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

cargo publish doesn't work well with git worktrees #4131

Closed
seanmonstar opened this issue Jun 6, 2017 · 10 comments · Fixed by #13567
Closed

cargo publish doesn't work well with git worktrees #4131

seanmonstar opened this issue Jun 6, 2017 · 10 comments · Fixed by #13567
Assignees
Labels
A-git Area: anything dealing with git A-testing-cargo-itself Area: cargo's tests C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-publish S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@seanmonstar
Copy link

seanmonstar commented Jun 6, 2017

It seems that cargo works fine if a worktree hasn't been changed around much, since testing with a brand new worktree worked fine. However, these steps cause problems:

git checkout -b cargo-worktree
git worktree add ../foo-worktree cargo-worktree
cd ../
mv foo-worktree foo-cargo-worktree
cd foo-cargo-worktree
cargo pacakge -l

As for why you'd possibly do this: I have a worktree to track the 'previous version branch' of hyper. It started as a worktree of 0.8.x, and eventually its become 0.10.x, and I updated the name of the directory. All git commands work fine, but I cannot cargo publish.

This works fine with cargo 0.18.0 (fe7b0cdcf 2017-04-24), but fails with cargo 0.20.0-nightly (38ca9b702 2017-05-14).

@alexcrichton
Copy link
Member

Could you gist the error message you're seeing? This is probably just bubbling up an error when it should likely be ignoring it.

@seanmonstar
Copy link
Author

With RUST_LOG=trace:

TRACE:cargo::ops::cargo_read_manifest: read_package; path=/home/sean/code/hyper-0.10.x/Cargo.toml; source-id=file:///home/sean/code/hyper-0.10.x
DEBUG:cargo::core::workspace: find_root - trying /home/sean/code/Cargo.toml
DEBUG:cargo::core::workspace: find_root - trying /home/sean/Cargo.toml
DEBUG:cargo::core::workspace: find_root - trying /home/Cargo.toml
DEBUG:cargo::core::workspace: find_root - trying /Cargo.toml
DEBUG:cargo::core::workspace: find_members - only me as a member
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/home/sean/code/hyper-0.10.x/Cargo.toml; source-id=file:///home/sean/code/hyper-0.10.x
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/home/sean/code/hyper-0.10.x/Cargo.toml; source-id=file:///home/sean/code/hyper-0.10.x
DEBUG:cargo::ops::cargo_package: found a git repo at "./", checking if index present
   Packaging hyper v0.10.12 (file:///home/sean/code/hyper-0.10.x)
WARN:cargo::sources::path: list_files_git hyper v0.10.12 (file:///home/sean/code/hyper-0.10.x)
   Verifying hyper v0.10.12 (file:///home/sean/code/hyper-0.10.x)
TRACE:cargo::sources::path: root_package; source=the paths source
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/home/sean/code/hyper-0.10.x/target/package/hyper-0.10.12/Cargo.toml; source-id=file:///home/sean/code/hyper-0.10.x/target/package/hyper-0.10.12
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/home/sean/code/hyper-0.10.x/target/package/hyper-0.10.12/Cargo.toml; source-id=file:///home/sean/code/hyper-0.10.x/target/package/hyper-0.10.12
DEBUG:cargo: exit_with_error; err=CliError { error: Some(ChainedError { error: failed to verify package tarball, cause: ChainedError { error: failed to read `/home/sean/code/hyper-0.10.x/target/package/hyper-0.10.12/Cargo.toml`, cause: No such file or directory (os error 2) } }), unknown: false, exit_code: 101 }
error: failed to verify package tarball

Caused by:
  failed to read `/home/sean/code/hyper-0.10.x/target/package/hyper-0.10.12/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

When I use cargo package -l in this directory, it exits successfully, with no output. This leads to me think the list_git_files is somehow filtering out this whole directory.

@alexcrichton
Copy link
Member

Hm unsure! This may not actually be packaging up anything? Unfortunately nothing leaps to mind as the cause...

@carols10cents carols10cents added A-git Area: anything dealing with git C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-publish labels Oct 3, 2017
@kvark
Copy link

kvark commented Feb 24, 2018

Head's up! We are suffering from the same issue in https://github.com/three-rs/three :(

@kvark
Copy link

kvark commented Feb 24, 2018

Also, I consider this strictly "C-bug" rather than "C-feature-request". First, it's totally confusing what cargo doesn't like when you just face the issue. Secondly, I'm still not able to work around it. Tried cargo from the following toolchains with no success:

  • 1.25.0
  • 1.18.0
  • 1.17.0
  • 1.16.0
  • 1.10.0

@kvark
Copy link

kvark commented Feb 24, 2018

Hah, it turns out our issue was not the subject, sorry! I assumed this originally because the error message is an exact match, and three-rs is the only project I publish that added git submodules.
Our real problem was having both include and exclude directives in Cargo.toml. Would be best to detect and report it as a proper error in cargo.

@eminence
Copy link
Contributor

I'm not able to reproduce the original worktree issue with the reported versions, but I did find that cargo 1.46 and 1.47 would give an error about "did not expect repo at XYZ to be bare" when run in a worktree. I'm pretty sure the upgrade of git2 in #8778 is what made things work in 1.48.

I haven't found any issues with the latest cargo using worktrees or spase checkouts

Possible same root cause as #7876

@epage
Copy link
Contributor

epage commented Oct 12, 2023

Based on @eminence's comment, it sounds like this is no longer reproducible. If people find a way to reproduce this same bug, let us know and we can look into re-opening.

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2023
@epage epage reopened this Oct 12, 2023
@epage
Copy link
Contributor

epage commented Oct 12, 2023

Re-opened because a good point was made in #7876 that we should get tests added for this.

@epage epage added A-testing-cargo-itself Area: cargo's tests S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review labels Oct 12, 2023
@LuuuXXX
Copy link
Contributor

LuuuXXX commented Mar 4, 2024

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-git Area: anything dealing with git A-testing-cargo-itself Area: cargo's tests C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-publish S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants