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 vendor is not consistent about paths and symbolic links on Windows vs. other platforms #14965

Open
glandium opened this issue Dec 19, 2024 · 0 comments
Labels
C-bug Category: bug Command-vendor O-windows OS: Windows S-triage Status: This issue is waiting on initial triage.

Comments

@glandium
Copy link
Contributor

Problem

About paths:
when a crate contains paths for e.g. dependencies in a workspace, cargo vendor uses / on Unices and \ on Windows, changing whatever the original path was.

About symbolic links:
when a crate contains symbolic links to another file in a workspace, cargo vendor expands the content on Unices and replaces it with the path of the link target on Windows.

Steps

  1. cargo new foo
  2. cd foo
  3. cargo add libz-rs-sys
  4. cargo vendor

On Linux or Mac, you end up with a proper vendor/libz-rs-sys/LICENSE file, and vendor/libz-rs-sys/Cargo.toml has dependencies.zlib-rs.path = "../zlib-rs".
On Windows, vendor/libz-rs-sys/LICENSE literally contains ../LICENSE, and vendor/libz-rs-sys/Cargo.toml has dependencies.zlib-rs.path = "..\zlib-rs".

Possible Solution(s)

cargo vendor should be consistent, wherever it's run.

Notes

No response

Version


@glandium glandium added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Dec 19, 2024
github-merge-queue bot pushed a commit that referenced this issue Dec 31, 2024
### What does this PR try to resolve?

This adds a special case for checking source files are symlinks
and have been modified when under a VCS control

This is required because those paths may link to a file outside the
current package root, but still under the git workdir, affecting the
final packaged `.crate` file.

### How should we test and review this PR?

Pretty similar to #14966, as a part of #14967.

This may have potential performance issue. If a package contains
thousands of symlinks, Cargo will fire `git status` for each of them.
Not sure if we want to do anything proactively now.

The introduction of the `PathEntry` struct gives us more room for
storing file metadata to satisfiy use cases in the future. For
instances,

* Knowing a source file is a symlink and resolving it when packaging on
Windows
  * #5664
  * #14965
* Knowing more about a file's metadata (e.g. permission bits from Git)
  * #4413
  * #8006
* Provide richer information for `cargo package --list`, for example
JSON output mode
  * #11666
  * #13331
  * #13953
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-vendor O-windows OS: Windows S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants