Skip to content

Error on "cargo run", runs fine on second call #1669

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

Closed
azerupi opened this issue Jun 1, 2015 · 8 comments
Closed

Error on "cargo run", runs fine on second call #1669

azerupi opened this issue Jun 1, 2015 · 8 comments

Comments

@azerupi
Copy link
Contributor

azerupi commented Jun 1, 2015

Hi sometimes when I run cargo run I get an error.
Sometimes I get a little info:

Compiling rust-learn v0.0.1 (file:///home/mathieu/Programming/Rust/rust-learn)
error: failed to remove /home/mathieu/Programming/Rust/rust-learn/target/debug/math.o: No such file or directory (os error 2)
error: failed to remove /home/mathieu/Programming/Rust/rust-learn/target/debug/math.metadata.o: No such file or directory (os error 2)
An unknown error occurred

But sometimes I just get: An unknown error occurred without explanation.

This happens only when the file has already been built and was modified. By calling cargo run a second time the error disappears (until next modification).

$ cargo --version
cargo 0.2.0-nightly (ac61996 2015-05-17) (built 2015-05-17)

I am running on Arch Linux.

@alexcrichton
Copy link
Member

Do you have an example project I could take a peek at as well

@azerupi
Copy link
Contributor Author

azerupi commented Jun 1, 2015

Sure, I think it happens on almost all projects I build. You can try with: https://github.com/azerupi/rust-learn

In src/Numbers/math.rs when I delete some println's, save, build and then put them back, save and build I get that error. But it's weird, I don't get it systematically. It's not such a big deal since everything works by running the command a second time, but you know, some users might be scared by error messages ;)

The exact command I am using is cargo run --bin math

I downloaded cargo through AUR (Arch User Repository). https://aur.archlinux.org/packages/cargo-bin/

And rust through the pacman: https://www.archlinux.org/packages/community/i686/rust/

I also got this error once, but I can't seem to reproduce it:

$ cargo run --bin math
   Compiling rust-learn v0.0.1 (file:///home/mathieu/Programming/Rust/rust-learn)
error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-m64" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/mathieu/Programming/Rust/rust-learn/target/debug/math" "/home/mathieu/Programming/Rust/rust-learn/target/debug/math.o" "-Wl,--whole-archive" "-lmorestack" "-Wl,--no-whole-archive" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4e7c5e5c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode-4e7c5e5c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4e7c5e5c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4e7c5e5c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-4e7c5e5c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4e7c5e5c.rlib" "-L" "/home/mathieu/Programming/Rust/rust-learn/target/debug" "-L" "/home/mathieu/Programming/Rust/rust-learn/target/debug/deps" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/mathieu/Programming/Rust/rust-learn/.rust/lib64/x86_64-unknown-linux-gnu" "-L" "/home/mathieu/Programming/Rust/rust-learn/lib64/x86_64-unknown-linux-gnu" "-Wl,--whole-archive" "-Wl,-Bstatic" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-ldl" "-lpthread" "-lrt" "-lgcc_s" "-lpthread" "-lc" "-lm" "-lcompiler-rt"
note: /usr/bin/ld: cannot find /home/mathieu/Programming/Rust/rust-learn/target/debug/math.o: No such file or directory
collect2: error: ld returned 1 exit status

error: aborting due to previous error
Could not compile `rust-learn`.

To learn more, run the command again with --verbose.

@azerupi
Copy link
Contributor Author

azerupi commented Jun 1, 2015

Runnin verbose mode:

$ cargo run --bin math --verbose
   Compiling rust-learn v0.0.1 (file:///home/mathieu/Programming/Rust/rust-learn)
     Running `rustc src/Numbers/math.rs --crate-name math --crate-type bin -g --out-dir /home/mathieu/Programming/Rust/rust-learn/target/debug --emit=dep-info,link -L dependency=/home/mathieu/Programming/Rust/rust-learn/target/debug -L dependency=/home/mathieu/Programming/Rust/rust-learn/target/debug/deps`
error: failed to remove /home/mathieu/Programming/Rust/rust-learn/target/debug/math.o: No such file or directory (os error 2)
error: failed to remove /home/mathieu/Programming/Rust/rust-learn/target/debug/math.metadata.o: No such file or directory (os error 2)
could not rename dep info: "/home/mathieu/Programming/Rust/rust-learn/target/debug/math.d"

Caused by:
  No such file or directory (os error 2)

@alexcrichton
Copy link
Member

What version of Cargo and Rust are you using? Unfortunately I can't reproduce this :(

@alexcrichton
Copy link
Member

Also, do you perhaps have Cargo running concurrently in the background? (e.g. does your editor run cargo whenever you save?)

@azerupi
Copy link
Contributor Author

azerupi commented Jun 1, 2015

Also, do you perhaps have Cargo running concurrently in the background? (e.g. does your editor run cargo whenever you save?)

That could be it, I am using Atom with some plug-ins for rust. If it is a plug-in that causes this it's probably Atom linter-rust

I will check tomorrow if I still get the error when I disable it.

@azerupi
Copy link
Contributor Author

azerupi commented Jun 7, 2015

My apologies for my late response.

So I uninstalled the plugin I mentioned before, and don't seem to have any errors anymore. It's definitely the cause of all my problems.

I even noticed that it spawned a new rustc process every time I saved.. At some point I had 13 rustc instances running in parallel saturating my processor

@alexcrichton
Copy link
Member

Ok! In that case I'm going to close this as a dupe of #354.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants