Workarounds for cargo publish/package on symlinks?

I'm currently trying to publish a crate which contains some 3rd party code as a git submodule (which in turn has its own submodules).

One issue that I've run into is that the code contains a lot of symlinks, which cargo doesn't currently handle (https://github.com/rust-lang/cargo/issues/2748).

Has anyone that's run into this got any good suggestions for workarounds? Currently I've come up with two options:

  • fork the 3rd party repo, replace all symlinks with the dirs/files they point at, add that as a submodule
  • remove the submodule from being packaged entirely, and fetch the 3rd party code at build time

Anything else I should consider?

cargo publish only needs to work on your machine. Before publishing, you could replace the symlinks locally, and run cargo publish --allow-dirty if needed.

1 Like

Thanks, that's an option too. Was hoping to avoid the --allow-dirty flag if possible, but seems there might not be any easy way for that to happen.

Forgot to update this in case it's useful to anyone else:

cargo publish --allow-dirty (and package) didn't work, both with/without the --no-verify option too.

I also tried both removing the symlinks, and replacing the symlinks with the directories they pointed at, but all give the same error, e.g.:

$ cargo publish --allow-dirty --no-verify
error: failed to prepare local package for uploading

Caused by:
  could not archive source file `foo/bar`

Caused by:
  Is a directory (os error 21)

Current plan is to fork the 3rd party repo and replace symlinks, but haven't found the time to do that yet.