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

Cargo prints warnings with full paths #694

Closed
vrinek opened this issue Oct 12, 2014 · 10 comments · Fixed by #1164
Closed

Cargo prints warnings with full paths #694

vrinek opened this issue Oct 12, 2014 · 10 comments · Fixed by #1164
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. E-easy Experience: Easy

Comments

@vrinek
Copy link
Contributor

vrinek commented Oct 12, 2014

cargo build prints compile time warnings using full file paths. This results in very long lines making it either wrap on a moderately widened terminal window and/or hard to follow.

Sample cargo output:

$ cargo build
   Compiling hello_world v0.0.1 (file:///Users/kostaskarachalios/Code/Learning/Rust/guide/hello_world)
/Users/kostaskarachalios/Code/Learning/Rust/guide/hello_world/src/main.rs:2:9: 2:14 warning: value assigned to `x` is never read, #[warn(dead_assignment)] on by default
/Users/kostaskarachalios/Code/Learning/Rust/guide/hello_world/src/main.rs:2     let mut x = 5i;
                                                                                    ^~~~~

For comparison:

$ rustc src/main.rs
src/main.rs:2:9: 2:14 warning: value assigned to `x` is never read, #[warn(dead_assignment)] on by default
src/main.rs:2     let mut x = 5i;
                      ^~~~~

Versions:

$ cargo -V
cargo 0.0.1-pre-nightly (0881adf 2014-10-10 22:03:11 -0700)
$ rustc -v
rustc 0.13.0-nightly (adb44f53d 2014-10-12 00:07:15 +0000)
@alexcrichton
Copy link
Member

This is somewhat at odds with #209 and I'm not sure that there's really any great solution here.

If we print src/main.rs, then it's confusing because you don't know where src/main.rs comes from. On the other hand, if we print the entire path it's quite long and takes up a good deal of space.

I suppose the story is a little different with dependencies vs the local package though, and perhaps we could just use absolute paths for all dependencies and relative paths for the local package.

@vrinek
Copy link
Contributor Author

vrinek commented Oct 16, 2014

Personally, I use the paths to quickly navigate to the compile error/warning. I assume that the cases where I would fix most usually are my own code (under src/) which I would prefer to be relative.

My expectations (warning/error on my own project):

  • root of project --> src/main.rs
  • inside src/ --> main.rs
  • inside docs/ --> ../src/main.rs

My expectations (warning/error on a dependency):

  • anywhere --> /home/user/src/rust/some_lib/src/lib.rs

Another solution would be to use something like what ruby does for dependencies:

  • anywhere --> <lib_name>/src/lib.rs

I am sorry for only providing expectations and not solutions but I am quite new to Rust and cargo's code seems to me like a beast to navigate.

@alexcrichton alexcrichton added the E-easy Experience: Easy label Oct 20, 2014
@alexcrichton
Copy link
Member

@vrinek that sounds like a good system to me!

@AnthIste
Copy link
Contributor

I'm trying to help out on a Sublime Text linter and so far the biggest challenge for me is figuring out which file is which based on relative paths. From a tooling perspective, getting the full filename is definitely the easiest.

@mhart
Copy link

mhart commented Nov 4, 2014

Current cargo (492bc86) does this, which is very confusing:

$ cargo test
   Compiling rust-crypto v0.1.0 (https://github.com/DaGenix/rust-crypto#6a712849)
   Compiling intertwine v0.0.1 (https://github.com/reem/rust-intertwine#3b23760c)
   Compiling openssl v0.0.0 (https://github.com/sfackler/rust-openssl#1e706b8e)
   Compiling move-acceptor v0.0.1 (https://github.com/reem/rust-move-acceptor#4eef9c13)
   Compiling typeable v0.0.1 (https://github.com/reem/rust-typeable#55154e18)
   Compiling mime v0.0.1 (https://github.com/hyperium/mime.rs#e2a6bcf5)
   Compiling unsafe-any v0.1.0 (https://github.com/reem/rust-unsafe-any#2863af36)
   Compiling encoding v0.1.0 (https://github.com/lifthrasiir/rust-encoding#a739425a)
src/lib.rs:2:9: 2:20 warning: lint missing_doc has been renamed to missing_docs
src/lib.rs:2 #![deny(missing_doc)]
                     ^~~~~~~~~~~
src/lib.rs:2:9: 2:20 warning: lint missing_doc has been renamed to missing_docs
src/lib.rs:2 #![deny(missing_doc)]
                     ^~~~~~~~~~~
src/lib.rs:2:9: 2:20 warning: lint missing_doc has been renamed to missing_docs
src/lib.rs:2 #![deny(missing_doc)]
                     ^~~~~~~~~~~
   Compiling url v0.1.0 (https://github.com/servo/rust-url#9142b86a)
   Compiling hyper v0.0.1 (https://github.com/hyperium/hyper#d409236e)

Those warnings all come from different libs and it's completely unclear which ones...

So there's gotta be a happy medium in here somewhere

@gsemet
Copy link

gsemet commented Jan 10, 2015

Please let the user have the choice. You can have cargo build --rel-path and cargo build --full-path and have one of them by default, but you will never find one that fit everyone !

I absolutely need absolute path for integration in some IDE, but some might not need it. Command line parameter is the key.

@vrinek
Copy link
Contributor Author

vrinek commented Jan 12, 2015

I agreed with @stibbons. For now we just need the command line option and either of them as a default.

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jan 14, 2015
All paths printed will now be absolute paths unless the path is a descendant of
the current directory. This should keep error messages and warnings of a
reasonable length when working with the local project while still allowing
errors in registry/git dependencies to be tracked down.

Special care is taken in these situations to ensure that the error message from
the compiler prints a reasonable path.

Closes rust-lang#209
Closes rust-lang#694
@alexcrichton alexcrichton added the A-diagnostics Area: Error and warning messages generated by Cargo itself. label Jan 14, 2015
bors added a commit that referenced this issue Jan 14, 2015
All paths printed will now be absolute paths unless the path is a descendant of
the current directory. This should keep error messages and warnings of a
reasonable length when working with the local project while still allowing
errors in registry/git dependencies to be tracked down.

Special care is taken in these situations to ensure that the error message from
the compiler prints a reasonable path.

Closes #209
Closes #694
@emoon
Copy link

emoon commented May 1, 2018

I would also like to have the option of having a --full-paths option to allow for easier integration into editors. Currenty I'm using another build system to build Rust code and it invokes Cargo. The problem is that sometimes the paths will show up as src/something.rs which is somewhere with in the tree and the editor can't find it.

@alexcrichton
Copy link
Member

@emoon I think we could definitely do that, want to open a separate issue to track that?

@emoon
Copy link

emoon commented May 1, 2018

Awesome! Will do :) Thanks. Added here #5450

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants