@@ -316,14 +316,14 @@ impl<'gctx> InstallablePackage<'gctx> {
316316 fn install_one ( mut self , dry_run : bool ) -> CargoResult < bool > {
317317 self . gctx . shell ( ) . status ( "Installing" , & self . pkg ) ?;
318318
319- let dst = self . root . join ( "bin" ) . into_path_unlocked ( ) ;
320- // `dst` is usually absolute; if not, make it absolute so messages are clearer.
319+ // Normalize to absolute path for consistency throughout.
321320 // See: https://github.com/rust-lang/cargo/issues/16023
321+ let dst_path = self . root . join ( "bin" ) . into_path_unlocked ( ) ;
322322 let cwd = self . gctx . cwd ( ) ;
323- let dst_abs_root = if dst . is_absolute ( ) {
324- paths:: normalize_path ( dst . as_path ( ) )
323+ let dst = if dst_path . is_absolute ( ) {
324+ paths:: normalize_path ( dst_path . as_path ( ) )
325325 } else {
326- paths:: normalize_path ( & cwd. join ( & dst ) )
326+ paths:: normalize_path ( & cwd. join ( & dst_path ) )
327327 } ;
328328
329329 let mut td_opt = None ;
@@ -466,18 +466,17 @@ impl<'gctx> InstallablePackage<'gctx> {
466466 // Move the temporary copies into `dst` starting with new binaries.
467467 for bin in to_install. iter ( ) {
468468 let src = staging_dir. path ( ) . join ( bin) ;
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 ( ) ) ?;
469+ let dst_bin = dst. join ( bin) ;
470+ self . gctx . shell ( ) . status ( "Installing" , dst_bin. display ( ) ) ?;
472471 if !dry_run {
473- fs:: rename ( & src, & dst_rel ) . with_context ( || {
472+ fs:: rename ( & src, & dst_bin ) . with_context ( || {
474473 format ! (
475474 "failed to move `{}` to `{}`" ,
476475 src. display( ) ,
477- dst_abs . display( )
476+ dst_bin . display( )
478477 )
479478 } ) ?;
480- installed. bins . push ( dst_rel ) ;
479+ installed. bins . push ( dst_bin ) ;
481480 successful_bins. insert ( bin. to_string ( ) ) ;
482481 }
483482 }
@@ -488,15 +487,14 @@ impl<'gctx> InstallablePackage<'gctx> {
488487 let mut try_install = || -> CargoResult < ( ) > {
489488 for & bin in to_replace. iter ( ) {
490489 let src = staging_dir. path ( ) . join ( bin) ;
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 ( ) ) ?;
490+ let dst_bin = dst. join ( bin) ;
491+ self . gctx . shell ( ) . status ( "Replacing" , dst_bin. display ( ) ) ?;
494492 if !dry_run {
495- fs:: rename ( & src, & dst_rel ) . with_context ( || {
493+ fs:: rename ( & src, & dst_bin ) . with_context ( || {
496494 format ! (
497495 "failed to move `{}` to `{}`" ,
498496 src. display( ) ,
499- dst_abs . display( )
497+ dst_bin . display( )
500498 )
501499 } ) ?;
502500 successful_bins. insert ( bin. to_string ( ) ) ;
@@ -673,7 +671,15 @@ pub fn install(
673671 lockfile_path : Option < & Path > ,
674672) -> CargoResult < ( ) > {
675673 let root = resolve_root ( root, gctx) ?;
676- let dst = root. join ( "bin" ) . into_path_unlocked ( ) ;
674+ // Normalize to absolute path for consistency throughout.
675+ // See: https://github.com/rust-lang/cargo/issues/16023
676+ let dst_path = root. join ( "bin" ) . into_path_unlocked ( ) ;
677+ let cwd = gctx. cwd ( ) ;
678+ let dst = if dst_path. is_absolute ( ) {
679+ paths:: normalize_path ( dst_path. as_path ( ) )
680+ } else {
681+ paths:: normalize_path ( & cwd. join ( & dst_path) )
682+ } ;
677683 let map = SourceConfigMap :: new ( gctx) ?;
678684
679685 let current_rust_version = if opts. honor_rust_version . unwrap_or ( true ) {
@@ -795,22 +801,14 @@ pub fn install(
795801 if installed_anything {
796802 // Print a warning that if this directory isn't in PATH that they won't be
797803 // 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- } ;
806804 let path = gctx. get_env_os ( "PATH" ) . unwrap_or_default ( ) ;
807- let dst_in_path = env:: split_paths ( & path) . any ( |path| path == dst_abs ) ;
805+ let dst_in_path = env:: split_paths ( & path) . any ( |path| path == dst ) ;
808806
809807 if !dst_in_path {
810808 gctx. shell ( ) . warn ( & format ! (
811809 "be sure to add `{}` to your PATH to be \
812810 able to run the installed binaries",
813- dst_abs . display( )
811+ dst . display( )
814812 ) ) ?;
815813 }
816814 }
0 commit comments