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

Unable to cargo search against panamax mirror #129

Open
alexjbuck opened this issue Apr 7, 2024 · 8 comments
Open

Unable to cargo search against panamax mirror #129

alexjbuck opened this issue Apr 7, 2024 · 8 comments

Comments

@alexjbuck
Copy link

When trying to use the cargo search command, I get this error:

$ cargo search <crate>
error: crates-io is replaced with non-remote-registry source registry `panamax`;
include `--registry crates-io` to use crates.io

I have set both environment variables:

RUSTUP_DIST_SERVER=http://127.0.0.1:8080"
RUSTUP_UPDATE_ROOT=http://127.0.0.1:8080/rustup"

This is my .cargo/config.toml:

[source.panamax]
registry = "http://127.0.0.1:8080/git/crates.io-index"
[source.panamax-sparse]
registry = "sparse+http://127.0.0.1:8080/index/"

[source.crates-io]
replace-with = "panamax"

And I edited mirror.toml to have the base_url be http://127.0.0.1:8080/crates.

Despite that, cargo search <crate> doesn't seem like it will search against the local panamax instance.

I couldn't find anything in the Readme or elsewhere that indicated whether or not cargo search should work with Panamax, but it seems like it would be a useful feature to have if its not yet supported.

@k3d3
Copy link
Member

k3d3 commented Apr 7, 2024

Hey,

Unfortunately cargo search does not work with the mirror.

Implementing it, while useful, would be a pretty big endeavour that I unfortunately don't have the bandwidth to take on right now.

I'd happily accept a PR for it though.

@alexjbuck
Copy link
Author

Okay! I can't say I'll look into it soon, but good to know that it doesn't. At a minimum I might push a docs PR that states that cargo search doesn't work with this mirror.

Thanks for the super quick response!

@qtfkwk
Copy link

qtfkwk commented Sep 18, 2024

Found this issue the other day while looking for the same functionality... and have been working locally on a potential fix...

So far, I've made an as-of-yet unpublished crate with library and CLI that parses the .crate files in a panamax mirror's crates subdirectory. It takes about 18 seconds on my i9 / 64GB RAM machine to create a ~16 MB JSON cache file (wanted to use TOML for consistency but it doesn't work all that well with BTreeMap data; oh well at least it enables web and/or jq-like use). I'm using rayon to do in parallel the description extraction from the .crate files (which is a gzipped tar file).

The CLI enables loading from the cache file, performing a search, and then produces output similar to cargo search. (I say similar because right now, I'm just doing results with exact name match, name contains, and description contains, while cargo search does more advanced relevance queries. So maybe I'll figure how they do it and add it to this.)

This is what it looks like now:

panamax-search

And for comparison:

cargo-search

I'm also thinking to use this library from panamax itself... particularly to enable it to create and update the cache file during sync and hopefully more efficiently than this CLI tool, and to load it during serve and provide a warp route/handler so that cargo search would just work when configured against a panamax mirror... but I'm still early on that part.

When these are ready, I'll publish to crates.io and send a PR linked to this issue.

Also, please let me know if you have any other thoughts, concerns, etc.

@qtfkwk
Copy link

qtfkwk commented Sep 20, 2024

It takes about 18 seconds on my i9 / 64GB RAM machine to create a ~16 MB JSON cache file

Rewrote it with a better approach/design and have it down to a ~14 MB file in ~2 seconds, with update capability and no updates ~1 second.

@qtfkwk
Copy link

qtfkwk commented Sep 24, 2024

qtfkwk pushed a commit to qtfkwk/panamax that referenced this issue Sep 24, 2024
@qtfkwk
Copy link

qtfkwk commented Sep 24, 2024

Note that this still requires one to add --index http://panamax.internal/git/crates.io-index to the cargo search command and so far I've not been able to get it to work via any other change to ~/.cargo/config.toml or command line option. Please lmk if you have any ideas.

@qtfkwk
Copy link

qtfkwk commented Sep 24, 2024

Also note that the panamax-search CLI utility exists now, and runs directly against the local panamax mirror versus going through cargo and requiring a separate copy of that git repository. In all cases, except for searching a non-local panamax mirror, I think it is probably better.

qtfkwk pushed a commit to qtfkwk/panamax that referenced this issue Sep 24, 2024
@qtfkwk
Copy link

qtfkwk commented Sep 24, 2024

Configuration:

Set the correct listening panamax serve URL at:

  • mirror.toml: crates.base_url
  • crates.io-index/config.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants