Closed
Description
It is not possible to compile a file whose name is equal to a directory already created in the same folder:
$ rustc rust.rs
error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "rust.0.o" "-o" "rust" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-39b92f95.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-39b92f95.rlib" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-l" "compiler-rt"
note: /usr/bin/ld: cannot open output file rust: Is a directory
collect2: error: ld returned 1 exit status
error: aborting due to previous error
Activity
durka commentedon Aug 22, 2016
Not really a rust bug.
c410-f3r commentedon Aug 22, 2016
@durka Guess it is not a bug after all
retep998 commentedon Aug 22, 2016
You cannot have both a file and a directory with the exact same name in the same directory.
dashed commentedon Aug 22, 2016
There could be a nicer error message to indicate to the user that there is a directory with the same name as the program.
0xmohit commentedon Aug 22, 2016
FWIW,
gcc
behaves similarly.estebank commentedon Aug 22, 2016
I could expand #34005 when I get back to it to clean it up to pick this case up as well.
alexcrichton commentedon Sep 13, 2016
Ah yes I think this is "not a bug" where we can't create executables with a directory of the same name, so closing.
Warn when rustc output conflicts with existing directories
varkor commentedon Jan 30, 2018
Just to note: this is a duplicate of #13098.
Auto merge of #47203 - varkor:output-filename-conflicts-with-director…
2 remaining items