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

Refine MatchSpec validation to avoid incompatibilities with libmamba's parser #421

Merged
merged 5 commits into from
Jan 10, 2024

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Jan 9, 2024

Description

Closes #418

We were a bit too strict with some auto-generated MatchSpec. The issue above includes an environment where a user has installed a package via URL or path. In this case, conda generates a MatchSpec object that gets rendered as package-name[url="package-url"].

libmamba only supports some key values in the brackets, so we were rejecting url with a InvalidSpecError. However, url here is superfluous so we can simply drop it from the passed string.

This uncovered a new matchspec that makes libmamba segfault: <unknown>/noarch::test-package. We will also anticipate that and drop it before the string is generated because, again, it doesn't add any useful info for the solver and it's only an artifact of not knowing from which channel test-package was installed (because it came from a URL).

Note that if the URL happens to be a channel URL (e.g. conda.anaconda.org/conda-forge/noarch/package-version-build.tar.bz2), conda DOES recognize it as a valid channel and that doesn't crash. It only reproduces if the tarball is in a non-channel-like location.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@jaimergp
Copy link
Contributor Author

Failing as expected. Submitting fix now.

@jaimergp jaimergp marked this pull request as ready for review January 10, 2024 09:18
@jezdez jezdez merged commit 974ffe1 into main Jan 10, 2024
71 checks passed
@jezdez jezdez deleted the drop-unknown-channel branch January 10, 2024 16:32
@therc
Copy link

therc commented Jan 24, 2024

Would this also fix the error

InvalidMatchSpec: Invalid spec 'conda-forge/linux-64::_libgcc_mutex==0.1=conda_forge[md5=d7c89558ba9fa0495403155b64376d81]': Libmamba only supports a subset of the MatchSpec interface for now. You can only use ('name', 'version', 'build', 'channel', 'subdir'), but you tried to use ('md5',).

assuming that "md5" would/could be dropped, too?

This was while trying to install another unrelated package. _libgcc_mutex shows as

_libgcc_mutex 0.1 conda_forge conda-forge

and was originally installed through a lockfile (which is where I suspect md5 comes from).

@jaimergp
Copy link
Contributor Author

Hm, maybe not (yet). We are only dropping the url field. Can you open a new issue so we can take a look? It's weird that the md5 hash ends up in the matchspec.

@nhsavage
Copy link

new issue opened at #427

@yzhang-gh
Copy link

May I ask whether this fix is included in the latest version? I have updated conda to v24.9.2 as suggested in https://conda.github.io/conda-libmamba-solver/user-guide/#how-to-install but still got this error

InvalidMatchSpec: Invalid spec 'pytorch3d[url=file:///home/xxx/pytorch3d-0.7.8-py310_cu121_pyt211.tar.bz2]':
Libmamba only supports a subset of the MatchSpec interface for now.
You can only use ('name', 'version', 'build', 'channel', 'subdir'), but you tried to use ('url',).

@jaimergp
Copy link
Contributor Author

What's your conda-libmamba-solver version? Maybe we don't support url in the field, but you can use it directly.

@yzhang-gh
Copy link

Thanks for the reply. I tried conda list -n base conda-libmamba-solver and it shows 23.12.0.

Could you elaborate a little bit about how to use it directly? I installed the pytorch3d package conda install --offline and after that I can no longer use conda install to install other packages.

@jaimergp
Copy link
Contributor Author

Try to upgrade to conda-libmamba-solver 24.9 first, which should contain this fix. If that doesn't work, report back.

@yzhang-gh
Copy link

That's it! Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
6 participants