Skip to content

rustbuild: if stage0 binaries can't be run, kindly inform user #40529

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

Open
cengiz-io opened this issue Mar 14, 2017 · 5 comments
Open

rustbuild: if stage0 binaries can't be run, kindly inform user #40529

cengiz-io opened this issue Mar 14, 2017 · 5 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@cengiz-io
Copy link
Contributor

cengiz-io commented Mar 14, 2017

Hello!

I was trying to build rust within Alpine linux and since it comes with musl instead of glibc I've bumped into this confusing error message from rustbuild.

$ make check
Traceback (most recent call last):
  File "/home/test/rust/src/bootstrap/bootstrap.py", line 614, in <module>
    main()
  File "/home/test/rust/src/bootstrap/bootstrap.py", line 602, in main
    bootstrap()
  File "/home/test/rust/src/bootstrap/bootstrap.py", line 587, in bootstrap
    rb.build_bootstrap()
  File "/home/test/rust/src/bootstrap/bootstrap.py", line 377, in build_bootstrap
    self.run(args, env)
  File "/home/test/rust/src/bootstrap/bootstrap.py", line 380, in run
    proc = subprocess.Popen(args, env=env)
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
make: *** [Makefile:54: check] Error 1

cargo is there, in stage0 directory but since it's not compatible with musl. execution fails.

My proposal is (thanks @matt36 for the idea) that we should catch the error and inform the user with more context.

$ make check
/home/test/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo could not be executed.

You might want to check your internet connection stability since it might be preventing
you from getting stage0 packages correctly.

If the archives are intact, then please check your operating system compatibility on prebuilt 
stage0 binaries. 

Go to: http://docs.rust-lang.org/some/docs/here for more information.

Build completed unsuccessfully in 0:00:00
make: *** [Makefile:54: check] Error 127

(If you're wondering "why cargo is not found?" please refer to #31322)

Thanks

@matt36
Copy link

matt36 commented Mar 15, 2017

There is a downside to adding shell=True to the subprocess.Popen call: it creates the potential for the script to be vulnerable to a 'shell injection' - see https://docs.python.org/2/library/subprocess.html#frequently-used-arguments

The security risks of this might be minimal (I'm not very familiar with the bootstrap process), or could be mitigated by correctly escaping the arguments passed to the shell.

In this particular case it would probably be simpler to improve the bootstrap.py script to catch this exception and improve the error message instead.

@cengiz-io
Copy link
Contributor Author

In this particular case it would probably be simpler to improve the bootstrap.py script to catch this exception and improve the error message instead.

That sounds so much better.

@cengiz-io cengiz-io changed the title rustbuild: subprocess should be executed in a shell rustbuild: if stage0 binaries can't be run, kindly inform user Mar 16, 2017
@cengiz-io
Copy link
Contributor Author

Hello @alexcrichton!

(Moving the discussion into issue)

Yes, I know that musl is not directly supported. But I'm throwing ideas right now.

Instead of changing it to a shell (like I did), I think we can catch the error and report it with more context, like

Execution error: /path/bin/cargo could not be run. Please check your _______
What do you think?

@alexcrichton
Copy link
Member

@cengizio that sounds totally plausible to me!

@Mark-Simulacrum Mark-Simulacrum added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jun 13, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 27, 2017
@Mark-Simulacrum Mark-Simulacrum added this to the impl period milestone Sep 15, 2017
@aturon aturon removed this from the impl period milestone Sep 15, 2017
@Enselic
Copy link
Member

Enselic commented Oct 6, 2023

Triage: Since musl binaries have been shipped for many years now, we can probably close this as won't fix? If not, in what realistic scenario would a user benefit from this feature being implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

6 participants