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

Can't publish to private registry (works with cargo publish) #831

Closed
scullionw opened this issue Jun 21, 2023 · 9 comments · Fixed by #863
Closed

Can't publish to private registry (works with cargo publish) #831

scullionw opened this issue Jun 21, 2023 · 9 comments · Fixed by #863
Labels
bug Something isn't working

Comments

@scullionw
Copy link

Bug description

Can't publish to private registry (works with cargo publish)

Expected behavior

I would expect the crates to be published like they are with cargo publish or cargo release

Screenshots

Screenshot 2023-06-21 at 6 22 59 PM

Environment

  • OS: macOS 13.3
  • release-plz version: release-plz 0.3.14
@scullionw scullionw added the bug Something isn't working label Jun 21, 2023
@MarcoIeni
Copy link
Owner

Thanks for the report, I will try to reproduce and fix this 👍

@Kelwing
Copy link
Contributor

Kelwing commented Jul 20, 2023

@MarcoIeni I looked into this because I was running into the same issue. It's caused when the private registry is configured using a sparse protocol url instead of a git url. release-plz only uses the git index fromcrates_index and tries to initialize the Index object from a sparse registry URL.
https://github.com/MarcoIeni/release-plz/blob/main/crates/release_plz_core/src/command/release.rs#L315

@MarcoIeni
Copy link
Owner

MarcoIeni commented Jul 20, 2023

Thanks for looking into this. I'll try to look into this next week.
In the meantime, if you have a proposal on how to fix it let me know :)

@MarcoIeni
Copy link
Owner

I'm trying to check if #863 fixed this issue.

  • scullionw, can you try if that branch fixes your issue?
  • Kelwing, can you tell me how have you tested it?

I registered to shipyard.rs, I added this to my .cargo/config.toml:

[registries.ieni]
index = "ssh://git@ssh.shipyard.rs/ieni/crate-index.git"

[net]
git-fetch-with-cli = true

[http]
user-agent = "shipyard <token>"

and I created an ssh key pair.

However both release-plz and cargo publish are failing for me.

$ cargo publish --registry ieni
    Updating `ieni` index
git@ssh.shipyard.rs: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
error: failed to update registry `ieni`

Caused by:
  failed to fetch `ssh://git@ssh.shipyard.rs/ieni/crate-index.git`

Caused by:
  process didn't exit successfully: `git fetch --force --update-head-ok 'ssh://git@ssh.shipyard.rs/ieni/crate-index.git' '+HEAD:refs/remotes/origin/HEAD'` (exit status: 128)

Probably I'm missing something from the configuration.

@Kelwing
Copy link
Contributor

Kelwing commented Jul 25, 2023

@MarcoIeni Sparse registry indexes don't use get, they use https. A sparse index URL will start with sparse+https. You should be able to test this with crates.io by specifying sparse+https://index.crates.io/ as your registry index.

https://doc.rust-lang.org/cargo/reference/registry-index.html#sparse-protocol

@MarcoIeni
Copy link
Owner

MarcoIeni commented Jul 25, 2023

ok, thanks, I will test this. However, from scullionw's screenshot, I see he is not using a sparse registry (I see a git@ssh).
Do you think your PR fixes his issue?

@MarcoIeni
Copy link
Owner

reopening, because I'm not sure the linked pr fixed the issue

@MarcoIeni MarcoIeni reopened this Jul 25, 2023
@Kelwing
Copy link
Contributor

Kelwing commented Jul 25, 2023

That's the same behavior and error I was seeing when I tried using a sparse URL without support for it. The crate_index package would attempt to treat it as if it were a git repo. I do feel it would be appropriate for this issue to be left open until the author can verify that the PR fixed it for them, and they are able to provide more information about whether or not they are using a sparse index.

@MarcoIeni
Copy link
Owner

In #892 I added a test where I publish a crate to the gitea private cargo registry which runs in docker.
This demonstrates that release-plz can publish to private registries, so I'm closing this issue.
If you find issues with other cargo registries, please open another issue with a step-by-step reproduction guide (e.g. register to this website, click here, use a certain config.toml, etc.).
Thanks everyone 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants