prefix-dev / rattler-build

rattler-build is a universal package builder for Windows, macOS and Linux
https://prefix-dev.github.io/rattler-build
BSD 3-Clause "New" or "Revised" License
185 stars 38 forks source link

unable to parse package name containing local version specifier #944

Closed ChristopherRussell closed 1 month ago

ChristopherRussell commented 2 months ago

Hello. I shared the below on prefix.dev discord and @baszalmstra suggested I make an issue. They said:

The specified package contains a local version specifier (+218-0). In general these should not be distributed. But I think we should be able to handle them properly regardless.

My situation: I have been trying out pixi at work for the first time. We install everything from internal conda channels. I suppose some bad versions get into there sometimes. E.g. "libxgboost-0.6+218-0.tar.bz2", which caused me to get the following error via pixi add <some_package>:

ERROR resolve_conda{group=default, platform=linux-64}: rattler_repodata_gateway::gateway: error=failed to parse repodata.json
  x failed to parse repodata.json
    -> invalid filename at line 38856 column 38 

I shall request to get these removed from our conda channels now that I am aware, however I think it'd be nice to handle since this error blocks me in the meantime.

wolfv commented 2 months ago

This is actually an issue for rattler (not rattler-build) if I understand correctly :)

Although it would be interesting to test that rattler-build does not put the local version in the filename.

wolfv commented 2 months ago

PS: can you open the issue here as well? https://github.com/mamba-org/rattler

wolfv commented 2 months ago

@ChristopherRussell I investigated a bit more and I am not sure wether the local version is really the problem.

Can you double check if you have any packages with fewer than two dashes in them?

The code looks like the following:

let package = s.rsplitn(3, '-').nth(2).ok_or("invalid filename")?;

We expect a package filename to look like foo-1.2.3-0.tar.bz2 or foo-1.2.3-hash_0.tar.bz2 or foo-base-1.2.3-hash_0.conda (i.e. to have at least two dashes). The dashes split name, version and build string.

I'll also adjust the error message to mention missing dashes.

wolfv commented 2 months ago

@ChristopherRussell - I opened a PR that might improve the error message here: https://github.com/mamba-org/rattler/pull/757

If you find the offending package, can you let us know? We could think about making the parsing more lenient and adding a fallback if only a single - is found. Or no - is found ...

ChristopherRussell commented 2 months ago

Thanks for investigating and opening the other issue for me!

The error message was:

invalid filename at line 38856 column 38

and the snippet below shows the entry starting at the 38856'th line (or 'line 38855' if you call the first line 'line 0'). I don't think the error refers to the previous line though as it's only a few characters long (a few spaces plus a close bracket). We also have noarch and win-64 sections in the channel, but the repodata.json files for those are shorter than 38856 lines so can't be the cause of the error.

    },
    "libxgboost-0.6+218_omp_0.tar.bz2": {     <---- Line 38856
      "build": "0",
      "build_number": 0,
      "depends": [],
      "extra": {
        "git": {
          "branch": "HEAD",
          "commit": "2715bae",
          "sha": "2715baef64c07546314977caf858d1cce1043b66"
        },
        "package": {
          "md5": "43b62a5ba9470354c6244353bfcad65d"
        },
        "system": {
          "cwd": "/some/path/to/a/dir",
          "node": "name.company.com",
          "os": "Linux",
          "prefix": "/some/path",
          "time": "2017-04-06 14:13:26.296584",
          "user": "some_user"
        },
        "versions": {
         "conda": "4.1.12",
          "conda-build": "1.21.7",
          "conda-tox": "0.6.5",
          "python": "3.5.2"
        }
      },
      "features": "omp",
      "md5": "477ec8a7faa700d27138e1cdf8fec967",
      "name": "libxgboost",
      "sha256": "4005a7034a294aa0d063aa5c4273f09e21cd04e1997e436f5bf0aada7e5c91da",
      "size": 912390,
      "subdir": "linux-64",
      "version": "0.6+218"
    },
wolfv commented 1 month ago

I think this is fixed in rattler. Thanks again for the bug report!