@@ -317,6 +317,14 @@ impl<'gctx> InstallablePackage<'gctx> {
317317 self . gctx . shell ( ) . status ( "Installing" , & self . pkg ) ?;
318318
319319 let dst = self . root . join ( "bin" ) . into_path_unlocked ( ) ;
320+ // `dst` is usually absolute; if not, make it absolute so messages are clearer.
321+ // See: https://github.com/rust-lang/cargo/issues/16023
322+ let cwd = self . gctx . cwd ( ) ;
323+ let dst_abs_root = if dst. is_absolute ( ) {
324+ paths:: normalize_path ( dst. as_path ( ) )
325+ } else {
326+ paths:: normalize_path ( & cwd. join ( & dst) )
327+ } ;
320328
321329 let mut td_opt = None ;
322330 let mut needs_cleanup = false ;
@@ -458,13 +466,18 @@ impl<'gctx> InstallablePackage<'gctx> {
458466 // Move the temporary copies into `dst` starting with new binaries.
459467 for bin in to_install. iter ( ) {
460468 let src = staging_dir. path ( ) . join ( bin) ;
461- let dst = dst. join ( bin) ;
462- self . gctx . shell ( ) . status ( "Installing" , dst. display ( ) ) ?;
469+ let dst_rel = dst. join ( bin) ;
470+ let dst_abs = dst_abs_root. join ( bin) ;
471+ self . gctx . shell ( ) . status ( "Installing" , dst_abs. display ( ) ) ?;
463472 if !dry_run {
464- fs:: rename ( & src, & dst) . with_context ( || {
465- format ! ( "failed to move `{}` to `{}`" , src. display( ) , dst. display( ) )
473+ fs:: rename ( & src, & dst_rel) . with_context ( || {
474+ format ! (
475+ "failed to move `{}` to `{}`" ,
476+ src. display( ) ,
477+ dst_abs. display( )
478+ )
466479 } ) ?;
467- installed. bins . push ( dst ) ;
480+ installed. bins . push ( dst_rel ) ;
468481 successful_bins. insert ( bin. to_string ( ) ) ;
469482 }
470483 }
@@ -475,11 +488,16 @@ impl<'gctx> InstallablePackage<'gctx> {
475488 let mut try_install = || -> CargoResult < ( ) > {
476489 for & bin in to_replace. iter ( ) {
477490 let src = staging_dir. path ( ) . join ( bin) ;
478- let dst = dst. join ( bin) ;
479- self . gctx . shell ( ) . status ( "Replacing" , dst. display ( ) ) ?;
491+ let dst_rel = dst. join ( bin) ;
492+ let dst_abs = dst_abs_root. join ( bin) ;
493+ self . gctx . shell ( ) . status ( "Replacing" , dst_abs. display ( ) ) ?;
480494 if !dry_run {
481- fs:: rename ( & src, & dst) . with_context ( || {
482- format ! ( "failed to move `{}` to `{}`" , src. display( ) , dst. display( ) )
495+ fs:: rename ( & src, & dst_rel) . with_context ( || {
496+ format ! (
497+ "failed to move `{}` to `{}`" ,
498+ src. display( ) ,
499+ dst_abs. display( )
500+ )
483501 } ) ?;
484502 successful_bins. insert ( bin. to_string ( ) ) ;
485503 }
@@ -777,14 +795,22 @@ pub fn install(
777795 if installed_anything {
778796 // Print a warning that if this directory isn't in PATH that they won't be
779797 // able to run these commands.
798+ // `dst` is usually absolute; if not, make it absolute so messages are clearer.
799+ // See: https://github.com/rust-lang/cargo/issues/16023
800+ let cwd = gctx. cwd ( ) ;
801+ let dst_abs = if dst. is_absolute ( ) {
802+ paths:: normalize_path ( dst. as_path ( ) )
803+ } else {
804+ paths:: normalize_path ( & cwd. join ( & dst) )
805+ } ;
780806 let path = gctx. get_env_os ( "PATH" ) . unwrap_or_default ( ) ;
781807 let dst_in_path = env:: split_paths ( & path) . any ( |path| path == dst) ;
782808
783809 if !dst_in_path {
784810 gctx. shell ( ) . warn ( & format ! (
785811 "be sure to add `{}` to your PATH to be \
786812 able to run the installed binaries",
787- dst . display( )
813+ dst_abs . display( )
788814 ) ) ?;
789815 }
790816 }
0 commit comments