nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.25k stars 41 forks source link

Does not work with private registries? #279

Closed vmalloc closed 1 month ago

vmalloc commented 1 month ago

When trying to use cargo-update to update binaries installed from a private registry (e.g. cargo install --registry my-registry XXX - it seems like it does not pick up on newly available versions or releases... Is this a known bug/limitation?

Thanks in advance!

nabijaczleweli commented 1 month ago

Are you sure you double-configured the registry like https://github.com/nabijaczleweli/cargo-update#source-replacement-vs-custom-registries says?

vmalloc commented 1 month ago

I am not using replace-with. My registry is already configured like the recommendation AFAIK:

[registries]
local-registry = { index = "https://url.of.local.registry/registry" }

and the binaries are installed with cargo install --registry=local-registry

nabijaczleweli commented 1 month ago

If also adding

[source]
local-registry = { registry = "https://url.of.local.registry/registry" }

doesn't work, then post ~/.cargo/.crates.toml and ~/.cargo/config.

vmalloc commented 1 month ago

Adding the above did not solve it.

I have to redact some of it because the private crate names are somewhat sensitive, so I renamed the binary I am interested in upgrading "my-bin" here.

My cargo config.toml is as follows:

[registries]
local-registry = { index = "https://url.of.local.registry/registry" }

[source]
local-registry = { registry = "https://url.of.local.registry/registry" }

(Url redacted by search+replace, and I double-checked it for errors so that's not the issue)

My .crates.toml contains many crates but here is the relevant section of it:

[v1]
"cargo-asm 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-llvm-ir"]
"cargo-audit 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-audit"]
"cargo-edit 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = [
    "cargo-add",
    "cargo-rm",
    "cargo-set-version",
    "cargo-upgrade",
]
"my-bin 1.5.1 (registry+https://url.of.local.registry/registry)" = ["my-bin"]
...
vmalloc commented 1 month ago

Running cargo-install again manually installes the newer version (in my case 1.5.2) which is the latest at the moment, but cargo install-update claims that 1.5.1 is the latest version. I can see it fetching my local registry though, which is odd

vmalloc commented 1 month ago

Another strange behavior - when I try to install an even older verison (1.5.0 for example), cargo install-update -l shows the latest to be 1.5.0 all of a sudden, even though it was just 1.5.1 a moment ago... Perhaps this is an issue related to cargo-install itself?

nabijaczleweli commented 1 month ago

Without a way to reproduce this, all I can really tell you is "this should be working".

If this were a sparse registry, then you could blame whatever's serving it, but since it's a git registry, then that's not really the case.

You say it's fetching, but then the version listing is unstable? That's incongruent with how you'd expect git to work. What does the checkout say? Should be in ~/.cargo/registry/index/local.registry-123123123123123/.git, it's a bare repository, git show FETCH_HEAD:my/-b/my-bin (of course, adapt both paths for your real name) inside should show you the real registry state.

vmalloc commented 1 month ago

If I install with --version to a past version and then run cargo install-update - is the expected behavior for it to update to the latest version or keep the old one? Just asking so that I know what to expect in my attempts to narrow down the issue

nabijaczleweli commented 1 month ago

cargo install --version 0.5.0 my-bin should get automatically updated to 0.5.1 &c.

vmalloc commented 1 month ago

So when I manually install my-bin to 1.5.0 (once again - 1.5.2 is available in the registry repo - as a proof it gets installed when I manually rerun cargo install my-bin --registry local-registry) - I get a printout like this from cargo install-update:

Package             Installed  Latest   Needs update
my-bin               v1.5.0     =1.5.0   No
vmalloc commented 1 month ago

And double checking - the FETCH_HEAD in my local checkout (bare git repo) is the very same commit publishing my-bin#1.5.2, so it looks like the local checkout state is correct

nabijaczleweli commented 1 month ago

=1.5.0 means a "don't install anything past 1.5.0" restriction. What does cargo install-update-config my-bin say?

vmalloc commented 1 month ago
Target version    =1.5.0
Default features  true

I suspect the answer to my question from before is actually no - --version sets the requirement at =, meaning it is frozen. Am I wrong here?

vmalloc commented 1 month ago

I see there's a "version_req": "=1.5.0" on it in ~/..cargo/.crates2.json -- I am guessing this was done by cargo install my-bin --version 1.5.0

nabijaczleweli commented 1 month ago

That was interpreted between v14.0.0 and v14.0.1 (clopen). But unless you're running that version, "version_req" is ignored.

You can check ~/.cargo/.install_config.toml if it's actually configured in there, because this probably means that it is.

vmalloc commented 1 month ago

@nabijaczleweli I don't have a ~/.cargo/install_config.toml file...

vmalloc commented 1 month ago

Still even if I were to have installed it pinned to =1.5.0, isn't it weird that cargo install-update shows the latest version as =1.5.0 where 1.5.2 is available?

vmalloc commented 1 month ago

I just found out that my cargo-update is on 14.0, even though I run cargo install-update practically on a daily basis... Perhaps self-update failed for me and so I didn't get the newer version?

After having forced the upgrade to 15 it seems to work correctly now...

vmalloc commented 1 month ago

Closing as this seems to be fixed in 15.0. Thanks a lot for the help @nabijaczleweli !