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 rm cannot handle wildcard package spec in profile setting overrides #12620

Closed
cyqsimon opened this issue Sep 4, 2023 · 3 comments · Fixed by #12624
Closed

cargo rm cannot handle wildcard package spec in profile setting overrides #12620

cyqsimon opened this issue Sep 4, 2023 · 3 comments · Fixed by #12624
Assignees
Labels
C-bug Category: bug Command-remove E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@cyqsimon
Copy link
Contributor

cyqsimon commented Sep 4, 2023

Problem

When using the wildcard syntax to specify profile setting overrides for all dependencies, cargo rm will error:

error: invalid character * in pkgid: *, the first character must be a Unicode XID start character (most letters or _)

Steps

  1. Create a new cargo project
  2. Add the following section to Cargo.toml:
[profile.dev.package."*"]
opt-level = 3
  1. Run cargo add foo
  2. Run cargo rm foo, and observe the error

Version

cargo 1.72.0 (103a7ff2e 2023-08-15)
release: 1.72.0
commit-hash: 103a7ff2ee7678d34f34d778614c5eb2525ae9de
commit-date: 2023-08-15
host: x86_64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.1.2-DEV (sys:0.4.63+curl-8.1.2 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: EndeavourOS Rolling Release (rolling) [64-bit]
@cyqsimon cyqsimon added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Sep 4, 2023
@cyqsimon cyqsimon changed the title cargo rm cannot handle wildcard package spec when setting profile overrides cargo rm cannot handle wildcard package spec in profile setting overrides Sep 4, 2023
@weihanglo
Copy link
Member

The reason cargo rm does this is that it garbage-collects related fields in your Cargo.toml. For example, if you have a [profile.dev.package."foo"] it will be gc'd.

This line bails out when parsing *, which is not a valid PackageIdSpec.

&PackageIdSpec::parse(key.get())?,

To fix this, we may probably just skip *.

@weihanglo weihanglo added E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review Command-remove and removed S-triage Status: This issue is waiting on initial triage. labels Sep 5, 2023
@Rustin170506
Copy link
Member

@rustbot claim

@epage
Copy link
Contributor

epage commented Sep 5, 2023

We should check for crate::util::is_glob_pattern, that is what we use in other places when dealing with globs where package id specs are supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-remove E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants