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 chokes on symlinks #2748

Closed
elinorbgr opened this issue May 28, 2016 · 4 comments · Fixed by #6817
Closed

cargo publish chokes on symlinks #2748

elinorbgr opened this issue May 28, 2016 · 4 comments · Fixed by #6817

Comments

@elinorbgr
Copy link

On my project wayland-client, I have a structure like this:

- protocols/
- wayland-client/
    |- protocols/ (symlink -> ../protocols)
    |- src/
    |- Cargo.toml

With previous versions of cargo, publishing wayland-client worked as expected, packaging the contents of protocols through the symlink as if it was a simple directory.

Now, since I updated to cargo 0.10.0, cargo publish chokes on the protocols symlink:

 $ cargo publish --verbose
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Packaging wayland-client v0.6.0 (file:///home/levans/dev/wayland-rs/wayland-client)
   Archiving Cargo.toml
   Archiving build.rs
   Archiving examples/list_globals.rs
   Archiving examples/simple_window.rs
   Archiving protocols
error: failed to prepare local package for uploading

Caused by:
  could not archive source file `protocols`

Caused by:
  Is a directory (os error 21)
@elinorbgr
Copy link
Author

Hmm, last time I tried to publish something, I worked around the issue by copying the directory in place of the symlink and it worked fine.

Now, it doesn't any more, and I didn't update cargo in the meantime... I don't understand what's going on.

@elinorbgr
Copy link
Author

Thanks to @SimonSapin I understood what's going on: cargo uses the git index to list the files to package.But the symlink is listed as a plain file in this index, not as a directory (and that's caused my other error: I didn't git add the directory after copying it).

Needless to say I'd really like this to work again (I use the symlink because this "protocols" directory is shared between two projects), but I understand I'd be more than a simple bugfix.

@emberian
Copy link
Member

This isn't always quite as simple to workaround when the symlink is in a submodule that you don't really have the ability to modify...

@davechallis
Copy link

davechallis commented Aug 24, 2018

Are there currently any good workarounds for this? I'm working on a project which uses a 3rd party submodule (which itself contains submodules), and which makes heavy use of symlinks throughout its directory structure (which makes modifying it non-trivial).

This also affects the cargo package command, so maybe needs a label for that adding?

ysimonson added a commit to pachyderm/rust-pachyderm that referenced this issue Mar 13, 2019
bors added a commit that referenced this issue Jul 31, 2019
Handle symlinks to directories

When cargo encounters a link, check if it's a directory when considering it for further processing.
I'm not sure how this interacts with things such as submodules – it allowed me to publish the crate [pqcrypto-kyber768](https://github.com/rustpq/pqcrypto) which uses a link to a submodule.

Fixes #2748.

This PR:
* Add new tests that demonstrate that links to dirs can't be packaged
* Fixes those tests
* Enabled symlink tests to run on Windows
* Fix a bug in the handling of symlinks
* Add new test runner behaviour on Windows (it will ignore symlink-related tests and instead run them if you specify --ignored.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants