@@ -215,27 +215,30 @@ fn install_one(
215
215
Some ( Filesystem :: new ( config. cwd ( ) . join ( "target-install" ) ) )
216
216
} ;
217
217
218
+ let mut git_package = None ;
218
219
let mut ws = match overidden_target_dir {
219
220
Some ( dir) => Workspace :: ephemeral ( pkg, config, Some ( dir) , false ) ?,
220
221
None => {
221
222
let mut ws = Workspace :: new ( pkg. manifest_path ( ) , config) ?;
222
223
ws. set_require_optional_deps ( false ) ;
223
224
224
225
// Use tempdir to build git depedencies to prevent bloat in cargo cache
225
- if source_id. is_git ( ) && config. target_dir ( ) ?. is_none ( ) {
226
- match TempFileBuilder :: new ( ) . prefix ( "cargo-install" ) . tempdir ( ) {
227
- Ok ( td) => ws. set_target_dir ( Filesystem :: new ( td. path ( ) . to_owned ( ) ) ) ,
228
- // If tempfile creation fails, write to cargo cache but clean up afterwards
229
- Err ( _) => needs_cleanup = true ,
226
+ if source_id. is_git ( ) {
227
+ if config. target_dir ( ) ?. is_none ( ) {
228
+ match TempFileBuilder :: new ( ) . prefix ( "cargo-install" ) . tempdir ( ) {
229
+ Ok ( td) => ws. set_target_dir ( Filesystem :: new ( td. path ( ) . to_owned ( ) ) ) ,
230
+ // If tempfile creation fails, write to cargo cache but clean up afterwards
231
+ Err ( _) => needs_cleanup = true ,
232
+ }
230
233
}
234
+ git_package = Some ( & pkg) ;
231
235
}
232
- ws. set_package ( pkg) ;
233
236
234
237
ws
235
- }
238
+ } ,
236
239
} ;
237
240
ws. set_ignore_lock ( config. lock_update_allowed ( ) ) ;
238
- let pkg = ws. current ( ) ?;
241
+ let pkg = git_package . map_or_else ( || ws. current ( ) , |pkg| Ok ( pkg ) ) ?;
239
242
240
243
if from_cwd {
241
244
if pkg. manifest ( ) . edition ( ) == Edition :: Edition2015 {
0 commit comments