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

Support relative paths for registries #2252

Closed
marcbowes opened this issue Dec 28, 2015 · 3 comments · Fixed by #6873
Closed

Support relative paths for registries #2252

marcbowes opened this issue Dec 28, 2015 · 3 comments · Fixed by #6873
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@marcbowes
Copy link
Contributor

marcbowes commented Dec 28, 2015

I have a use case where I need a local registry. I currently do this by editing .cargo/config and specifying the absolute path to the registry:

[registry]
index = "file:///Users/me/blah/registry/git"

Because the path is absolute, this means I can't really check in .cargo/config since the paths may differ for my peers. This has a couple of problems:

  1. Without this file present, cargo doesn't work (because it won't have the custom registry). Cargo has become a standard integration point for editors, so this means that people can't even edit the project without having errors.
  2. http://doc.crates.io/config.html - there are some options there I might want to check in that are specific to the project.

If I specify a relative path, e.g.:

[registry]
index = "registry/git"

Then I get:

$ cargo build --verbose
failed to parse manifest at `/Users/..../Cargo.toml`

Caused by:
  invalid url `registry/git`: relative URL without a base

According to https://github.com/servo/rust-url/blob/2aa249b5bbc462e5582735bdae76a27acc9d70fd/src/lib.rs#L115, this can be fixed by adding a base_url to the UrlParser that is used in cargo/src/cargo/util/to_url.rs


Instructions to fix this added by @carols10cents:

  • Check out the code from this PR
  • Rebase it on master, fix any git merge conflicts and make any updates to code that's changed a lot in the meantime
  • Add some tests around the behavior in that PR
  • Resubmit!
marcbowes added a commit to marcbowes/cargo that referenced this issue Jan 25, 2016
This commit adds a `ToUrlWithBase` trait which is used when parsing the
value of `registry.index` from a Cargo config file.

The base url is the file that contained the URL.

The net effect is that you can now use relative URLs when specifying a
registry.
@carols10cents carols10cents added this to the impl period milestone Sep 12, 2017
@carols10cents carols10cents removed this from the impl period milestone Sep 15, 2017
@ghost
Copy link

ghost commented Jan 21, 2019

I apologize if I cause annoyance, I know this is an old issue.

I think it might be good if I add one similar example about using dependencies too. Currently Rust 1.32.0 doesn't work with local Git relative paths, like this:

[dependencies]
some-lib = { git='file:../../some-lib/', tag='...' }

So it would be great if you also consider that use case.

Thank you,

@alexcrichton alexcrichton added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 22, 2019
@fluffysquirrels
Copy link
Contributor

@ghost,

I think that your Git relative path problem deserves its own issue, so just made #6859 . Hope that helps!

@fluffysquirrels
Copy link
Contributor

I'm taking a look at this issue.

bors added a commit that referenced this issue Apr 29, 2019
Support relative paths for registries

Closes #2252

I haven't finished the tests for this yet as I wasn't sure what was necessary. Is it OK to just test through `registry_configuration()` in `src/cargo/ops/registry.rs` or are integration tests required? If integration tests then I'm not sure what cargo sub-command I can run without a real remote registry to play with; any thoughts?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants