-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Fix cargo run
on Windows
#95254
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix cargo run
on Windows
#95254
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
c379355
to
37835dc
Compare
I don't know if rustc currently builds on any other platforms that have executable suffixes but maybe using |
37835dc
to
dcd7dbf
Compare
This comment has been minimized.
This comment has been minimized.
Fixes the following error: ``` error: failed to run custom build command for `bootstrap v0.0.0 (C:\Users\Walther\git\rust\src\bootstrap)` Caused by: process didn't exit successfully: `C:\Users\Walther\git\rust\target\debug\build\bootstrap-7757a4777dec0f86\build-script-build` (exit code: 101) --- stdout cargo:rerun-if-changed=build.rs cargo:rerun-if-env-changed=RUSTC cargo:rustc-env=BUILD_TRIPLE=x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PATH --- stderr thread 'main' panicked at 'assertion failed: rustc.is_absolute()', src\bootstrap\build.rs:22:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... error: build failed ``` The problem was that the `dir.join` check only works with rustc.exe, not rustc. Thanks Walther for the help testing the fix!
dcd7dbf
to
76d7bcc
Compare
/// Given an executable called `name`, return the filename for the | ||
/// executable for a particular target. | ||
pub fn exe(name: &PathBuf) -> PathBuf { | ||
if EXE_EXTENSION != "" && name.extension() != Some(EXE_EXTENSION.as_ref()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this method is basically name.with_extension(EXE_EXTENSION)
? Unless I'm missing something, that's the intent of the code...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is this doesn't replace any existing extension. with_extension will change my.file
to my.exe
.
@rustbot ready |
Hi @Mark-Simulacrum , I saw you marked this as waiting on author, but I'm not sure why? That said it's very unlikely for this to actually come up, so I'm ok with using |
@rustbot ready |
Seems okay, I think the author status was probably just a race with each other (I don't recall seeing your comment so probably I either by accident changed the wrong PR or something else went wrong). @bors r+ |
📌 Commit 76d7bcc has been approved by |
…imulacrum Fix `cargo run` on Windows Fixes the following error: ``` error: failed to run custom build command for `bootstrap v0.0.0 (C:\Users\Walther\git\rust\src\bootstrap)` Caused by: process didn't exit successfully: `C:\Users\Walther\git\rust\target\debug\build\bootstrap-7757a4777dec0f86\build-script-build` (exit code: 101) --- stdout cargo:rerun-if-changed=build.rs cargo:rerun-if-env-changed=RUSTC cargo:rustc-env=BUILD_TRIPLE=x86_64-pc-windows-msvc cargo:rerun-if-env-changed=PATH --- stderr thread 'main' panicked at 'assertion failed: rustc.is_absolute()', src\bootstrap\build.rs:22:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... error: build failed ``` The problem was that the `dir.join` check only works with `rustc.exe`, not `rustc`. Thanks `@Walther` for the help testing the fix! Helps with rust-lang#94829.
☀️ Test successful - checks-actions |
This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. |
Fixes the following error:
The problem was that the
dir.join
check only works withrustc.exe
, notrustc
.Thanks @Walther for the help testing the fix!
Helps with #94829.