rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.5k stars 2.37k forks source link

Error running cargo build, "failed to join search paths together" #1083

Closed brianloveswords closed 9 years ago

brianloveswords commented 9 years ago

I'm trying to do my first Cargo build and I'm getting an error:

$ cargo build
failed to join search paths together: path segment contains separator `:`
Does $DYLD_LIBRARY_PATH have an unterminated quote character?

$ echo $DYLD_LIBRARY_PATH

$ rustc --version
rustc 0.13.0-nightly (34d680009 2014-12-22 00:12:47 +0000)

$ cargo --version
cargo 0.0.1-pre-nightly (e11c317 2014-12-21 20:43:45 +0000)

My $DYLD_LIBRARY_PATH appears to be empty, is that causing the problem? What's supposed to be in that env var? This is a fairly fresh install of OS X, but I do have XCode installed.

alexcrichton commented 9 years ago

What does the directory you're working in look like? Does it have colons in filenames somewhere?

brianloveswords commented 9 years ago

Ahh yeah it does. I suppose that's not allowed?

alexcrichton commented 9 years ago

Maybe! The implementation could be wrong, I'm not actually sure how you include something in a PATH-like variable with a colon in it...

charlesprogrammr commented 9 years ago

I'm having a very similar issue:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\chas1>cd projects\hello_world

C:\Users\chas1\projects\hello_world>\Rust\bin\cargo.exe build
failed to join search paths together: path segment contains `"`
Does $PATH have an unterminated quote character?

C:\Users\chas1\projects\hello_world>

I don't have unterminated quote character, they all match up as far as I can tell. I thought perhaps a backslash might have been escaping an ending one, so I deleted all trailing backslashes before quote characters. Here's my path env var:

C:\Users\chas1\projects\hello_world>echo %path%
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Windows Resource Kits\Tools\;C:\oracle\product\11.2.0\client_1;C:\oracle\product\11.2.0\client_1\bin;C:\Anaconda;C:\Anaconda\Scripts;"C:\Program Files\WATCOM\BINNT";"C:\Program Files\WATCOM\BINW";"C:\Program Files\Silverfrost\FTN95 Express";"C:\Program Files\ActiveState Komodo Edit7";C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;"c:\Program Files\Microsoft SQL Server\100\Tools\Binn";"c:\Program Files\Microsoft SQL Server\100\DTS\Binn";"C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0";"C:\Program Files\Microsoft SQL Server\110\Tools\Binn";C:\Python27;C:\mingw64\bin;"C:\Program Files\QuickTime\QTSystem";"C:\Program Files\R\R-3.0.2\bin\i386";"C:\Program Files\TortoiseSVN\bin";"C:\Program Files\Git\cmd";"C:\Program Files\Windows Kits\8.1\Windows Performance Toolkit";"C:\Program Files\nodejs";"C:\Program Files\Microsoft SQL Server\120\Tools\Binn";"C:\Program Files\Microsoft\Web Platform Installer";"C:\Program Files\TortoiseGit\bin";"C:\Program Files\MongoDB 2.6 Standard\bin";C:\GitHub\mean-stack-skeleton;c:\GitHub\mean-stack-skeleton\node_modules\.bin;"C:\Program Files\Microsoft SDKs\TypeScript\1.0";"C:\Program Files\cURL\bin";C:\cURL\bin;C:\Go\bin;C:\TortoiseHg\;C:\Program Files\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\ChucK\bin;C:\Program Files\GtkSharp\2.12\bin;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program
Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files\Windows Live\Shared;C:\Program Files\TortoiseGit\bin;C:\Users\chas1\.kre\packages\KRE-CLR-x86.1.0.0-beta1\bin;C:\Users\chas1\.kre\bin;c:\Java\jdk1.8.0\bin;C:\Users\chas1\AppData\Local\.meteor;C:\Rust\bin;C:\Users\chas1\AppData\Roaming\npm;

Needless to say, this isn't a Mac, so it just may be some implementation error in the language...

sfackler commented 9 years ago

@alexcrichton It looks like you just can't escape it at all, at least when interacting with bash: http://stackoverflow.com/questions/14661373/how-to-escape-colon-in-path-on-unix

charlesprogrammr commented 9 years ago

@sfakler While that is interesting, mine is not identical to the OP's problem, merely similar, unless it is related to the colons' handling in "cargo build." Both are "failed to join search paths together", where brianloveswords's complains about colons, and mine complains of double quotes not being terminated.

charlesprogrammr commented 9 years ago

Ok, I've figured out a rather inconvenient workaround. After altering my PATH, to eliminate all the colons, and still getting the same error, then eliminating all backslashes before my semicolons (fail,) then quoting everything with a space in it (fail,) then finally eliminating the path altogether, it compiles, but then complains about a missing libgcc_s_dw2-1.dll (see link,) when I try to run the executable. I subsequently had to set the path again (sigh.) What a pain.

system error

I'm wondering if it might be related to the spaces in my path.

alexcrichton commented 9 years ago

@charlesprogrammr does your current directory have a quote character anywhere inside of it? The error here can probably be more descriptive, yes, but the error conditions on windows is that a path has a " character in it (which is different than on unix).

charlesprogrammr commented 9 years ago

No. I've never even attempted to use a quote in a directory name. It has something to do with the actual %PATH% environment variable, I think. With the variable out of the environment, it complied. I'll just use 2 command line windows, 1 with and 1 without until it gets straightened out. I haven't looked at the source code for Rust yet, I imagine it is some strange edge case, since only 2 of us seem to have reported anything about it.

alexcrichton commented 9 years ago

Could you paste the output of this program?

#![feature(core, env)]
use std::env;
fn main() {
    let var = env::var("PATH").unwrap();
    for path in env::split_paths(&var) {
        println!("{:?}", path);
    }

    let v: Vec<_> = env::split_paths(&var).collect();
    println!("{:?}", v);
    println!("{:?}", env::join_paths(v.iter()));
}
charlesprogrammr commented 9 years ago

I haven't yet got it to compile, seems std::env is unstable and not included in the install. Since I can't get it to compile with the current "stable" install, can you compile and put the executable up on github?

argontus commented 9 years ago

Seconding the quotation mark (") problem on Windows 8.1. My %PATH% contains quotation marks, because I have stuff from Program files and other folders that contain spaces. Surely it shouldn't be a problem, I mean quotation marks are common usage of %PATH%?

failed to join search paths together: path segment contains `"`
Does $PATH have an unterminated quote character?
alexcrichton commented 9 years ago

@argontus could you try running this program and gist the output?

argontus commented 9 years ago

@alexcrichton Here you go: https://gist.github.com/argontus/8b7c0f18af5c2e4208cc

alexcrichton commented 9 years ago

@argontus could I see the source of the crate you're trying to build as well?

argontus commented 9 years ago

@alexcrichton Sure, actually it is the default hello world program that's created by issuing

cargo new hello_world --bin

fn main() {
    println!("Hello, world!");
}

The command I'm trying to run is

cargo build

as documented in the starter guide. :)

alexcrichton commented 9 years ago

@argontus sorry I'm at a bit of a loss, I'll try to add some more error reporting to help figure this out

alexcrichton commented 9 years ago

If you can build Cargo manually it may be helpful to build with https://github.com/rust-lang/cargo/pull/1291 and see what the output is.

argontus commented 9 years ago

@alexcrichton I'm getting stuck at installing all necessary dependencies (pkg-config etc.) under MSYS. Is there any way to build cargo on Windows without all the unix deps that are annoying to find/compile under different OS? Sorry if I'm hopeless, I haven't used make and other unix tools in years...

alexcrichton commented 9 years ago

Oh most of the listed dependencies aren't actually necessary for windows (aka pkg-config), you could try just running ./configure and make and see what happens! I think you'll at least need to install cmake though.

argontus commented 9 years ago

@alexcrichton Right, I tweaked the configure script a bit and removed the pkg-config dependency, and I also had to change https to http in src/etc/dl-snapshot.py. Now make runs for some time, until...

cargo 0.0.1-pre-nightly (bb28e71 2015-01-22 06:06:34 +0000)
target/snapshot/bin/cargo.exe build --target x86_64-pc-windows-gnu
    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating git repository `https://github.com/carllerche/hamcrest-rust.git`
 Downloading toml v0.1.16
 Downloading libssh2-sys v0.1.5
 ...
 Downloading tar v0.1.10
 Downloading winapi v0.1.11
failed to join search paths together: path segment contains `"`
Does $PATH have an unterminated quote character?
make: *** [cargo-x86_64-pc-windows-gnu] Error 101
argontus commented 9 years ago

@alexcrichton I had time to test cargo on my work laptop, which has Windows 7 installed. cargo build works perfectly fine on the cargo version that comes with current Windows x64 installer (cargo 0.0.1-pre-nightly (9404539 2015-02-09 20:54:26 +0000)).

I'm starting to suspect the culprit here might be Windows 8.1, since my PATH is pretty similar on both machines, but that's just a wild guess. :)

argontus commented 9 years ago

@alexcrichton Just a last spam, sorry for noise :) I just tried to remove Rust completely from my home box (Windows 8.1), reinstalled from latest nightly x64 installer and now cargo build works.

cargo 0.0.1-pre-nightly (9404539 2015-02-09 20:54:26 +0000)

Now all is in order with my setup, at least. Yay!

