-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Workspace "profile ignored" warning discounts the possibility of publishing binary crates which use profile settings #8264
Comments
The team discussed this a bit. We feel like it would probably be best if I have definitely felt uneasy with that warning, since it cannot be silenced. However, I'm also a little uncomfortable with adding config and machinery for silencing it (just to avoid complexity). |
I get the same warning, but I'm not publishing anything. Copying of the profile would not be useful to me. I combine a few standalone projects into a large workspace using git submodules. In my setup that is easier to work with than Cargo git dependencies and The problem is that one of the subprojects pulled into the workspace is usable independently, and has its own profile. That one subproject supports WASM, so it has a profile with So to me Cargo does the right thing. I'm aware the other profile is ignored, and that's exactly what I want. I just don't need to be reminded about this on every build. |
An alternate solution we discussed would be to have some kind of nested workspace support for the git submodule use case. Cargo and Rust have the same problem, since they use git submodules. But it sounds like @kornelski specifically wants to disable the profile. Hmm.. |
To me it'd make sense if Cargo had a similar allow/deny mechanism that rustc has. My problem is also related to lack of per-target profiles: #4897. I wouldn't need the other profile to be ignored in the workspace context if I could limit that profile to WASM targets. |
Hi, I'm the poster from users.rust-lang.org. Yes, that would resolve my use case. |
I just ran into the issue @kornelski described. I have a workspace, and one of the crates is a WASM application which should be compiled with For
And when I place it in the crates
So there's no way of setting |
I ran into this as well. Same as @DzenanJupic with |
I also ran into the same issue as @DzenanJupic. I was able to sidestep the issue by removing the cargo workspace from my project and instead use workspace emulation as provided by cargo-make. Before # Cargo.toml
[workspace]
members = ["crate1", "crate2"] After # Makefile.toml
[env]
# this tells cargo-make that this directory acts as a workspace root
CARGO_MAKE_WORKSPACE_EMULATION = true
# a list of crate members. since we do not have a Cargo.toml, we will need to specify this in here.
CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = [
"crate1",
"crate2",
] After setting up Makefiles in all my other crates I can now build my project like so: Debug Build Release Build With cargo-make's workspace emulation, I no longer get the "profile ignored" warning and my WASM is optimized in release builds. 🎉 |
I have the same issue with wanting to specify I noticed the cargo docs mention this limitation:
Is there a fundamental reason cargo can't support this? Or is it more a matter of requiring some additional work to implement? |
Use caseIn my use case I have what I believe is called a "virtual" workspace. Virtual because it does not hold any dependencies. I have 4 project members. What is surprising, is that I get the warning when I call to compile one of the projects. For instance, cargo build \
--release \
--target x86_64-unknown-linux-musl \
--bin oauth \
--target-dir target Why give me a warning that the Impact ability to create a "dependency-only" layer when working in docker?This all said, I do wonder if it somehow prevents my ability to create a "dependency-only" layer in my builds?... perhaps depending on whether I specify a specific member-project? |
Any updates on this issue? It pollutes cargo build's output so much that it makes it hardly readable. |
What we do for the resolver field is we apply the workspace field to the individual packages when publishing so that the workspace's configuration is available for i would expect the same behavior for profile though it sounds like people are relying on this and it would be a breaking change. Maybe we could make this change on the next Edition. |
What about using the env var |
The replay command wasn't working on MacOS because the HostIO symbols were striped from cargo-stylus. To fix this issue, we add a profile release to the workspace and cargo-stylus binary crate. This fixes introduces the following warning: warning: profiles for the non root package will be ignored However, there is workaround to this warning. More information here: * rust-lang/cargo#8264 * rust-lang/cargo#11599
The replay command wasn't working on MacOS because the HostIO symbols were striped from cargo-stylus. To fix this issue, we have to disable stripping in the release profile. This fixes introduces the following warning: warning: profiles for the non root package will be ignored We have to edit the profile in the non-root package because the root package is ignored during cargo install. Otherwise, the solution won't work after the package is published to crates.io. More information about this issue is available here: * rust-lang/cargo#8264 * rust-lang/cargo#11599
* Fix replay command in MacOS The replay command wasn't working on MacOS because the HostIO symbols were striped from cargo-stylus. To fix this issue, we have to disable stripping in the release profile. This fixes introduces the following warning: warning: profiles for the non root package will be ignored We have to edit the profile in the non-root package because the root package is ignored during cargo install. Otherwise, the solution won't work after the package is published to crates.io. More information about this issue is available here: * rust-lang/cargo#8264 * rust-lang/cargo#11599 * Fix missing symbols in MacOS Add #[used] static variables pointing to the exported functions so the linked doesn't remove them from the final binary. * Revert "Fix replay command in MacOS" This reverts commit b489394.
Problem
When a
profile
section is provided in theCargo.toml
for a crate in a workspace that isn't the workspace root, the following warning is generated:However, if
subcrate
is a binary crate published to crates.io, then theprofile
section will be used when someonecargo install
s that crate. Moving the profile section to the workspace root would remove the settings whencargo install
ing the crate downloaded from crates.io.Steps
or copy whole Cargo.toml:
Or copy whole
Cargo.toml
:Possible Solution(s)
Add a way to ignore this warning, and output a suggestion for that when outputting the error? Could be something like
And when the error occurs, something like:
Another option could be to provide an option to copy configuration from workspace root when publishing the crate?
Notes
Output of
cargo version
:cargo 1.45.0-nightly (258c89644 2020-04-30)
I found this bug from this post on the users.rust-lang.org forum. The user in question decided to simply not have a workspace to avoid this error, but I don't think that's a good solution in general.
The text was updated successfully, but these errors were encountered: