Skip to content

rustup run doesn't setup the dylib path on windows #4246

Closed as duplicate of#3825
@Nadrieril

Description

@Nadrieril

Verification

Problem

Hi! I am developping a rustc driver. I make sure to always call it as rustup run my-driver, which works on Mac and Linux: both the toolchain binaries and the rustc_driver.so are accessible so my program runs well. On Windows however, calling the driver fails with "rustc_driver.dll not found".

And indeed, as far as I can tell rustup run only attempts to set up loader paths on macos and linux:

fn set_ldpath(&self, cmd: &mut Command) {

I've seen related issues (#765, #932, #1152), but they're not exactly the same problem.

Steps

  1. Install the required rustup components: rustup component add --toolchain nightly rust-src rustc-dev llvm-tools-preview;
  2. Make a minimal binary crate that dynamically links to rustc-internal crates:
#![feature(rustc_private)]
extern crate rustc_driver;
fn main() {
    println!("Hello, World!");
}
  1. cargo +nightly build
  2. Run the resulting binary on Windows with rustup run nightly path\to\test-crate.exe

Possible Solution(s)

I can't test myself because I don't own a Windows machine, but a user reports that adding the lib path (e.g. C:\Users\Administrator\.rustup\toolchains\nightly-2024-10-23-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib), to PATH (instead of LD_LIBRARY_PATH) works. This seems confirmed by a quick google search.

Notes

The reproducing details (OS version etc) are not precise because I'm reporting on behalf of a user. If you can't reproduce on your Windows machine I'll ask for more details.

Rustup version

rustup 1.27.1

Installed toolchains

nightly

OS version

Windows ???

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions