@@ -75,26 +75,12 @@ pub fn cli() -> App {
75
75
}
76
76
77
77
pub fn exec ( config : & mut Config , args : & ArgMatches < ' _ > ) -> CliResult {
78
- let workspace;
79
78
if let Some ( path) = args. value_of_path ( "path" , config) {
80
79
config. reload_rooted_at ( path) ?;
81
- // Only provide worksapce information for local crate installation
82
- workspace = args. workspace ( config) . ok ( ) ;
83
80
} else {
84
81
config. reload_rooted_at ( config. home ( ) . clone ( ) . into_path_unlocked ( ) ) ?;
85
- workspace = None ;
86
82
}
87
83
88
- let mut compile_opts = args. compile_options (
89
- config,
90
- CompileMode :: Build ,
91
- workspace. as_ref ( ) ,
92
- ProfileChecking :: Checked ,
93
- ) ?;
94
-
95
- compile_opts. build_config . requested_profile =
96
- args. get_profile_name ( config, "release" , ProfileChecking :: Checked ) ?;
97
-
98
84
let krates = args
99
85
. values_of ( "crate" )
100
86
. unwrap_or_default ( )
@@ -130,6 +116,26 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
130
116
let version = args. value_of ( "version" ) ;
131
117
let root = args. value_of ( "root" ) ;
132
118
119
+ // We only provide worksapce information for local crate installation from
120
+ // one of the following sources:
121
+ // - From current working directory (only work for edition 2015).
122
+ // - From a specific local file path.
123
+ let workspace = if from_cwd || args. is_present ( "path" ) {
124
+ args. workspace ( config) . ok ( )
125
+ } else {
126
+ None
127
+ } ;
128
+
129
+ let mut compile_opts = args. compile_options (
130
+ config,
131
+ CompileMode :: Build ,
132
+ workspace. as_ref ( ) ,
133
+ ProfileChecking :: Checked ,
134
+ ) ?;
135
+
136
+ compile_opts. build_config . requested_profile =
137
+ args. get_profile_name ( config, "release" , ProfileChecking :: Checked ) ?;
138
+
133
139
if args. is_present ( "list" ) {
134
140
ops:: install_list ( root, config) ?;
135
141
} else {
0 commit comments