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 didn't install Visual Studio #3823

Open
KotlinIsland opened this issue May 12, 2024 · 7 comments
Open

rustup didn't install Visual Studio #3823

KotlinIsland opened this issue May 12, 2024 · 7 comments
Labels

Comments

@KotlinIsland
Copy link

KotlinIsland commented May 12, 2024

If rustup-init detects that Visual Studio is installed but with the incorrect modules, it should say so.

If you don’t have Visual Studio already installed then rustup-init will offer to automatically install the prerequisites.
- https://rust-lang.github.io/rustup/installation/windows-msvc.html

But when I ran rustup it didn't offer to install Visual Studio:

> rustup

Rust Visual C++ prerequisites

Rust requires the Microsoft C++ build tools for Visual Studio 2013 or
later, but they don't seem to be installed.

You can acquire the build tools by installing Microsoft Visual Studio.

  https://visualstudio.microsoft.com/downloads/

Check the box for "Desktop development with C++" which will ensure that the
needed components are installed. If your locale language is not English,
then additionally check the box for English under Language packs.

For more details see:

  https://rust-lang.github.io/rustup/installation/windows-msvc.html

Install the C++ build tools before proceeding.

If you will be targeting the GNU ABI or otherwise know what you are
doing then it is fine to continue installation without the build
tools, but otherwise, install the C++ build tools before proceeding.

Continue? (y/N)

And I see this with the default project:

> cargo build
   Compiling test v0.1.0 (C:\Users\AMONGUS\projects\test)
error: linker `link.exe` not found                                                                                                                                                                                              
  |
  = note: program not found

note: the msvc targets depend on the msvc linker but `link.exe` was not found                                                                                                                                                   

note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.

note: VS Code is a different product, and is not sufficient.

error: could not compile `test` (bin "test") due to 1 previous error       

is it 2013 or 2017?

Why is this most basic step of "install rust on Windows" seemingly so completely broken and/or poorly documented?

@rami3l
Copy link
Member

rami3l commented May 13, 2024

@KotlinIsland Thanks for filing this issue!

Regarding your second point, the change has already been made in #3799 to match rustc's output.

cc @ChrisDenton for the first point, introduced in #3060... I don't even know rustup-init offers to install MSVC. Maybe that's not true? (But I have quit Windows in 2020, so my impression might not be entirely true either.)

@rami3l rami3l added the docs label May 13, 2024
@ChrisDenton
Copy link
Member

ChrisDenton commented May 13, 2024

Currently the offer to auto install only works if Visual Studio is not already installed. If it is installed but missing required components then they will not currently be installed for you. This could definitely be improved. In the meantime the rustup doc page does walkthrough manual installation.

It also doesn't currently work on aarch64. That's just waiting on someone implementing and testing it.

@KotlinIsland
Copy link
Author

KotlinIsland commented May 13, 2024

At this time, I don't believe I have Visual Studio installed. Maybe I did in the past at some point. Is this some kind of heuristic check to determine if VS is installed or not?

If VS is determined to be installed with incorrect modules, perhaps rustup-init could indicate as much?

@ChrisDenton
Copy link
Member

At this time, I don't believe I have Visual Studio installed. Maybe I did in the past at some point. Is this some kind of heuristic check to determine if VS is installed or not?

Rustup uses the cc crate for finding if visual studio is installed. This is the same crate that's used by rust itself for finding VS tools. You can see the logic here:

let installing_msvc = host_triple.contains("msvc");
let have_msvc = windows_registry::find_tool(&host_triple, "cl.exe").is_some();
if installing_msvc && !have_msvc {
// Visual Studio build tools are required.
// If the user does not have Visual Studio installed and their host
// machine is i686 or x86_64 then it's OK to try an auto install.
// Otherwise a manual install will be required.
let has_any_vs = windows_registry::find_vs_version().is_ok();
let is_x86 = host_triple.contains("i686") || host_triple.contains("x86_64");
if is_x86 && !has_any_vs {
Some(VsInstallPlan::Automatic)
} else {
Some(VsInstallPlan::Manual)
}

If VS is determined to be installed with incorrect modules, perhaps rustup-init could indicate as much?

Sure, the message here would need to be changed to a more specific message rather than the general manual install message.

md(&mut term, MSVC_MANUAL_INSTALL_MESSAGE);

@ChrisDenton
Copy link
Member

Incidentally, if you do have visual studio installed then there should be a "Visual Studio Installer" in your start menu,

@KotlinIsland
Copy link
Author

I don't:
image

@KotlinIsland
Copy link
Author

I assume some registry key exists on my machine from a previous install.

@rami3l rami3l added the O-windows Windows related label Jun 10, 2024
@rami3l rami3l changed the title (🐞) rustup didn't install Visual Studio rustup didn't install Visual Studio Jul 11, 2024
@rami3l rami3l added the bug label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants