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

Add the rust lib dir (containing std-<hash>.dll) to the path on windows #1093

Merged
merged 1 commit into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/rustup/env_var.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::ffi::OsString;
use std::env;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use std::process::Command;

pub const RUST_RECURSION_COUNT_MAX: u32 = 5;
Expand All @@ -20,15 +19,19 @@ pub fn append_path(name: &str, value: Vec<PathBuf>, cmd: &mut Command) {
}
}

pub fn prepend_path(name: &str, value: &Path, cmd: &mut Command) {
pub fn prepend_path(name: &str, value: Vec<PathBuf>, cmd: &mut Command) {
let old_value = env::var_os(name);
let mut parts = vec![value.to_owned()];
let mut parts: Vec<PathBuf>;
if let Some(ref v) = old_value {
parts.extend(env::split_paths(v));
parts = value;
parts.extend(env::split_paths(v).collect::<Vec<_>>());
} else {
parts = value;
}
let new_value = env::join_paths(parts).unwrap_or_else(|_| OsString::from(value));

cmd.env(name, new_value);
if let Ok(new_value) = env::join_paths(parts) {
cmd.env(name, new_value);
}
}

pub fn inc(name: &str, cmd: &mut Command) {
Expand Down
11 changes: 9 additions & 2 deletions src/rustup/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,22 @@ impl<'a> Toolchain<'a> {
mod sysenv {
pub const LOADER_PATH: &'static str = "DYLD_LIBRARY_PATH";
}
env_var::prepend_path(sysenv::LOADER_PATH, &new_path, cmd);
env_var::prepend_path(sysenv::LOADER_PATH, vec![new_path.clone()], cmd);

// Prepend CARGO_HOME/bin to the PATH variable so that we're sure to run
// cargo/rustc via the proxy bins. There is no fallback case for if the
// proxy bins don't exist. We'll just be running whatever happens to
// be on the PATH.
let mut path_entries = vec![];
if let Ok(cargo_home) = utils::cargo_home() {
env_var::prepend_path("PATH", &cargo_home.join("bin"), cmd);
path_entries.push(cargo_home.join("bin").to_path_buf());
}

if cfg!(target_os = "windows") {
path_entries.push(self.path.join("bin"));
}

env_var::prepend_path("PATH", path_entries, cmd);
}

pub fn doc_path(&self, relative: &str) -> Result<PathBuf> {
Expand Down