charlesprogrammr commented 9 years ago

Good call, argontus. I didn't think to look at nightly builds for a particular platform, I assumed the install on the homepage would be updated on an ongoing basis. My mistake was to assume. I just now uninstalled and installed rust-nightly-i686-pc-windows-gnu.exe, and I no longer have problems with %path%. I even got it to compile the PathFromEnv program

C:\Users\chas1\projects>cd PathsFromEnv

C:\Users\chas1\projects\PathsFromEnv>rustc PathsFromEnv.rs
PathsFromEnv.rs:1:12: 1:16 warning: unused or unknown feature, #[warn(unused_features)] on by default
PathsFromEnv.rs:1 #![feature(core, env)]
 ^~~~

C:\Users\chas1\projects\PathsFromEnv>dir
 Volume in drive C has no label.
 Volume Serial Number is CC4F-2372

 Directory of C:\Users\chas1\projects\PathsFromEnv

02/13/2015  01:16 PM<DIR>  .
02/13/2015  01:16 PM<DIR>  ..
02/13/2015  01:16 PM 2,680,229 PathsFromEnv.exe
02/10/2015  11:51 AM   310 PathsFromEnv.rs
   2 File(s)  2,680,539 bytes
   2 Dir(s)  123,388,956,672 bytes free

C:\Users\chas1\projects\PathsFromEnv>PathsFromEnv.exe
"C:\\Program Files\\Common Files\\Microsoft Shared\\Windows Live"
"C:\\Program Files\\Windows Resource Kits\\Tools"
"C:\\oracle\\product\\11.2.0\\client_1"
"C:\\oracle\\product\\11.2.0\\client_1\\bin"
"C:\\Anaconda"
"C:\\Anaconda\\Scripts"
"C:\\Program Files\\WATCOM\\BINNT"
"C:\\Program Files\\WATCOM\\BINW"
"C:\\Program Files\\Silverfrost\\FTN95 Express"
"C:\\Program Files\\ActiveState Komodo Edit 7"
"C:\\Windows\\system32"
"C:\\Windows"
"C:\\Windows\\System32\\Wbem"
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0"
"C:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Binn"
"C:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn"
"C:\\Program Files\\Microsoft ASP.NET\\ASP.NET Web Pages\\v1.0"
"C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn"
"C:\\Python27"
"C:\\mingw64\\bin"
"C:\\Program Files\\QuickTime\\QTSystem"
"C:\\Program Files\\R\\R-3.0.2\\bin\\i386"
"C:\\Program Files\\TortoiseSVN\\bin"
"C:\\Program Files\\Git\\cmd"
"C:\\Program Files\\Windows Kits\\8.1\\Windows Performance Toolkit"
"C:\\Program Files\\nodejs"
"C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn"
"C:\\Program Files\\Microsoft\\Web Platform Installer"
"C:\\Program Files\\TortoiseGit\\bin"
"C:\\Program Files\\MongoDB 2.6 Standard\\bin"
"C:\\GitHub\\mean-stack-skeleton"
"C:\\GitHub\\mean-stack-skeleton\\node_modules\\.bin"
"C:\\Program Files\\Microsoft SDKs\\TypeScript\\1.0"
"C:\\Program Files\\cURL\\bin"
"C:\\cURL\\bin"
"C:\\Go\\bin"
"C:\\TortoiseHg"
"C:\\Program Files\\Microsoft SDKs\\TypeScript\\1.0"
"C:\\Program Files\\Windows Kits\\8.1\\Windows Performance Toolkit"
"C:\\Program Files\\ChucK\\bin"
"C:\\Program Files\\GtkSharp\\2.12\\bin"
"C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn"
"C:\\Program Files\\Microsoft SQL Server\\110\\DTS\\Binn"
"C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\ManagementStudio"
"C:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\\IDE\\PrivateAssemblies"
"C:\\Program Files\\Windows Live\\Shared"
"C:\\Program Files\\TortoiseGit\\bin"
"C:\\Users\\chas1\\.kre\\packages\\KRE-CLR-x86.1.0.0-beta1\\bin"
"C:\\Users\\chas1\\.kre\\bin"
"C:\\Java\\jdk1.8.0\\bin"
"C:\\Users\\chas1\\AppData\\Local\\.meteor"
"C:\\Users\\chas1\\AppData\\Roaming\\npm"
"."
"C:\\Rust\\bin"
["C:\\Program Files\\Common Files\\Microsoft Shared\\Windows Live", "C:\\Program Files\\Windows Resource Kits\\Tools", "C:\\oracle\\product\\11.2.0\\client_1", "C:\\oracle\\product\\11.2.0\\client_1\\bin", "C:\\Anaconda", "C:\\Anaconda\\Scripts", "C:\\Program Files\\WATCOM\\BINNT", "C:\\Program Files\\WATCOM\\BINW", "C:\\Program Files\\Silverfrost\\FTN95 Express", "C:\\Program Files\\ActiveState Komodo Edit 7", "C:\\Windows\\system32", "C:\\Windows", "C:\\Windows\\System32\\Wbem", "C:\\Windows\\System32\\WindowsPowerShell\\v1.0", "C:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Binn", "C:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn", "C:\\Program Files\\Microsoft ASP.NET\\ASP.NET Web Pages\\v1.0", "C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn", "C:\\Python27", "C:\\mingw64\\bin", "C:\\Program Files\\QuickTime\\QTSystem", "C:\\Program Files\\R\\R-3.0.2\\bin\\i386", "C:\\Program Files\\TortoiseSVN\\bin", "C:\\Program Files\\Git\\cmd", "C:\\Program Files\\Windows Kits\\8.1\\Windows Performance Toolkit", "C:\\Program Files\\nodejs", "C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn", "C:\\Program Files\\Microsoft\\Web Platform Installer", "C:\\Program Files\\TortoiseGit\\bin", "C:\\Program Files\\MongoDB 2.6 Standard\\bin", "C:\\GitHub\\mean-stack-skeleton", "C:\\GitHub\\mean-stack-skeleton\\node_modules\\.bin", "C:\\Program Files\\Microsoft SDKs\\TypeScript\\1.0", "C:\\Program Files\\cURL\\bin", "C:\\cURL\\bin", "C:\\Go\\bin", "C:\\TortoiseHg", "C:\\Program Files\\Microsoft SDKs\\TypeScript\\1.0", "C:\\Program Files\\Windows Kits\\8.1\\Windows Performance Toolkit", "C:\\Program Files\\ChucK\\bin", "C:\\Program Files\\GtkSharp\\2.12\\bin", "C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn", "C:\\Program Files\\Microsoft SQL Server\\110\\DTS\\Binn", "C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\ManagementStudio", "C:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\\IDE\\PrivateAssemblies", "C:\\Program Files\\Windows Live\\Shared", "C:\\Program Files\\TortoiseGit\\bin", "C:\\Users\\chas1\\.kre\\packages\\KRE-CLR-x86.1.0.0-beta1\\bin", "C:\\Users\\chas1\\.kre\\bin", "C:\\Java\\jdk1.8.0\\bin", "C:\\Users\\chas1\\AppData\\Local\\.meteor", "C:\\Users\\chas1\\AppData\\Roaming\\npm", ".", "C:\\Rust\\bin"]
Ok("C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Windows Resource Kits\Tools;C:\oracle\product\11.2.0\client_1;C:\oracle\product\11.2.0\client_1\bin;C:\Anaconda;C:\Anaconda\Scripts;C:\Program Files\WATCOM\BINNT;C:\Program Files\WATCOM\BINW;C:\Program Files\Silverfrost\FTN95 Express;C:\Program Files\ActiveState Komodo Edit 7;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Microsoft SQL Server\100\Tools\Binn;C:\Program Files\Microsoft SQL Server\100\DTS\Binn;C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\Python27;C:\mingw64\bin;C:\Program Files\QuickTime\QTSystem;C:\Program Files\R\R-3.0.2\bin\i386;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Git\cmd;C:\Program Files\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files\nodejs;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft\Web Platform Installer;C:\Program Files\TortoiseGit\bin;C:\Program Files\MongoDB 2.6 Standard\bin;C:\GitHub\mean-stack-skeleton;C:\GitHub\mean-stack-skeleton\node_modules\.bin;C:\Program Files\Microsoft SDKs\TypeScript\1.0;C:\Program Files\cURL\bin;C:\cURL\bin;C:\Go\bin;C:\TortoiseHg;C:\Program Files\Microsoft SDKs\TypeScript\1.0;C:\Program Files\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files\ChucK\bin;C:\Program Files\GtkSharp\2.12\bin;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\Program Files\Microsoft SQL Server\110\DTS\Binn;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\ManagementStudio;C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies;C:\Program Files\Windows Live\Shared;C:\Program Files\TortoiseGit\bin;C:\Users\chas1\.kre\packages\KRE-CLR-x86.1.0.0-beta1\bin;C:\Users\chas1\.kre\bin;C:\Java\jdk1.8.0\bin;C:\Users\chas1\AppData\Local\.meteor;C:\Users\chas1\AppData\Roaming\npm;.;C:\Rust\bin")

Thanks for the help, everyone. BTW, maybe someone should update the downloads from the Rust homepage.

alexcrichton commented 9 years ago

Gah sorry everyone! That should have been the first question I asked...

Sounds like this is solved in more recent versions of cargo though!