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

Update fails when a package is installed from a custom registry #128

Closed
SolidTux opened this issue Mar 10, 2020 · 15 comments
Closed

Update fails when a package is installed from a custom registry #128

SolidTux opened this issue Mar 10, 2020 · 15 comments

Comments

@SolidTux
Copy link
Contributor

I have a binary which is installed from a custom registry. Now cargo install-update -l or cargo install-update -a fails with

    Updating registry 'https://github.com/rust-lang/crates.io-index'

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "package ... not found"', src/libcore/result.rs:1188:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Is there a way to search all configured registries or maybe even just skip the failed packages?

@nabijaczleweli
Copy link
Owner

nabijaczleweli commented Mar 10, 2020

Can you test current master branch with the referenced commit?

It has an experimental implementation of generic registry handling, so it should work for your usecase – your package should update from the right registry automatically and you should be able to install it from there via (registry_url):package_name.

@SolidTux
Copy link
Contributor Author

It seems to recognize the correct registry, but it tries to open the wrong registry directory:

Failed to open registry repository at /home/daniel/.cargo/registry/index/dl.cloudsmith.io-1c9cb99b5e769975.

The correct directory would be /home/daniel/.cargo/registry/index/dl.cloudsmith.io-c9a963c300d41cda.

nabijaczleweli added a commit that referenced this issue Mar 10, 2020
@nabijaczleweli
Copy link
Owner

The Cargo code for this is Very Good and Reproducible:tm:, but I'm pretty sure referenced commit above should do it?

@SolidTux
Copy link
Contributor Author

Seems to work! Thank you for the very fast response and fix!

nabijaczleweli added a commit that referenced this issue Mar 10, 2020
nabijaczleweli added a commit that referenced this issue Mar 10, 2020
@nabijaczleweli
Copy link
Owner

Released in v3.0.0!

@SolidTux
Copy link
Contributor Author

SolidTux commented Mar 11, 2020

Now it doesn't work anymore and I get

Couldn't get registry for gitmanager: Non-crates.io registry specified and $URL couldn't be found in the config file at /home/daniel/.cargo/config. Due to a Cargo limitation we will not be able to install from there until it's given a [source.NAME] in that file!

Even though I have an entry with this exact URL in ~/.cargo/config Bisecting yields

1b27f6e43940f49551a730e427b1762456e20e8c is the first bad commit
commit 1b27f6e43940f49551a730e427b1762456e20e8c
Author: nabijaczleweli <[email protected]>
Date:   Wed Mar 11 02:11:48 2020 +0100

    Work around Cargo not accepting registry URLs in --registry

 src/main.rs                | 38 ++++++++------------------------------
 src/ops/mod.rs             | 26 ++++++++++++++++++++------
 tests/ops/get_index_url.rs | 30 +++++++++++++++++++++++++++---
 3 files changed, 55 insertions(+), 39 deletions(-)

@SolidTux SolidTux reopened this Mar 11, 2020
@nabijaczleweli
Copy link
Owner

That's interesting... What's your cargo version? I get "cargo 1.41.0 (626f0f40e 2019-12-03)", which gave me errors when I fed it an URL to --registry, which I "worked around" in that commit by replacing "invalid character ':' in registry" from Cargo with a nicer error if I couldn't find a source name that Cargo expects.

@SolidTux
Copy link
Contributor Author

Interesting ... I've also got cargo 1.41.0 (626f0f40e 2019-12-03). When installing with cargo install --repository ... only a name works for me.

@nabijaczleweli
Copy link
Owner

By way of test, can try with this patch, which'll revert to the previous behaviour of passing the URL to the registry (and say if it does so)? It shouldn't work, but ..?

diff --git a/src/ops/mod.rs b/src/ops/mod.rs
index cd4fa30f7..fbb2462ff 100644
--- a/src/ops/mod.rs
+++ b/src/ops/mod.rs
@@ -900,11 +900,8 @@ pub fn get_index_url(crates_file: &Path, registry: &str) -> Result<(String, Cow<
     }
 
     if Url::parse(&cur_source).is_ok() {
-        Err(format!("Non-crates.io registry specified and {} couldn't be found in the config file at {}. \
-                     Due to a Cargo limitation we will not be able to install from there \
-                     until it's given a [source.NAME] in that file!",
-                    cur_source,
-                    config_file.display()))?
+        eprintln!("WARN: Passing {} as --registry", cur_source);
+        return Ok((cur_source.to_string(), cur_source.to_string().into()));
     }
 
     while let Some(repl) = replacements.get(&cur_source[..]) {

@SolidTux
Copy link
Contributor Author

Listing at least works, I'll try to update a package and see what happens.

This is the repo by the way, maybe it's about the repo and not the program ...

@SolidTux
Copy link
Contributor Author

SolidTux commented Mar 11, 2020

Interesting ... with the patch the command show no error, but also the update is not recognized. And without the patch the error is shown. Sorry, I never tested if the updating works, only if the package is listed 🤦‍♂️

@nabijaczleweli
Copy link
Owner

nabijaczleweli commented Mar 11, 2020

😆 zall good, who hasn't been there lol

I think you're gonna have to add the source with, at minimum,

[source.cloudsmith]
registry = "https://dl.cloudsmith.io/public/solidtux/cargo/cargo/index.git"

in your ~/.cargo/config, to install/update packages from there?

@SolidTux
Copy link
Contributor Author

SolidTux commented Mar 11, 2020

My ~/.cargo/config looks like

[registries]
solidtux-cargo = { index = "https://dl.cloudsmith.io/public/solidtux/cargo/cargo/index.git" }

because the cargo book and the cloudsmith help. But when I add

[source.solidtux-cargo]
registry = "https://dl.cloudsmith.io/public/solidtux/cargo/cargo/index.git"

as you suggested, everything works.

What exactly is the difference between registries.NAME.index and source.NAME.registry?

Edit: Apparently the index version is deprecated according to the reference. So it seems that the other sources are just outdated.

@nabijaczleweli
Copy link
Owner

Oh neat, I didn't actually know about those before! This might warrant an issue on cloudsmith's side, too.

Glad I could help!

@SolidTux
Copy link
Contributor Author

But it only works, when both entries are present 🤷‍♂️ Thank you for helping!

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

No branches or pull requests

2 participants