rust-lang/cargo

cargo publish chokes on symlinks

Closed this issue · 4 comments

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)

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.

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.

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...

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?