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

Support Cargo project with workspace #51

Closed
nebgnahz opened this Issue Dec 26, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@nebgnahz
Copy link

nebgnahz commented Dec 26, 2017

See sample project: https://github.com/nebgnahz/cargo.el-workspace

For a project with workspace, Cargo returns issue relative to the workspace root
directory. cargo.el instead find the directory with Cargo.toml, which can be
different. When these two project root directory differ, Emacs compilation mode
fails to find the correct file path. To a user, Emacs is unable to jump to the
error location and a window prompt is open.

In the linked sample project, the file in add-one/src/lib.rs has a typo x1. When one
does a cargo build, we see the following compilation log:

-*- mode: cargo-process; default-directory: "~/repos/cargo.el-workspace/add-one/" -*-
Cargo-Process started at Mon Dec 25 15:50:13

cargo build
   Compiling add-one v0.1.0 (file:///Users/benzh/repos/cargo.el-workspace/add-one)
error[E0425]: cannot find value `x1` in this scope
 --> add-one/src/lib.rs:2:5
  |
2 |     x1 + 1
  |     ^^ did you mean `x`?

error: aborting due to previous error

error: Could not compile `add-one`.

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

Cargo-Process exited abnormally with code 101 at Mon Dec 25 15:50:15

And Emacs wants to open a non-existant file
~/repos/cargo.el-workspace/add-one/add-one/src/lib.rs. cargo.el finds file
relative to ~/repos/cargo.el-workspace/add-one/ while Cargo
~/repos/cargo.el-workspace/.

Note: this wasn't an issue for old Cargo/cargo.el. I did a package update today and start experiencing this issue.

Edit:

$  cargo --version
cargo 0.25.0-nightly (e08f31018 2017-12-24)
// emacs package-list-packages
     Status: Installed in ‘cargo-20171218.855/’ (unsigned). Delete
    Version: 20171218.855
    Summary: Emacs Minor Mode for Cargo, Rust's Package Manager.
   Requires: emacs-24.3, rust-mode-0.2.0
   Keywords: tools 
Other versions: 20171218.855 (melpa).
@kwrooijen

This comment has been minimized.

Copy link
Owner

kwrooijen commented Dec 29, 2017

Hi,

I don't seem to be having this issue. When I select the error link on the compilation screen it takes me to the proper file / location.
I ran cargo-process-build in src/lib.rs and src/main.rs.
Cargo version: 0.23.0

@nebgnahz

This comment has been minimized.

Copy link
Author

nebgnahz commented Dec 29, 2017

I updated the comment. This issue occurs for nightly Rust toolchain (cargo 0.25.0-nightly (e08f31018 2017-12-24)). Jump to file works for stable Rust toolchain (i.e. cargo 0.23.0 (61fa02415 2017-11-22)).

@Dushistov

This comment has been minimized.

Copy link
Contributor

Dushistov commented Jan 25, 2018

Yes, it is new rustc problem. If you compile inside crate "CrateA" that part of workspace, with new rustc you got warnings/errors in form of CrateA/foo.rs:43:17, instead of
foo.rs:43:17, and so emacs can not find source code if you click on CrateA/foo.rs:43:17.

@kwrooijen

This comment has been minimized.

Copy link
Owner

kwrooijen commented May 21, 2018

This should be fixed with #56

@kwrooijen kwrooijen closed this May 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.