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 install doesn't follow workspace target #5662

Closed
xzn opened this issue Jun 28, 2018 · 4 comments · Fixed by #5685
Closed

cargo install doesn't follow workspace target #5662

xzn opened this issue Jun 28, 2018 · 4 comments · Fixed by #5685
Labels

Comments

@xzn
Copy link

xzn commented Jun 28, 2018

I'm following this book here: https://doc.rust-lang.org/book/second-edition/ch14-03-cargo-workspaces.html

and cargo build works as described. However cargo install doesn't work in the workspace level, and at crate level it tries to recompile the binary to a target folder within the crate folder instead of using the workspace level target folder.

cargo build from a workspace level also sometimes compiles things differently from cargo install from the crate. I was trying to compile pijul on Windows earlier and while workspace level cargo build completes successfully, cargo install pijul (as well as cargo install from pijul crate) results in a bunch missing trait implementation errors.

In comparison cargo run doesn't have this problem as it uses the executables from workspace level target folder. (Although it'd be nice if cargo run can be used from workspace root directly instead of at crate folder)

@alexcrichton
Copy link
Member

Hm can you describe a bit more precisely what you're executing with cargo install? The meaning of cargo install and cargo install pijul are very different which may be why you're seeing issues.

@xzn
Copy link
Author

xzn commented Jun 28, 2018

Sorry could've been more clear.

Using wasm-bindgen as an example,

Executing cargo build at workspace root works as expected and binaries from crates/cli directory are compiled to workspace root target folder. Now let's say I want to install the binaries with cargo install, at workspace root level this doesn't work so I cd to crates/cli and run cargo install from there. The problem is that instead of using the the workspace root target folder, it creates and uses a target folder from crates/cli instead.

The expectation is that cargo install works like cargo build and cargo run etc and uses the target folder at workspace root level.

cargo install pijul is prolly a separate issue: basically running cargo build at workspace root of pijul source tree succeeds with binary being placed in workspace root target folder. Running cargo install pijul directly fails with some compilation error.

@alexcrichton
Copy link
Member

Ok that definitely sounds like a bug! Given a crate in an existing workspace I'd also expect the workspace's general build settings and target directory to get used.

@ehuss
Copy link
Contributor

ehuss commented Jul 2, 2018

This is caused by the change in #5350. @matklad, would it make sense to revert that? It's not clear to me why it changed.

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jul 5, 2018
bors added a commit that referenced this issue Jul 5, 2018
…tklad

Fix `cargo install` using a workspace target dir

Closes #5662
@bors bors closed this as completed in #5685 Jul 5, 2018
alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants