@@ -200,48 +200,34 @@ fn install_one(
200
200
) ?
201
201
} ;
202
202
203
- let mut td_opt = None ;
204
- let mut needs_cleanup = false ;
205
- let overidden_target_dir = if source_id. is_git ( ) || source_id. is_path ( ) {
206
- None
207
- } else if let Some ( dir) = config. target_dir ( ) ? {
208
- Some ( dir)
209
- } else if let Ok ( td) = TempFileBuilder :: new ( ) . prefix ( "cargo-install" ) . tempdir ( ) {
210
- let p = td. path ( ) . to_owned ( ) ;
211
- td_opt = Some ( td) ;
212
- Some ( Filesystem :: new ( p) )
203
+ let ( mut ws, git_package) = if source_id. is_git ( ) {
204
+ // Don't use ws.current() in order to keep the package source as a git source so that
205
+ // install tracking uses the correct sourc.
206
+ ( Workspace :: new ( pkg. manifest_path ( ) , config) ?, Some ( & pkg) )
207
+ } else if source_id. is_path ( ) {
208
+ ( Workspace :: new ( pkg. manifest_path ( ) , config) ?, None )
213
209
} else {
214
- needs_cleanup = true ;
215
- Some ( Filesystem :: new ( config. cwd ( ) . join ( "target-install" ) ) )
210
+ ( Workspace :: ephemeral ( pkg, config, None , false ) ?, None )
216
211
} ;
212
+ ws. set_ignore_lock ( config. lock_update_allowed ( ) ) ;
213
+ ws. set_require_optional_deps ( false ) ;
217
214
218
- let mut git_package = None ;
219
- let mut ws = match overidden_target_dir {
220
- Some ( dir) => Workspace :: ephemeral ( pkg, config, Some ( dir) , false ) ?,
221
- None => {
222
- let mut ws = Workspace :: new ( pkg. manifest_path ( ) , config) ?;
223
- ws. set_require_optional_deps ( false ) ;
224
-
225
- // Use tempdir to build git depedencies to prevent bloat in cargo cache
226
- if source_id. is_git ( ) {
227
- if config. target_dir ( ) ?. is_none ( ) {
228
- match TempFileBuilder :: new ( ) . prefix ( "cargo-install" ) . tempdir ( ) {
229
- Ok ( td) => {
230
- let p = td. path ( ) . to_owned ( ) ;
231
- td_opt = Some ( td) ;
232
- ws. set_target_dir ( Filesystem :: new ( p) ) ;
233
- }
234
- // If tempfile creation fails, write to cargo cache but clean up afterwards
235
- Err ( _) => needs_cleanup = true ,
236
- }
237
- }
238
- git_package = Some ( & pkg) ;
239
- }
215
+ let mut td_opt = None ;
216
+ let mut needs_cleanup = false ;
217
+ if !source_id. is_path ( ) {
218
+ let target_dir = if let Some ( dir) = config. target_dir ( ) ? {
219
+ dir
220
+ } else if let Ok ( td) = TempFileBuilder :: new ( ) . prefix ( "cargo-install" ) . tempdir ( ) {
221
+ let p = td. path ( ) . to_owned ( ) ;
222
+ td_opt = Some ( td) ;
223
+ Filesystem :: new ( p)
224
+ } else {
225
+ needs_cleanup = true ;
226
+ Filesystem :: new ( config. cwd ( ) . join ( "target-install" ) )
227
+ } ;
228
+ ws. set_target_dir ( target_dir) ;
229
+ }
240
230
241
- ws
242
- }
243
- } ;
244
- ws. set_ignore_lock ( config. lock_update_allowed ( ) ) ;
245
231
let pkg = git_package. map_or_else ( || ws. current ( ) , |pkg| Ok ( pkg) ) ?;
246
232
247
233
if from_cwd {
0 commit comments