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

Support ~ in path for dependencies #12874

Open
Wasabi375 opened this issue Oct 24, 2023 · 4 comments
Open

Support ~ in path for dependencies #12874

Wasabi375 opened this issue Oct 24, 2023 · 4 comments
Labels
A-crate-dependencies Area: [dependencies] of any kind C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@Wasabi375
Copy link

Wasabi375 commented Oct 24, 2023

Problem

I would like to specify a dependency relative to my home directory. At the moment I would need to specify the home directory as a full path which is platform dependent, e.g Linux

my_dep = { path = "/home/name/rust/my_dep" }

Proposed Solution

Most shells expand ~ into the current users home directory. It would be nice if cargo could do the same.

my_dep = { path = "~/rust/my_dep" }

That would than be expanded into the user home directory.

Notes

Currently ~/something is resolved to project-dir/~/something which is obviously not what is intended by the user.

Also looking through existing issues, this might be the same as #12873

@Wasabi375 Wasabi375 added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Oct 24, 2023
@epage epage added the A-crate-dependencies Area: [dependencies] of any kind label Oct 24, 2023
@epage
Copy link
Contributor

epage commented Oct 24, 2023

Could you expand on your use case for why you are using absolute paths in dependencies?

For myself, my projects tend to be in repos and shared with others, so I can't count on an absolute path being there, only relative paths to other items within my repo. If I need to reference something outside my repo, it then needs to be a git dependency.

@weihanglo
Copy link
Member

FWIW, previously we had #9855 and rust-lang/rfcs#3074.

@Wasabi375
Copy link
Author

My use case is the following:

I had a problem with a library: In this case rust-derive-builder.
Created a small test project to reproduce the issue.
After some discussion I started working on a fix.
Now I want to use my local implementation of rust-derive-builder in my test project to ensure that I have a working solution.

Maybe a better solution would be to just copy my minimal test case into a proper test within the library.
That said I was still surprised about the fact that ~ is not handled the way I would expect it to. I always assumed that ~ was a special character in paths and only learned that ~ is a shell feature, after googling for it when creating this issue.

@epage
Copy link
Contributor

epage commented Oct 24, 2023

Thanks for explaining, that helps a lot in understanding how someone would run into this in day-to-day operations.

On the broader side of this topic, I've wondered if we could have an improved workflow around patching, like a new subcommand that would make it easy to patch a dependency to an in-dev version, then clone that dependency so you can make a change, and then back this out of your project. We have issues like #1545 and #1861 which tie into that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-crate-dependencies Area: [dependencies] of any kind C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants