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

Specifying the manifest path ignores .cargo/config.toml #10302

Closed
allsey87 opened this issue Jan 17, 2022 · 3 comments
Closed

Specifying the manifest path ignores .cargo/config.toml #10302

allsey87 opened this issue Jan 17, 2022 · 3 comments
Labels
C-bug Category: bug

Comments

@allsey87
Copy link

Problem

When specifying --manifest-path=dir/Cargo.toml the .cargo/config.toml files appear to be ignored. It doesn't seem to matter whether .cargo/config.toml is (e.g., in my crates, workspace, or the directory from which I am running Cargo). It is always ignored.

Steps

  1. Place some configuration in a .cargo/config.toml file. For example, I have:
[build]
target = "wasm32-unknown-unknown"

So that Cargo compiles to WebAssembly by default.
2. Run cargo build --manifest-path=path/to/Cargo.toml
3. Observe that instead of WebAssembly, Cargo is producing shared libraries (i.e., .so on Linux)

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.57.0 (b2e52d7ca 2021-10-21)
release: 1.57.0
commit-hash: b2e52d7cab0a286ee9fcc0c17510b1e72fcb53eb
commit-date: 2021-10-21
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.79.1-DEV (sys:0.4.49+curl-7.79.1 vendored ssl:OpenSSL/1.1.1l)
os: Arch Linux Rolling Release [64-bit]
@allsey87 allsey87 added the C-bug Category: bug label Jan 17, 2022
@ehuss
Copy link
Contributor

ehuss commented Jan 17, 2022

Thanks for the report! Config searching is always done from the current working directory.

This is a bit of a known issue, so I'm going to close as a duplicate of #2930, #9769, and #10098.

@ehuss ehuss closed this as completed Jan 17, 2022
@allsey87
Copy link
Author

@ehuss thanks for the quick response! I would add though that I tried adding the .cargo directory with the config.toml inside it to the working directory to no avail.

@ehuss
Copy link
Contributor

ehuss commented Jan 17, 2022

It should, unless something else is overriding it. Can you show a complete example? For example:

~/Temp> mkdir foo
~/Temp> cd foo
~/Temp/foo> mkdir .cargo
~/Temp/foo> cat > .cargo/config.toml << EOF
> [build]
target = "wasm32-unknown-unknown"
> EOF
~/Temp/foo> cargo new myproj
     Created binary (application) `myproj` package
~/Temp/foo> cargo build --manifest-path myproj/Cargo.toml
   Compiling myproj v0.1.0 (/Users/eric/Temp/foo/myproj)
    Finished dev [unoptimized + debuginfo] target(s) in 1.42s
~/Temp/foo> ls -al myproj/target/wasm32-unknown-unknown/debug/myproj.wasm
-rwxr-xr-x  1 eric  staff  1664827 Jan 17 08:40 myproj/target/wasm32-unknown-unknown/debug/myproj.wasm

uncomfyhalomacro added a commit to openSUSE-Rust/obs-service-cargo that referenced this issue Nov 17, 2024
…directory when invoking commands

This is to address this weird issue in
rust-lang/cargo#10302.

Related issues about `cargo` improvements are tracked here in
rust-lang/cargo#12738.

Currently, to do this manually, it must be set to the parent path
of Cargo.toml.

Signed-off-by: Soc Virnyl Estela <contact@uncomfyhalomacro.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants