rustc vs rustc.exe in PATH (Windows/MinGW) #3319

Closed
mcandre opened this Issue Aug 31, 2012 · 18 comments

Projects

None yet

8 participants

@mcandre
mcandre commented Aug 31, 2012

When I open the Command Prompt, rustc is successfully found in PATH, but needs libgcc to run.

C:\> rustc --lib mycode.rs
The program can't start because libgcc_s_dw2-1.dll is missing from your computer.
Try reinstalling the program to fix this problem.

So I try MinGW.

$ rustc --lib mycode.rs
sh: rustc: command not found
$ where rustc
c:\Program Files (x86)\Rust\bin\rustc.exe
$ rustc.exe
Usage: c:\Program Files (x86)\Rust\bin\rustc.exe [options] <input>
...

For some reason, MinGW cannot find rustc unless it is specified as rustc.exe. This is highly inconvenient, as my shell scripts are configured to call rustc; I do not want to use different settings between [Windows] and [Mac OS X, Linux, Unix, Haiku]. I just want to be able to use rustc in all cases, if possible straight from the Command Prompt rather than MinGW.

Can someone please bundle the libgcc DLL with rustc in the Windows installer so that it can be used like a normal decent program?

@brson
Contributor
brson commented Aug 31, 2012

This is annoying. It's because we also have a directory called rustc in the same location as rustc.exe. I would like to change the name of this directory. Note though that we should not rename it to 'rust' because it's likely we'll have a tool with that name too at some point.

@graydon
Contributor
graydon commented Mar 25, 2013

concerning libgcc, shipping libgcc won't get us anywhere since rustc uses gcc as a link driver: so rustc will start but won't compile (well, link) anything. the rustc/ directory sub-issue here is fixable, though.

@brson
Contributor
brson commented Mar 29, 2013

A solution @graydon mentioned to being able to name rustc on the command line was to always put the target artifacts under lib/ even on windows. That way there is no rustc directory under bin/. I'm not entirely sure of all the details involved to make that happen but it seems plausible.

@brson
Contributor
brson commented Mar 31, 2013

Not going to happen for 0.6, sadly.

@graydon
Contributor
graydon commented Apr 29, 2013

nobody has taken this on for 0.7, sorry. pushing to general maturity milestone. it does need to get fixed.

@thomaslee
Contributor

I'm keen to close out #5223 to inch rust a little closer to readiness for downstream packages. I think if we can address this issue (#3319), #5223 should be trivial since the only weird case in there atm is for Windows.

That said, it's not entirely clear to me what @graydon had in mind here: do we simply go back to installing library artifacts under lib/ on win32 (as we currently do for Linux et al) & ask Windows users to update their %PATH% to include lib/ in addition to bin/?

Given this has slipped a few releases, I'm guessing it's more difficult than that. What would be involved in closing this out?

@milesrout

@brson If that is indeed the problem (the rustc directory), why not rename that directory in the next release?

@ubershmekel

I'm completely new to rust and llvm but ok with windows, c and python. So pardon my ignorance but I'd like to help if I can. I don't understand how are these related to the path problem:

#9252

#7089

#3318

I just now finished installing rust on windows8x64 (6.2.9200) and had 2 bumps - missing libstdc++-6a.dll, installing mingw only to get "The application was unable to start correctly (0xc0000142)." because it was the wrong dll. To finally download http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.6.2-1/libstdc%2B%2B-4.6.2-1-mingw32-dll-6.tar.lzma/download so I hope this shouldn't be too hard to fix by just bundling the right dll. Do tell if you don't mind me trying to make a pull request or if someone's already on it. ubershmekel at gmail

@klutzy
Contributor
klutzy commented Oct 9, 2013

@ubershmekel sounds like it is #9252 (missing dlls). We currently ships them, but it was done after 0.8 release. So if you've installed 0.8 binary, you had to download such old dlls manually.
If you've installed rust from latest source, there should be no "wrong dll" issues. In the case, please leave a comment at #9252 so we can investigate it more :)

@ubershmekel

Indeed I downloaded what http://static.rust-lang.org/doc/master/tutorial.html told me to. That was http://static.rust-lang.org/dist/rust-0.8-install.exe which means that perhaps a minor documentation patch remains to be applied after a new installer is distributed.

Thank you!

@mcandre
mcandre commented Oct 10, 2013

Does the Chocolatey package put rustc in PATH?

http://chocolatey.org/packages?q=rust

On Wed, Oct 9, 2013 at 4:38 AM, Yuval Greenfield
notifications@github.comwrote:

Indeed I downloaded what
http://static.rust-lang.org/doc/master/tutorial.html told me to. That was
http://static.rust-lang.org/dist/rust-0.8-install.exe which means that
perhaps a minor documentation patch remains to be applied after a new
installer is distributed.

Thank you!


Reply to this email directly or view it on GitHubhttps://github.com/mozilla/rust/issues/3319#issuecomment-25954845
.

Cheers,

Andrew Pennebaker
www.yellosoft.us

@brson
Contributor
brson commented Oct 15, 2013

@milesrout I think we should probably rename the rustc directory to something else, yes, but not rust. Maybe rustlib.

@jhasse
Contributor
jhasse commented Dec 12, 2013

@mcandre Yes

@brson what about using the lib directory even on windows? The installer could simply add the lib directory also to the PATH.

When the rustc directory is in another directory than rustc.exe, MinGW has no problems with rustc even when the lib folder is also in the path:

$ ls /usr/local/bin | grep rustc
rustc.exe
$ ls /usr/local/lib | grep rustc
rustc
rustc-5b94a16f-0.9-pre.dll
$ rustc --version
C:\MinGW\msys\1.0\local\bin\rustc.exe 0.9-pre (d441c54 2013-12-11 05:41:18 -0800)
host: i686-pc-mingw32
$ echo $PATH
...:/usr/local/bin:/usr/local/lib:...

A problem would be that stage2/bin/rustdoc.exe etc. can't find their dlls during build. Maybe create the lib folder as a symbolic link on Windows during the build? (Vista only, needs admin rights)

@klutzy
Contributor
klutzy commented Dec 13, 2013

I'm thinking of a sketch like:

(unix -> win)
bin/rustc -> bin/rustc.exe
lib/libstd-###.so -> bin/std-###.dll
lib/rustc/<target>/lib/libstd-###.so -> lib/rustc/<target>/bin/std-###.dll
@jhasse
Contributor
jhasse commented Dec 18, 2013

@klutzy Looks like a good solution.

But maybe it's easier to rename the rustc directory to rustlib as brson said? I will try to come up with a patch that does this and see how this works out.

@klutzy
Contributor
klutzy commented Dec 18, 2013

@jhasse Yes, rustlib sounds better solution. (I thought the way to utilize lib/ but it's not practical.) I really hope your patch land soon! :D

@jhasse
Contributor
jhasse commented Dec 18, 2013

Okay first version of the patch is finished (only tested on Linux). To build with my patch on Linux I needed to do the following:

rm -rf x86_64-unknown-linux-gnu/stage* # make sure no left over dirs exist
./configure
ln -s rustlib/ x86_64-unknown-linux-gnu/stage0/lib/rustc # fix snapshot
make

I will test it on Windows in the next days.

@jhasse jhasse added a commit to jhasse/rust that referenced this issue Dec 22, 2013
@jhasse jhasse Make rustc's own lib directory configurable and change the default to…
… rustlib. Fixes #3319
a999086
@jhasse
Contributor
jhasse commented Dec 22, 2013

To create the symbolic link on Windows start cmd.exe as admin and execute:

mklink /D i686-pc-mingw32\stage0\bin\rustc rustlib

Then make will work. I've created a PR: #11118
I don't know what to do about the stage0 snapshot (build bot will fail?), it needs to be rebuild on all platforms now.

@bors bors added a commit that referenced this issue Dec 23, 2013
@bors bors auto merge of #11118 : jhasse/rust/patch-rustlibdir, r=alexcrichton
...stlib. Fixes #3319
f2be0e6
@jhasse jhasse added a commit to jhasse/rust that referenced this issue Jan 2, 2014
@jhasse jhasse Make rustc's own lib directory configurable and change the default to…
… rustlib. Fixes #3319
ffebb75
@jhasse jhasse added a commit to jhasse/rust that referenced this issue Jan 2, 2014
@jhasse jhasse Make rustc's own lib directory configurable and change the default to…
… rustlib. Fixes #3319
cc0eb89
@bors bors added a commit that referenced this issue Jan 3, 2014
@bors bors auto merge of #11118 : jhasse/rust/patch-rustlibdir, r=alexcrichton
...stlib. Fixes #3319
00fbb64
@jhasse jhasse added a commit to jhasse/rust that referenced this issue Jan 4, 2014
@jhasse jhasse Make rustc's own lib directory configurable and change the default to…
… rustlib. Fixes #3319
22f7063
@bors bors added a commit that referenced this issue Jan 4, 2014
@bors bors auto merge of #11118 : jhasse/rust/patch-rustlibdir, r=alexcrichton
...stlib. Fixes #3319
42a2f99
@bors bors added a commit that referenced this issue Jan 6, 2014
@bors bors auto merge of #11118 : jhasse/rust/patch-rustlibdir, r=alexcrichton
...stlib. Fixes #3319
b80df75
@bors bors added a commit that referenced this issue Jan 6, 2014
@bors bors auto merge of #11118 : jhasse/rust/patch-rustlibdir, r=alexcrichton
...stlib. Fixes #3319
4e622be
@bors bors closed this in 6abe0ef Jan 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment