Crate version not found when using gitea as registry (new try)

Tried to post this here, but I think something went wrong. Please delete that if possible, I can not access it

Hi

I am experiencing some weird issues with using gitea as a registry. I am not quite sure if this is a gitea problem, a cargo problem or some combination.

I have a rust library function-generator, which I have successfully published versions 0.1.5-alpha.1, 0.1.5-alpha.0, and 0.1.4 to my private gitea registry. I can use these versions as dependencies and it works fine. However now all of a sudden when I tried to publish 0.2.0-alpha.0 the crate seems to get published. I can see it in my-gitea.domain/Owner/-/packages/cargo/function-generator. I can also see it mentioned in Owner/_cargo-index. I also see 0.2.0-alpha.0 when running cargo search function-generator. But I can not actually use it (cargo add function-generator@0.2.0-alpha.0 and cargo build fails)

Any thoughts?

Here is my second try (now v0.2.0-alpha.1) with the same result

$ cargo publish
...
Uploading function-generator v0.2.0-alpha.1 (/path/function-generator)     
    Uploaded function-generator v0.2.0-alpha.1 to registry `gitea`                                                                                                              
note: Waiting for `function-generator v0.2.0-alpha.1` to be available at registry `gitea`.                          
You may press ctrl-c to skip waiting; the crate should be available shortly.                                                                                                    
warning: timed out waiting for `function-generator v0.2.0-alpha.1` to be available in registry `gitea`
note: The registry may have a backlog that is delaying making the crate available. The crate should be available soon.
$ cd /path-to/my-bin
$ cargo add function-generator@0.2.0-alpha.1
    Updating `gitea` index
error: the crate `function-generator@0.2.0-alpha.1` could not be found in registry index.
$ cargo search function-generator
    function-generator = "0.2.0-alpha.1"    # 
$ cargo build
    Updating `gitea` index
    Updating crates.io index
error: failed to select a version for the requirement `function-generator = "^0.2.0-alpha.1"`
candidate versions found which didn't match: 0.1.5-alpha.1, 0.1.5-alpha.0, 0.1.4, ...
location searched: `gitea` index
required by package `my-bin v0.1.0 (/path/my-bin)`
if you are looking for the prerelease package it needs to be specified explicitly
    function-generator = { version = "0.1.5-alpha.1" }

Snippets of http://my.domain/SomeOwner/_cargo-index/raw/branch/main/fu/nc/function-generator from my cargo registry:

I guess it makes most sense that this is a gitea issue since its cargo registry feature is fairly new. However do you have any recommendations for how to troubleshoot this from cargo's side of things? What does cargo use to decide what versions are available? Anything i can curl or otherwise?

Also, I can download http://my.domain/api/packages/SomeOwner/cargo/api/v1/crates/function-generator/0.2.0-alpha.0/download just fine

One of these may be a typo, but did you publish alpha.0 and request alpha.1?

Yes and no :slight_smile: I have tried the same thing several times. The first failed attempt was 0.2.0-alpha.0, the second failed attempt was 0.2.0-alpha.1 which I copied the output from. But same result both times.

Sorry for the confusion, will update OP

(Temporary technical issue, see here.)

Oh, thanks

Is this perhaps better asked on irlo?

No, this is not a Rust internals issue. Please be patient, you may have to wait for a day if those who know are in a different timezone.

I haven't tried it, but I wonder if cargo build -vvv can give you any insight on what repo it queries, the result it receives, etc. Hopefully you don't need to clear any local caches (somewhere in ~/.cargo) because that would be weird if it changed the behavior.

Ok, will do. Thanks :slight_smile:

Will try that as soon as possible, thanks :slight_smile:

This is the result of that.


~/projects$ cargo new my-bin
    Creating binary (application) `my-bin` package
~/projects$ cd new-bin
~/projects/my-bin$ cargo add function-generator@0.2.0-alpha.1
    Updating `gitea` index
error: the crate `function-generator@0.2.0-alpha.1` could not be found in registry index.
~/projects/my-bin$ cargo add function-generator@0.2.0-alpha.1 -vvv
    Updating `gitea` index
  Credential cargo:token get gitea
error: the crate `function-generator@0.2.0-alpha.1` could not be found in registry index.
~/projects/my-bin$ cargo add function-generator@0.2.0-alpha.0 -vvv
    Updating `gitea` index
  Credential cargo:token get gitea
error: the crate `function-generator@0.2.0-alpha.0` could not be found in registry index.
~/projects/my-bin$ cargo add function-generator@0.1.5-alpha.1 -vvv
    Updating `gitea` index
  Credential cargo:token get gitea
      Adding function-generator v0.1.5-alpha.1 to dependencies
             Features:
             - defmt
             - embedded-svc
             - embuild
             - json
             - npm_rs
             - serde
             - serde_json
             - std
             - stm32g030
             - stm32g0xx-hal
             - stm32g474
             - stm32g4xx-hal
    Updating `gitea` index
    Updating crates.io index
     Locking 27 packages to latest compatible versions
      Adding atomic v0.5.3 (latest: v0.6.0)
      Adding embedded-hal v0.2.7 (latest: v1.0.0)
      Adding nb v0.1.3 (latest: v1.1.0)
# (Me manually updating Cargo.toml with function-generator = { version = "0.2.0-alpha.1", registry = "gitea" })
~/projects/my-bin$ cargo build -vvv
    Updating `gitea` index
  Credential cargo:token get gitea
error: failed to select a version for the requirement `function-generator = "^0.2.0-alpha.1"`
candidate versions found which didn't match: 0.1.5-alpha.1, 0.1.5-alpha.0, 0.1.4, ...
location searched: `gitea` index
required by package `my-bin v0.1.0 (/home/decahe/projects/my-bin)`
if you are looking for the prerelease package it needs to be specified explicitly
    function-generator = { version = "0.1.5-alpha.1" }

And clearing what I think might be the cache:

~/projects/my-bin$ rm -r ~/.cargo/registry/cache/my.gitea.thing-lots-of-hex-numbers
cargo build -vvv
    Updating `gitea` index
  Credential cargo:token get gitea
error: failed to select a version for the requirement `function-generator = "^0.2.0-alpha.1"`
candidate versions found which didn't match: 0.1.5-alpha.1, 0.1.5-alpha.0, 0.1.4, ...
location searched: `gitea` index
required by package `my-bin v0.1.0 (/home/decahe/projects/my-bin)`
if you are looking for the prerelease package it needs to be specified explicitly
    function-generator = { version = "0.1.5-alpha.1" }

How are you specifying the dependency in the Cargo.toml file (maybe share that)? Are you including the prerelease tag in the version

https://doc.rust-lang.org/cargo/reference/resolver.html#pre-releases

The pre-release must be specified, such as foo = "1.0.0-alpha". Similarly cargo install will avoid pre-releases unless explicitly asked to install one.

Here is my Cargo.toml for my binary crate

~/projects/my-bin$ cat Cargo.toml 
[package]
name = "my-bin"
version = "0.1.0"
edition = "2021"
publish = ["gitea"]

[dependencies]
function-generator = { version = "0.2.0-alpha.1", registry = "gitea" }

I think I might be getting closer here. Running CARGO_LOG=trace cargo build -vvv &> cargo.log yields this

With the interesting part being

checking freshness of fu/nc/function-generator
index file version: Unknown
slow path for "fu/nc/function-generator"
json parsed registry function-generator/0.1.1
json parsed registry function-generator/0.1.2
json parsed registry function-generator/0.1.3
json parsed registry function-generator/0.1.4
json parsed registry function-generator/0.1.5-alpha.0
json parsed registry function-generator/0.1.5-alpha.1
json parsed registry function-generator/0.2.0-alpha.0
failed to parse "fu/nc/function-generator" registry package: feature `e-hal-v02` includes `embedded-hal-0-2` which is neither a dependency nor another feature
json parsed registry function-generator/0.2.0-alpha.1
failed to parse "fu/nc/function-generator" registry package: feature `e-hal-v02` includes `embedded-hal-0-2` which is neither a dependency nor another feature
json parsed registry function-generator/0.2.0-alpha.2
failed to parse "fu/nc/function-generator" registry package: feature `e-hal-v02` includes `embedded-hal-0-2` which is neither a dependency nor another feature

which I suppose must be cargo registry - Renamed dependencies does not get renamed · Issue #31500 · go-gitea/gitea · GitHub

1 Like

Thank you all for the help :slight_smile: