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 dependency cannot recognize ~ as home path in dependency's path field #14882

Open
eval-exec opened this issue Dec 2, 2024 · 3 comments
Labels
A-manifest Area: Cargo.toml issues C-enhancement Category: enhancement S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@eval-exec
Copy link
Contributor

Problem

I have a dependency on my local file system:

❯ cat Cargo.toml
[package]
name = "cargo-path-bug"
version = "0.1.0"
edition = "2021"

[dependencies]
cargo-path-bug-lib = { path = "~/Temp/cargo-path-bug-lib/", package = "cargo-path-bug-lib"}

But when I run cargo run, it recognize ~ as a dir, not my home path.

❯ cargo run
error: failed to get `cargo-path-bug-lib` as a dependency of package `cargo-path-bug v0.1.0 (/home/exec/Temp/cargo-path-bug)`

Caused by:
  failed to load source for dependency `cargo-path-bug-lib`

Caused by:
  Unable to update /home/exec/Temp/cargo-path-bug/~/Temp/cargo-path-bug-lib

Caused by:
  failed to read `/home/exec/Temp/cargo-path-bug/~/Temp/cargo-path-bug-lib/Cargo.toml`

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

Steps

No response

Possible Solution(s)

request to recognize ~ as home path.

Notes

No response

Version


@eval-exec eval-exec added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Dec 2, 2024
@epage epage added A-manifest Area: Cargo.toml issues S-needs-team-input Status: Needs input from team on whether/how to proceed. S-triage Status: This issue is waiting on initial triage. and removed S-triage Status: This issue is waiting on initial triage. S-needs-team-input Status: Needs input from team on whether/how to proceed. labels Dec 2, 2024
@epage
Copy link
Contributor

epage commented Dec 2, 2024

Could you help me understand why you want to use user-relative paths? In my mind, the use case is limited because no one else can use that. If someone clones your repo, they have to lay out the paths exactly how you do which is even weirder for windows systems because users don't normally write to ~. For local prototyping or patching, I would assume relative paths would work just as well. At worse, you can fully specify the path.

Support for ~ is not built-in to the OS but is something apps have to manually support. Technically, adding support would be a breaking change as ~ is allowed in paths.

@epage epage added C-enhancement Category: enhancement and removed C-bug Category: bug labels Dec 2, 2024
@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Dec 2, 2024
@eval-exec
Copy link
Contributor Author

eval-exec commented Dec 3, 2024

Could you help me understand why you want to use user-relative paths?

emmm.I just got used to doing it this way.

If someone clones your repo, they have to lay out the paths exactly how you do which is even weirder for windows systems because users don't normally write to ~.

I think windows systems have ~ too, it's %USERPROFILE%, may like C:\Users\John

Finally, I think supporting ~ would be better, but it's okay if it's not supported.

@epage
Copy link
Contributor

epage commented Dec 3, 2024

Yes, most software that supports ~ maps it to the user profile. I was more so highlighting that users don't normally put files there and so

  • Its less convenient as more nesting is needed
  • Cloning a repo that uses ~ will require unusual filesystem layout for a windows user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-manifest Area: Cargo.toml issues C-enhancement Category: enhancement S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

3 participants