GithubHelp home page GithubHelp logo

cargo looks for wrong URL about panamax HOT 8 CLOSED

panamax-rs avatar panamax-rs commented on July 28, 2024
cargo looks for wrong URL

from panamax.

Comments (8)

k3d3 avatar k3d3 commented on July 28, 2024

The storage format changed recently, but that's still strange it's not getting the right URL.

Are you using panamax serve or nginx to serve the crates?

If you're using nginx, you'll likely need some rewrite config settings:

	# Rewrite the download URLs to match the proper crates location.
	rewrite "^/crates/([^/])/([^/]+)$"                     "/crates/1/$1/$2"         last;
	rewrite "^/crates/([^/]{2})/([^/]+)$"                  "/crates/2/$1/$2"         last;
	rewrite "^/crates/([^/])([^/]{2})/([^/]+)$"            "/crates/3/$1/$1$2/$3"    last;
	rewrite "^/crates/([^/]{2})([^/]{2})([^/]*)/([^/]+)$"  "/crates/$1/$2/$1$2$3/$4" last;

from https://github.com/panamax-rs/panamax/blob/master/nginx.sample.conf

If you already have those in your nginx config, or you're using panamax serve and it's still not working, that's indeed strange.

from panamax.

panzerballett avatar panzerballett commented on July 28, 2024

thanks a lot for your QUICK reply!

i use nginx directly - without panamax serve.

the rewrite rules helped although i had to tweak them a little in order to take the version number of the crates into account:

rewrite "^/crates/([^/])/([^/]+)-([\d\.]*).crate$"                     "/crates/1/$1/$3/$2-$3.crate"          last;
rewrite "^/crates/([^/]{2})/([^/]+)-([\d\.]*).crate$"                  "/crates/2/$1/$3/$2-$3.crate"          last;
rewrite "^/crates/([^/])([^/]{2})/([^/]+)-([\d\.]*).crate$"            "/crates/3/$3/$4/$3-$4.crate"          last;
rewrite "^/crates/([^/]{2})([^/]{2})([^/]*)/([^/]+)-([\d\.]*).crate$"  "/crates/$1/$2/$1$2$3/$5/$4-$5.crate"  last;

i did not run exhaustive tests but it did work for a few simple cases (obviously i'm no regex wizard...).

would it be beneficial to run panamax serve?

thanks again and best regards!

from panamax.

k3d3 avatar k3d3 commented on July 28, 2024

Apologies for the late reply.

Yeah, I think panamax serve is the best option for this. If that command doesn't work for you, let me know.

Also, good to know with regards to the rewrite rules! I'll quickly review those. Thanks!

from panamax.

nicoxxl avatar nicoxxl commented on July 28, 2024

Also, this PR, I have removed the need for URL rewriting.

from panamax.

JustAnotherCodemonkey avatar JustAnotherCodemonkey commented on July 28, 2024

@k3d3

If you already have those in your nginx config, or you're using panamax serve and it's still not working, that's indeed strange.

I'm using panamax serve on macos and am getting a similar issue. Following the README tutorial with panamax serve and using installing ripgrep as a dummy and get the following output from cargo:

cargo install --config "source.crates-io.replace-with=\"panamax\"" ripgrep
    Updating `panamax` index
warning: spurious network error (3 tries remaining): [6] Couldn't resolve host name (Could not resolve host: panamax.internal)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: panamax.internal)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: panamax.internal)
error: failed to download from `http://panamax.internal/crates/ri/pg/ripgrep/13.0.0/ripgrep-13.0.0.crate`

Btw, my cargo config is this:

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

Oh and also, base_url is set to "http://panamax.internal/crates".

from panamax.

JustAnotherCodemonkey avatar JustAnotherCodemonkey commented on July 28, 2024

Sorry to keep updating but now I've meddled in mirror.toml and now can't get the same error. Now I get

cargo install --config "source.crates-io.replace-with=\"panamax\"" ripgrep
    Updating `panamax` index
warning: spurious network error (3 tries remaining): unexpected http status code: 404; class=Http (34)
warning: spurious network error (2 tries remaining): unexpected http status code: 404; class=Http (34)
warning: spurious network error (1 tries remaining): unexpected http status code: 404; class=Http (34)
error: failed to update replaced source registry `crates-io`

Caused by:
  failed to fetch `http://localhost:8080/git/crates.io-index`

Caused by:
  network failure seems to have happened
  if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  unexpected http status code: 404; class=Http (34)

With the server outputting

Not a git repository: 'crates-mirror/crates.io-index'Not a git repository: 'crates-mirror/crates.io-index'Not a git repository: 'crates-mirror/crates.io-index'Not a git repository: 'crates-mirror/crates.io-index'

from panamax.

JustAnotherCodemonkey avatar JustAnotherCodemonkey commented on July 28, 2024

Ok now I got it back to the problem with panamax.internal somehow.

from panamax.

JustAnotherCodemonkey avatar JustAnotherCodemonkey commented on July 28, 2024

Ugh I feel very slightly stupid. I for some reason didn't figure out that the base_url would have to be actually what cargo would connect to. Should have read the docs more thoroughly. Sorry.

from panamax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.