-
Notifications
You must be signed in to change notification settings - Fork 2.6k
cargo install
should respect [patch]
from user config
#12855
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
Comments
cargo install
should respect patchcargo install
should respect [patch]
from user config
Cargo generally starts a config discovery from the current working directory. However, it is not the case for It makes sense to me for |
The cargo team discussed this, and we didn't have any specific reasons to not support that. There was some confusion as to why this isn't working, but I just looked and understood the reason is that I'm marking this accepted conditional on how complex the solution might be. |
Oh, I had missed that this was for patching what you install and not what it depends on. @loynoir could you help me understand the use case for this? I would have assumed that if you want to install something from somewhere else, you would just specify that to |
According to my memory, I was installing cli tool. And that cli tool need to download asset using maybe-non-reqwest builder with hard code timeout, which leads to cli failure within my side. So, I git clone repo, and patch that hard code timeout number. |
The original real world problem is patch hard-code-timeout-cli. So, the best solution is not supporting path to patched large dir, but supporting I currently don't have good example of famous nodejs repo using https://github.com/configu/configu/blob/main/patches/giget.patch |
If I'm understanding correctly, you were installing a tool that you needed to patch. What is the reason for wanting to use
Yes, there is interest in supporting patch files and we are tracking that in #4648. However, they would likely be managed through |
Too long, and not able to reuse reasonable hard code timeout patch.
Zero config This is Would be nice into cargo project layout default. |
I feel like I'm missing something about that last part. How is
Could you describe this solution within pnpm for someone without any node background and then share how you think that could then be applied to cargo? |
Within devcontainer $ cargo install --path /workspaces/repo/workaround/optional-dx-cli-with-timeout-patch Within new devcontainer $ cargo install --path /workspaces/repo/workaround/optional-dx-cli-with-timeout-patch I would prefer longer config, shorter cli for reuse. Don't need to remember the path. Patch transparently. Decrease mind burden. [patch.crates-io]
optional-dx-cli = { path = '/workspaces/repo/workaround/optional-dx-cli-with-timeout-patch' } Within devcontainer $ cargo install optional-dx-cli Within new devcontainer $ cargo install optional-dx-cli
I don't have small popular real world patch example near my hand. According to my memory, I would suggest like below. https://yarnpkg.com/cli/patch-commit https://github.com/search?q=org%3Ayarnpkg%20path%3Apatches&type=code Given background
Start patching $ cargo yarn patch foo
[Show hint like]
`foo` have multiple versions, select one $ cargo yarn patch foo@cratesio:1.0.0
[Show hint like]
`foo@cratesio:1.0.0.zip` now decompressed to `/tmp/xfs-foo-cratesio:1.0.0-hash/`.
Please modify `/tmp/xfs-foo-cratesio:1.0.0/`.
After that, run `cargo yarn patch-commit /tmp/xfs-foo-cratesio:1.0.0-hash/`
...
$ cargo yarn patch foo@cratesio:2.0.0
... $ cargo yarn patch-commit /tmp/xfs-foo-cratesio:1.0.0-hash/
[Show hint like]
Writing `/workspaces/repo/patches/foo-cratesio:1.0.0-hash.patch`
Writing `/workspaces/repo/Cargo.lock`
...
$ cargo yarn patch-commit /tmp/xfs-foo-cratesio:2.0.0-hash/
... .
├── Cargo.lock
├── Cargo.toml
├── src/
│ ├── lib.rs
│ ├── main.rs
│ └── bin/
│ ├── named-executable.rs
│ ├── another-executable.rs
│ └── multi-file-executable/
│ ├── main.rs
│ └── some_module.rs
├── benches/
│ ├── large-input.rs
│ └── multi-file-bench/
│ ├── main.rs
│ └── bench_module.rs
├── examples/
│ ├── simple.rs
│ └── multi-file-example/
│ ├── main.rs
│ └── ex_module.rs
├── patches/
│ ├── foo-cratesio:1.0.0-hash.patch
│ └── foo-cratesio:2.0.0-hash.patch
└── tests/
├── some-integration-tests.rs
└── multi-file-test/
├── main.rs
└── test_module.rs Before yarn patch commit, Cargo.toml
After yarn patch commit, Cargo.toml not changed, but Cargo.lock
|
Thanks for expanding on the use case! If I'm understanding correctly, you are creating many dev containers that all have access to your host system's Maybe I'm missing something but this seems relatively specialized and there are alternative ways of resolving (scripts, aliases). Granted, there still might be value due to consistency / level of surprised.
This is showing the workflow for patching a dependency. For installing a binary, I assume you would want us to also have a For local patches, I wonder if we should load from To reiterate, this would all be blocked on #4648. |
Hmm, thinking more about the experience of (1) If a user puts a
See #15130 So it seems like patching dependencies of We could provide an install-specific config location but then we'd get these warnings between different cargo-installed commands. We could have a (2) The experience of lining up a patch with dependencies is not great. If we kept the existing behavior for |
Problem
I want to install
XXX
with a patch./home/user/.cargo/config.toml
cargo install XXX
is still installing the original version.Steps
No response
Possible Solution(s)
cargo install
should respect patchNotes
No response
Version
The text was updated successfully, but these errors were encountered: