@@ -173,8 +173,12 @@ impl ToolchainLayer {
173173 // Run steps execute with `bash --noprofile --norc`, so
174174 // profile.d PATH exports are never sourced. Symlink the
175175 // cargo binaries into /usr/local/bin so they are on the
176- // default system PATH for every step shell.
177- "ln -sf $HOME/.cargo/bin/cargo /usr/local/bin/cargo; ln -sf $HOME/.cargo/bin/rustc /usr/local/bin/rustc; ln -sf $HOME/.cargo/bin/rustup /usr/local/bin/rustup" . into( ) ,
176+ // default system PATH for every step shell. `rustdoc` is
177+ // included because `cargo test` spawns it by bare name for
178+ // doctests: without it on PATH the whole workspace test
179+ // step dies with `could not execute process rustdoc`
180+ // after every real test has already passed.
181+ "ln -sf $HOME/.cargo/bin/cargo /usr/local/bin/cargo; ln -sf $HOME/.cargo/bin/rustc /usr/local/bin/rustc; ln -sf $HOME/.cargo/bin/rustdoc /usr/local/bin/rustdoc; ln -sf $HOME/.cargo/bin/rustup /usr/local/bin/rustup" . into( ) ,
178182 ] ,
179183 ] ,
180184 Self :: Python ( version) => {
@@ -538,6 +542,22 @@ mod tests {
538542 assert ! ( !script. contains( "sh.rustup.rs" ) ) ;
539543 }
540544
545+ /// `cargo test --workspace` spawns `rustdoc` by bare name for doctests, so
546+ /// the interpreter must be on the default PATH of a `bash --noprofile
547+ /// --norc` step shell. Without the symlink the workspace test step fails
548+ /// with `could not execute process rustdoc` after every real test passed.
549+ #[ test]
550+ fn rust_layer_puts_rustdoc_on_default_path ( ) {
551+ let commands = ToolchainLayer :: Rust ( "stable" . into ( ) ) . install_commands ( ) ;
552+ let script = commands[ 1 ] . join ( " " ) ;
553+ for binary in [ "cargo" , "rustc" , "rustdoc" , "rustup" ] {
554+ assert ! (
555+ script. contains( & format!( "/usr/local/bin/{binary}" ) ) ,
556+ "{binary} must be linked onto the default PATH: {script}"
557+ ) ;
558+ }
559+ }
560+
541561 #[ test]
542562 fn go_layer_install_resolves_minimum_version ( ) {
543563 let commands = ToolchainLayer :: Go ( "1.24" . into ( ) ) . install_commands ( ) ;
0 commit comments