Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we rely on proxy mode being based on argv[0]? #1293

Closed
SimonSapin opened this issue Nov 14, 2017 · 3 comments · Fixed by #1295
Closed

Can we rely on proxy mode being based on argv[0]? #1293

SimonSapin opened this issue Nov 14, 2017 · 3 comments · Fixed by #1295

Comments

@SimonSapin
Copy link
Contributor

We’re considering replacing Servo’s rust/cargo bootstrapping code with rustup.rs: servo/servo#11361

My tentative plan is to always use rustup, and run it with a RUSTUP_TOOLCHAIN environment variable that selects the appropriate date nightly or versioned stable. However we’d want to make sure we run cargo through rustup.rs’s proxy, and not run directly a plain Cargo that would ignore RUSTUP_TOOLCHAIN and use a rustc that might not be the appropriate version. (Which would likely cause a confusing build error later on.)

So, to do that we’d start it from Python with something like subprocess.Popen(["cargo"] + cargo_args, executable="rustup"). (And similarly for rustc, rustdoc, etc.) This makes Python look for an executable in $PATH named rustup, and execute it with argv[0] == "cargo".

So this all relies on what’s probably an implementation detail of rustup.rs: the proxy executable installed at $CARGO_HOME/bin/cargo is exactly the same as $CARGO_HOME/bin/rustup, and they behave differently based on argv[0].

Is this a bad idea? Is there a better way? Or does it sound fine to rely on running rustup with a different argv[0] triggering proxy mode?

@Diggsey
Copy link
Contributor

Diggsey commented Nov 14, 2017

If you're always specifying the toolchain, could you just use rustup run <toolchain> <command>?

@SimonSapin
Copy link
Contributor Author

I didn’t realize rustup run existed. This is exactly what we need, thanks!

@SimonSapin
Copy link
Contributor Author

Ah, rustup run doesn’t automatically install missing toolchains, though. So that doesn’t work for this use case.

@SimonSapin SimonSapin reopened this Nov 14, 2017
SimonSapin added a commit to SimonSapin/rustup.rs that referenced this issue Nov 21, 2017
bors added a commit that referenced this issue Nov 22, 2017
Add `rustup run --install`

This fixes #1293. See discussion there.
mattico pushed a commit to mattico/rustup.rs that referenced this issue Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants