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

rustup does not recognize Visual C++ Build Tools #1003

Closed
projektir opened this issue Mar 22, 2017 · 38 comments
Closed

rustup does not recognize Visual C++ Build Tools #1003

projektir opened this issue Mar 22, 2017 · 38 comments

Comments

@projektir
Copy link

Previously, rustc and related tools worked fine for me, but I had VS itself installed with the C++ tools. I've just reinstalled Windows 10. I've installed Visual C++ Build Tools from the landinghub link, no SDK,, but when I run rustup-init.exe, it still tells me that it's missing. There's nothing else Rust or Visual Studio related on my machine.

I ran the installer again, but it has nothing to offer besides installing SDK's that I don't need.

I've installed updates and restarted my computer, but that didn't help.

I've added the Microsoft Visual C++ Build Tools folder to PATH, that didn't help, either.

Either rustup truly needs more than just the Build Tools themselves, or it's not doing a very good job of detecting it.

@projektir
Copy link
Author

Installing Visual Studio 2017 for C++ Desktop Development makes it work. Perhaps specifying installing VS with C++ is the safer bet.

@redstrike
Copy link

redstrike commented Mar 28, 2017

@projektir I got this issue. I have tested many custom installation settings of Visual C++ 2015 Build Tools installer. But it seems that the installer's custom mode doesn't behave the same as the DEFAULT installation mode no matter the custom packages which we have chosen.

Install Visual C++ 2015 Build Tools with the DEFAULT installation will solve this problem 😄 and remember to re-proceed the installation with rustup-init. It may affect the linker.

Edit: rust requires Windows SDK (8.1 or 10 is ok). Another test: #1003 (comment)

image

After that, I encountered this linker issue: rust-lang/rust#30319
OMG... develop a Rust HelloWorld program on Windows is tougher than I expected :(

I have tried to install "Visual Studio 2017 for C++ Desktop Development" as suggested, but it still not work, and rustup doesn't recognize Visual C++ Build Tools. Again, I have tested VS 2017 installer by adding more components related to C++ development, also try to strip as much as possible.

Here is the required components to install Visual C++ via Visual Studio for Rust HelloWorld program:

image

rustup still requires VC++ 2015 toolset, Universal CRT SDK & Windows 8.1 SDK to recognize the build tools. Therefore, I removed all VS 2017 related programs and re-install Visual C++ 2015 Build Tools with the DEFAULT settings for my Rust HelloWorld program.

My linker issue is no longer happen anymore. I don't know why? Maybe, VS 2017's installation fixed it? I have tried to reproduce the linker problem by removing all and install again, but it has been disappeared.

What a horrible getting started experience with Rust on Windows!

@projektir
Copy link
Author

@redstrike so happy to see that someone else ran into this! Thanks for describing this in such detail.

I have tested VS 2017 installer by adding more components related to C++ development, also try to strip as much as possible.

I very much had a similar approach that I think was causing issues. I kept trying to strip down what I was installing since I didn't really need much from VS on my machine. Among other things, I get a weird feeling that the Windows SDK is required (and you have it selected in your list), which just doesn't make much sense to me. I may experiment a bit more and see if I can confirm that.

If we can figure out what exactly is needed for install, we could update the README.md. Seems like C++ 2015 Build Tools with DEFAULT settings (lol) is a good safe bet, but would also be nice to know how VS can be installed since many will have that on their machine.

@aturon
Copy link
Member

aturon commented Mar 28, 2017

cc @Diggsey @retep998 -- @brson is away right now, but this is a pretty troubling issue, and from what I understand may not be too hard to fix. Any chance either of you can help?

@Diggsey
Copy link
Contributor

Diggsey commented Mar 28, 2017

@aturon I'm not quite sure what you have in mind, beyond changing the documentation, nor why you consider this particularly troubling?

The fact is, rust currently requires (and has always required) all three of these components, and the components are installed by default when installing the VC++ build tools. If you remove those components it can't work.

I can add a note the installation instructions saying to use the default settings, but anything more detailed, such as exactly which components are required, may be difficult to keep up to date and correct for all versions of the installer, since MS have a tendency to change things up quite a bit!

Here's a breakdown of why each component is required:

  • Universal CRT
    Rust programs currently require a CRT
  • VC++ toolset
    Rustc needs a linker
  • Windows SDK
    libstd imports symbols from advapi32.lib, ws2_32.lib, userenv.lib and shell32.lib which are part of the windows SDK

@projektir @redstrike Is there something further you'd like to see changed?

@retep998
Copy link
Member

It doesn't really matter which VC++ toolset version you use, or which Universal CRT version you use, or which Windows SDK version you use as long as you have all three of them. However, it is generally better to have the newest versions when possible.

If you install VC++ via VS 2017, then Rust is currently incapable of autodetecting this VC++ installation, and you'll have to manually configure your environment using a vcvars bat file or the VC++ development command prompt option.

@steveklabnik
Copy link
Member

I was just about to jump in here to say

If you install VC++ via VS 2017, then Rust is currently incapable of autodetecting this VC++ installation, and you'll have to manually configure your environment using a vcvars bat file or the VC++ development command prompt option.

👍 we have people hitting this every day now.

@Diggsey
Copy link
Contributor

Diggsey commented Mar 28, 2017

Here's the relevant issue for VS 2017 detection: rust-lang/rust#38584

@redstrike
Copy link

redstrike commented Mar 28, 2017

@Diggsey Have more guide text is better than let the users sink themselves in unexpected issues and try to search for the solutions (It costs me a full afternoon to experiment with different installation settings).

I had a great getting started with Golang in the past, I only need to run the official go1.8.windows-amd64.msi and it does the all the tedious tasks for me without relying on Visual Studio/C++ toolchain. Each time, I want to update my Go or Node version, just download the official installer and run... DONE.

I don't have enough background in Computer Science, programming language & compiler design. But I think a modern system programming language like Rust should not rely on C++ build tools to compile & run HelloWorld program. I hope Rust could be that awesome and more beginner friendly.

@Diggsey
Copy link
Contributor

Diggsey commented Mar 28, 2017

@redstrike I agree we should do more documentation-wise.

I'm afraid what you're suggesting isn't really feasible for rust. Go avoids a dependency on a VC++ toolchain by implementing their own custom linker, which only works for go, and it comes with significant downsides. For example, as soon as you depend on a C library, you're back to needing a proper VC++ linker again.

NodeJS isn't really comparable because javascript isn't a compiled language. However, if you use any npm libraries that have native dependencies, you'll again need the VC++ build tools.

Basically. link.exe is the official microsoft linker, so if you want to link native programs for windows, that's what you use, and link.exe is part of the VC++ build tools.

In the future, we may be able to automatically start the VC++ build tools installation if the user requests it, when rustup is initially installed, and I think that's as good as it's likely to get honestly.

@brson
Copy link
Contributor

brson commented Mar 28, 2017

There seem to be several interrelated bugs here, and I'm not clear on them.

There's the bug to teach rustc how to find the VC 2017 linker. That is not this bug. This is a bug about rustup-init not detecting a usable VC 2017 install.

I'm not clear on why this is only a crisis now, when the VC 2017 bug in rustc has existed since 2016/12/31. Can anybody explain? (Maybe it only hit stable recently).

Since rustc doesn't work correctly with some VC 2017's, doesn't that mean that even if rustup fixes its own detection, that rust will still be broken?

Does anybody know what the necessary change to rustup is to make this detection work?

How many versions of VS 2017 are there, and which ones work correctly with rustc, which ones don't work correctly with rustc, which ones work with rustup, which don't work with rustup?

@retep998
Copy link
Member

@redstrike

Getting Rust to not depend on a C++ toolchain is quite a long way in the future and would involve several things:

  1. Using LLD as the linker. It currently has some deficiencies like no debug info on Windows, and still relies on calling other tools from the VC++ toolchain for certain things, so it's not something we can do today.
  2. We currently rely on the CRT for a few math and memory functions. We'd have to write our own versions of those functions. Not particularly difficult
  3. In order to access all the system functions, we depend on the plethora of import libraries provided by the Windows SDK. To not rely on them would require support for a dll link kind that would emit idata, and then would involve me updating winapi with DLL bindings to the tens of thousands of functions.

@retep998
Copy link
Member

I'm not clear on why this is only a crisis now, when the VC 2017 bug in rustc has existed since 2016/12/31.

Because VS 2017 only had its actual stable release in March. Before then it was just previews and release candidates.

Since rustc doesn't work correctly with some VC 2017's, doesn't that mean that even if rustup fixes its own detection, that rust will still be broken?

Unless you use vcvars to manually configure your environment, yes. Or if rustc delegates responsibility for detecting VC++ to rustup, which would involve the rustup proxies doing the autodetection and setting env vars appropriately before calling the actual binaries.

How many versions of VS 2017 are there, and which ones work correctly with rustc, which ones don't work correctly with rustc, which ones work with rustup, which don't work with rustup?

There is just the one VS 2017, and both rustc and rustup do not autodetect it currently. It can however have multiple VC++ toolsets installed and provides a COM api to select one of those toolsets which I am currently working with.

@brson
Copy link
Contributor

brson commented Mar 28, 2017

Thanks @retep998.

@projektir
Copy link
Author

This discussion is getting a bit derailed. This is NOT about VS 2017. This is about rustup not detecting VC++ Build Tools (note the title). The VS 2017 thing just shines light on what's happening.

It doesn't really matter which VC++ toolset version you use, or which Universal CRT version you use, or which Windows SDK version you use as long as you have all three of them. However, it is generally better to have the newest versions when possible.

It is not at all obvious from the rustup installation page that you need, say, the Windows SDK. It just says VC++ toolset, which was installed, and present in the programs list, but not picked up by rustup. When you run rustup, it complains about the toolset.

If you install VC++ via VS 2017, then Rust is currently incapable of autodetecting this VC++ installation, and you'll have to manually configure your environment using a vcvars bat file or the VC++ development command prompt option.

This is true, and that's why I went for the VC++ Build Tools install at first. But it's also a very weird experience when your VC++ 2017 install, which Rust is incapable of detecting, fixes the issue by apparent side effect of installing extra missing components rustup didn't specify were needed (such as the Windows SDK).

The problem I reported is with rustup not detecting the VC++ 2015 Build Tools, not VS 2017. It's completely understandable for rustup to not detect VS 2017. But it's a bad user experience when it tells you that VC++ 2015 Tools are OK, you install them, and it literally tells you they're not installed... when they're there... if it wants the SDK, it should say it wants the SDK.

I hope that clears my complaint up.

@Diggsey
Copy link
Contributor

Diggsey commented Mar 28, 2017

@projektir Ah, I think I see part of the confusion:

It just says VC++ toolset, which was installed

No, it says you need either (the VC++ build tools, which includes all three components), or (a full Visual Studio installation with the "C++ tools" option checked). I can see why it would be easy to misread that and believe that the "C++ tools" option applied to the former, but it only applies to the full visual studio option.

Note that when you customize the installation and remove those components, you no longer have the VC++ build tools installed. The installer just happens to be modular - if you uncheck every component it will essentially install nothing, there's no "core" selection of required components.

The problem I reported is with rustup not detecting the VC++ 2015 Build Tools,

But it is detecting them when they exist, you just don't have the "VC++ 2015 Build Tools" installed if you unchecked those components. Phrasing it as a detection problem is what started the confusion around VS 2017.

@projektir
Copy link
Author

Note that when you customize the installation and remove those components, you no longer have the VC++ build tools installed.

That doesn't seem true according to Microsoft, because there's a minimum install size to the build tools (2 GB), and when I checked my programs list, it listed Microsoft Visual C++ Build Tools as installed. So while this may be true in some sense, it's not any kind of obvious sense.

A given person may not be an expert on how rustup uses these tools, or how MS names their components, and shouldn't need to be. It's not infrequent for installers to come with a bunch of extra components a person may choose not to want to install for various reasons.

I think a small update to the rustup page to say that you need all modules that come with the MS VC++ installer wouldn't hurt, and I'm perfectly willing to create a PR for that as long as everyone's OK with that. I would have made a PR straight away if I didn't think originally that this was a problem with rustup's detection, rather than semantic issues around what "VC++ Build Tools" actually means.

@projektir
Copy link
Author

@Diggsey

Also, sorry to hammer this point further but I really think usability issues like this are very important to Rust's growth.

Consider @redstrike comment here:

But it seems that the installer's custom mode doesn't behave the same as the DEFAULT installation mode no matter the custom packages which we have chosen.

So if I'm understanding them correctly (I probably want to test this myself), regardless of which packages you choose, being in CUSTOM mode produces an installation rustup can't detect... that's definitely not something you can expect the average user to realize, I hope we can agree on that?

@retep998
Copy link
Member

retep998 commented Mar 29, 2017

So basically I need to split out all the VC++ detection logic into a separate crate which can provide diagnostics for why it failed to locate a suitable VC++ installation, including specific errors messages such as for when you have VC++ but not the Windows SDK. Then I need to make sure rustup, gcc, and rustc all get their detection logic from that crate.

Or if rustc delegates responsibility for detecting VC++ to rustup, which would involve the rustup proxies doing the autodetection and setting env vars appropriately before calling the actual binaries.

I just remembered that this won't work because of cross compilation and build scripts.

@redstrike
Copy link

@projektir @Diggsey @retep998

Let's reduce the scope from VS 2017 to this issue. In confusing mode yesterday, I may mismatch linker issue tests with rustup's recognization tests. So, I decided to reinstall VC++ 2015 Build Tools again to give you more information.

image
image

rustup can recognize VC++ build tools in custom mode with Windows 8.1 SDK or Windows 10 SDK.

Windows 10 SDK is bigger but requires fewer support packages than Windows 8.1 (Ex: VC++ 2013 Redist x86/x64).

image

@retep998
Copy link
Member

@redstrike So that confirms that there's nothing weird going on, and you just have to remember to select some Windows SDK version when installing the VC++ build tools. The initial fix for this is to expand the diagnostics and documentation to clarify that not only do you need the VC++ build tools, but you need to make sure you also get the Windows SDK with it. Later on we can then upgrade rustup to detect scenarios where VC++ was installed without the Windows SDK and emit a diagnostic telling the user of their mistake and how to fix it.

@redstrike
Copy link

redstrike commented Mar 29, 2017

@retep998 I have a concern about the linker. I could workaround this recognization issue with Default installation mode yesterday, but then I stuck at linker issue.

image

Installing Visual Studio helped me solve this problem by accident. At the moment, although I removed all VS components, I cannot reproduce the above linker problem anymore, but it may haunt other users in the future. This means just install VC++ 2015 Build Tools is not enough.

@retep998
Copy link
Member

@redstrike Looks like you had a broken installation of the Windows 8.1 SDK. As you can see it is passing it via /LIBPATH, but since it can't find ws2_32.lib that means there aren't any libraries in there. For the Windows 10 SDK rustc does sanity checks to make sure at least kernel32.lib is there, but I never implemented such a sanity check for the Windows 8.1 SDK. It does prefer the Windows 10 SDK over the Windows 8.1 SDK though so as long as you have some valid Windows SDK it should work.

@redstrike
Copy link

@retep998

For the Windows 10 SDK rustc does sanity checks to make sure at least kernel32.lib is there, but I never implemented such a sanity check for the Windows 8.1 SDK.

In a typical scenario, a beginner's Windows 10 machine usually doesn't have any installed Windows SDK. By default, Windows 8.1 SDK will be installed by VC++ 2015 Build Tools installer instead of Windows 10 SDK. So, if rustc could do sanity checks for Windows 8.1 SDK, it will be better than not. Helpful error messages with some troubleshoot tips are nice to have. By the way, I'm glad to know these kind of issues are still in your control 👍

@kosinix
Copy link

kosinix commented Mar 31, 2017

This thread is long. But the most important question for us stuck on limbo in windows is:

Is there any temporary "recommended" workaround ATM?

Maybe post a Q/A on SO? Perhaps add some notes on rustup.rs website? Please. Just anything to get us going with msvc toolchain.

@Diggsey
Copy link
Contributor

Diggsey commented Mar 31, 2017

@kosinix Just install the VC++ build tools with default options. Most of us on this thread are using windows with the MSVC toolchain, there's no real issue beyond better explaining what the dependencies are.

@kosinix
Copy link

kosinix commented Mar 31, 2017

@Diggsey I did. Im in similar situation with @redstrike. Windows 10 + vs studio 2017. As a last ditch effort, I uninstalled vs studio 2017 completely (which I tried to avoid since I spent a few days downloading it - third world country internet), uninstalled rustup, and installed vc build tools 2013. Didn't work. Iinstalled vc build tools 2015. Still getting this:

sc

Before this, I had no problems with windows 8.1 + rustup. It seems to be a win10 + vstudio 2017 issue.

@Diggsey
Copy link
Contributor

Diggsey commented Mar 31, 2017

@kosinix This is not the issue for VS 2017 detection, please go here for that: rust-lang/rust#38584

@Diggsey
Copy link
Contributor

Diggsey commented Mar 31, 2017

Re: your issue with 2015 build tools, I haven't seen that issue before (assuming you installed with the default installation options), so I'm afraid I can't offer a workaround, but my best guess is that some remnant of the VS 2017 install is lingering around, confusing rustup. @retep998 Does that seem likely?

Does everything work if you choose to continue?

@kosinix
Copy link

kosinix commented Apr 4, 2017

@Diggsey unfortunately no. :-(

@brson
Copy link
Contributor

brson commented May 23, 2017

Thanks @levinem

@brson
Copy link
Contributor

brson commented May 24, 2017

I've started a fix to gcc-rs: https://github.com/brson/gcc-rs/tree/vs2017

@levinem
Copy link

levinem commented May 24, 2017

You're welcome @brson

brson added a commit to brson/gcc-rs that referenced this issue May 24, 2017
This teaches gcc-rs to find tools installed by MSVC 2017. It's not
obvious to what extend the new COM interfaces are expected to be
use. This patch only uses it to find the product installation
directory, then infers everything else. A lot of COM scaffolding to do
very little. The toolchains seem to have a different directory
structure in this release to better support cross-compilation.

It looks to me like all the lib/include logic is pretty much the same
as it always has been.

This is tested to fix the rustup installation logic, and to fix
rustc in basic use cases on x86_64.

cc rust-lang#143
cc rust-lang/rustup#1003
cc rust-lang/rust#38584
brson added a commit to brson/gcc-rs that referenced this issue May 24, 2017
This teaches gcc-rs to find tools installed by MSVC 2017. It's not
obvious to what extend the new COM interfaces are expected to be
use. This patch only uses it to find the product installation
directory, then infers everything else. A lot of COM scaffolding to do
very little. The toolchains seem to have a different directory
structure in this release to better support cross-compilation.

It looks to me like all the lib/include logic is pretty much the same
as it always has been.

This is tested to fix the rustup installation logic, and to fix
rustc in basic use cases on x86_64.

cc rust-lang#143
cc rust-lang/rustup#1003
cc rust-lang/rust#38584
brson added a commit to brson/gcc-rs that referenced this issue May 24, 2017
This teaches gcc-rs to find tools installed by MSVC 2017. It's not
obvious to what extend the new COM interfaces are expected to be
use. This patch only uses it to find the product installation
directory, then infers everything else. A lot of COM scaffolding to do
very little. The toolchains seem to have a different directory
structure in this release to better support cross-compilation.

It looks to me like all the lib/include logic is pretty much the same
as it always has been.

This is tested to fix the rustup installation logic, and to fix
rustc in basic use cases on x86_64.

cc rust-lang#143
cc rust-lang/rustup#1003
cc rust-lang/rust#38584
cc alexcrichton/curl-rust#161
brson added a commit to brson/gcc-rs that referenced this issue May 24, 2017
This teaches gcc-rs to find tools installed by MSVC 2017. It's not
obvious to what extent the new COM interfaces are expected to be
used. This patch only uses it to find the product installation
directory, then infers everything else. A lot of COM scaffolding to do
very little. The toolchains seem to have a different directory
structure in this release to better support cross-compilation.

It looks to me like all the lib/include logic is pretty much the same
as it always has been.

This is tested to fix the rustup installation logic, and to fix
rustc in basic use cases on x86_64.

cc rust-lang#143
cc rust-lang/rustup#1003
cc rust-lang/rust#38584
cc alexcrichton/curl-rust#161
brson added a commit to brson/gcc-rs that referenced this issue May 24, 2017
This teaches gcc-rs to find tools installed by MSVC 2017. It's not
obvious to what extent the new COM interfaces are expected to be
used. This patch only uses it to find the product installation
directory, then infers everything else. A lot of COM scaffolding to do
very little. The toolchains seem to have a different directory
structure in this release to better support cross-compilation.

It looks to me like all the lib/include logic is pretty much the same
as it always has been.

This is tested to fix the rustup installation logic, and to fix
rustc in basic use cases on x86_64.

cc rust-lang#143
cc rust-lang/rustup#1003
cc rust-lang/rust#38584
cc alexcrichton/curl-rust#161
brson added a commit to brson/rustup.rs that referenced this issue May 25, 2017
bors added a commit that referenced this issue May 26, 2017
Detect MSVC 2017. Closes #1003

Rust itself won't actually work until it is also updated. This just lets rustup install without a warning.
bors added a commit that referenced this issue May 26, 2017
Detect MSVC 2017. Closes #1003

Rust itself won't actually work until it is also updated. This just lets rustup install without a warning.
bors added a commit that referenced this issue May 26, 2017
Detect MSVC 2017. Closes #1003

Rust itself won't actually work until it is also updated. This just lets rustup install without a warning.
@bors bors closed this as completed in 99cbfe0 May 27, 2017
@Diggsey Diggsey removed this from Documentation & CLI in Issue Categorisation May 29, 2017
FaultyRAM pushed a commit to FaultyRAM/gcc-rs that referenced this issue Aug 10, 2017
This teaches gcc-rs to find tools installed by MSVC 2017. It's not
obvious to what extent the new COM interfaces are expected to be
used. This patch only uses it to find the product installation
directory, then infers everything else. A lot of COM scaffolding to do
very little. The toolchains seem to have a different directory
structure in this release to better support cross-compilation.

It looks to me like all the lib/include logic is pretty much the same
as it always has been.

This is tested to fix the rustup installation logic, and to fix
rustc in basic use cases on x86_64.

cc rust-lang#143
cc rust-lang/rustup#1003
cc rust-lang/rust#38584
cc alexcrichton/curl-rust#161
@kragil
Copy link

kragil commented Feb 12, 2021

Why is Rust still relying on this slow MS crap? It's been years...

@rbtcollins
Copy link
Contributor

@kragil I understand you are frustrated, though its not clear what has caused that, but please be kind or at least courteous in this bugtracker: we follow, and require everyone participating here to follow, the rust code of conduct: https://www.rust-lang.org/policies/code-of-conduct - in particular calling the MS toolchains "slow crap" is rude an unnecessary.

That said, your question would be best answered in the rust forums I think; rustup focuses on installing rust, not on defining what rust does or does not require.

@Menelion
Copy link

Menelion commented Sep 5, 2022

I'm trying to install Rust. I have MSVS 2022 installed, tried various versions of MSVC and Windows 10 SDK. Rustup still rejects me with this infamous window. Any suggestions in 2022 please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests