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

buildRustCrate does not support features with spaces #90605

Open
danieldk opened this issue Jun 16, 2020 · 8 comments
Open

buildRustCrate does not support features with spaces #90605

danieldk opened this issue Jun 16, 2020 · 8 comments

Comments

@danieldk
Copy link
Contributor

Describe the bug
If a crate provides a feature with a space and it is enabled, the feature is incorrectly passed to the rustc command. Moreover CARGO_FEATURE_* is not set correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Add a feature with a space to:
    features = [ "some-feature" "crate/another_feature" ];
  2. nix-build -A buildRustCrateTests

Expected behavior
A successful build with the right features enabled.

Additional context
Background: #90193

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: buildRustCrateTests
@stale
Copy link

stale bot commented Dec 13, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 13, 2020
@danieldk
Copy link
Contributor Author

I still care about this.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 13, 2020
@stale
Copy link

stale bot commented Jun 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 16, 2021
@danieldk
Copy link
Contributor Author

Still relevant.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 17, 2021
@Fuuzetsu
Copy link
Member

Fuuzetsu commented Apr 8, 2022

As of today/yesterday (Rust 1.60), this is a bigger problem because many features now look like dep:foo/bar and the colon breaks this code:

Some issue as with a space really, need some sanitisation of feature names before they are exported as env vars.

@Fuuzetsu
Copy link
Member

Fuuzetsu commented Apr 8, 2022

If a crate provides a feature with a space and it is enabled, the feature is incorrectly passed to the rustc command. Moreover CARGO_FEATURE_* is not set correctly.

In cargo code there's an envify function that it uses to set CARGO_FEATURE_*. All this function does is replace - with _ which is something we do already in nixpkgs.

Is a feature with a space in it a valid name to start with, according to cargo?

@pacak
Copy link
Contributor

pacak commented May 4, 2022

Is a feature with a space in it a valid name to start with, according to cargo?

No.

Feature names may include characters from the Unicode XID standard (which includes most letters), and additionally allows starting with _ or digits 0 through 9, and after the first character may also contain -, +, or ..

In practice it's even more restricted:

crates.io imposes additional constraints on feature name syntax that they must only be ASCII alphanumeric characters or _, -, or +.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 2, 2022
@patka-123
Copy link
Contributor

Hello @danieldk 👋

If I read the comment thread here correctly then features with spaces aren't valid. Does this mean that this issue is "resolved"? If so, would you be able to close this issue?

(I'm going through issues marked as stale to see what can be resolved. If this is still an issue then don't mind me).

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants