Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd cargo-add (from cargo-edit) to cargo proper #5586
Comments
This comment has been minimized.
This comment has been minimized.
|
@rust-lang/cargo, is this something you'd be interested in being worked on right now? This might work as a mentored even if you can't spend much time to work on it ourselves. |
This comment has been minimized.
This comment has been minimized.
|
I'd personally be thrilled to see this enter Cargo itself! I would ideally prefer to avoid having two TOML parsers built in but if we need to have that for the time being I think it's not the end of the world. (I don't know much about the technical design of cargo-edit right now) |
This comment has been minimized.
This comment has been minimized.
|
This is the number one thing I want in Cargo; a simple |
This comment has been minimized.
This comment has been minimized.
ibaryshnikov
commented
May 29, 2018
•
|
I'd like to implement it, work in-progress is here |
ibaryshnikov
referenced this issue
Jun 5, 2018
Closed
[WIP]: Add cargo-add (from cargo-edit) to cargo proper #5611
added a commit
to ibaryshnikov/cargo
that referenced
this issue
Jun 16, 2018
added a commit
to ibaryshnikov/cargo
that referenced
this issue
Jun 16, 2018
added a commit
to ibaryshnikov/cargo
that referenced
this issue
Jul 2, 2018
This comment has been minimized.
This comment has been minimized.
|
I know that lots of people (myself included) are plenty busy with stuff for the upcoming edition release and that we don't have much spare @rust-lang/cargo @killercup @aturon could we make this happen, somehow? |
This comment has been minimized.
This comment has been minimized.
|
Huuuuuuuuuuuuge
… On Sep 6, 2018, at 7:59 PM, Jorge Aparicio ***@***.***> wrote:
I know that lots of people (myself included) are plenty busy with stuff for the upcoming edition release and that we don't have much spare human Rustacean resources but I still want to say that it would be AMAZING to have cargo add in Cargo 2018. As mentioned by boats, cargo add fits perfectly with the module / path changes of the edition. And I fully agree, but to me the biggest win would be not having to cargo install cargo-edit, which involves compiling / linking to C code and can be a (very) frustrating experience.
@rust-lang/cargo @killercup @aturon could we make this happen, somehow?
|
Mark-Simulacrum
added
I-nominated
T-cargo
labels
Sep 7, 2018
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
ibaryshnikov
commented
Sep 7, 2018
|
I did some preparations in this pr like filling the boilerplate and updating errors from cargo-edit to fit more for cargo, but farther work requires some patches to toml parser which is used in cargo (in case we don't want to have two parsers), and currently I don't have enough time to do required updates in the parser on my own. If you find some of the code in this pr fits for the solution, feel free to use it. |
This comment has been minimized.
This comment has been minimized.
thejpster
commented
Sep 11, 2018
|
I just wanted to add that I think cargo-add is a great tool for people new to Rust, as is cargo-generate. Unfortunately if I recommend them in a guide or tutorial, I have to explain how to install them and that they need to first install GCC and cmake and libssl-dev, which is non-trivial. |
added a commit
to ibaryshnikov/cargo
that referenced
this issue
Sep 11, 2018
This comment has been minimized.
This comment has been minimized.
|
Definitely would love to see this added to cargo, since my workflow setting up a new dev environment is:
As @ibaryshnikov points out though, its nontrivial work since the TOML parser cargo uses right now doesn't preserve layout, whitespace, or comments. We need to migrate to using the same parser cargo-edit uses before we can upstream any of its features into cargo. |
This comment has been minimized.
This comment has been minimized.
|
We discussed this in the cargo meeting. There was strong support for upstreaming the functionality of We are comfortable having two TOML parsers in cargo for now (with a view to eventually merging them) so long as they share a common lexer, to be confident they aren't interpreting the TOML significantly differently. @alexcrichton says he's left a comment on the repo for the parser cargo-edit is using to this effect. |
nrc
removed
the
I-nominated
label
Sep 19, 2018
dwijnand
referenced this issue
Oct 27, 2018
Closed
Subcommand to add a new dependency to Cargo.toml #2179
carols10cents
referenced this issue
Dec 26, 2018
Closed
Ability to `cargo install <dependency>@<version>` should update `Cargo.toml` #6488
This comment has been minimized.
This comment has been minimized.
sandangel
commented
Jan 5, 2019
|
Hi everyone, may I know the status of this issue? It's 2019 now and Happy New Year. ^^ |
This comment has been minimized.
This comment has been minimized.
|
From the discord Today at 5:48 PM: |
killercup commentedMay 28, 2018
•
edited
Cargo as well as cargo-edit have gone a long way since #4 was opened. It might now make sense to move (parts of) cargo-edit into cargo itself. Basically, we now have a format-preserving TOML library that -- at least for adding a dependency line -- work quite well (you can test this with
cargo install cargo-edit --vers 0.3.0-beta.1 -f).Speaking with @matklad, I believe I now have a somewhat solid understanding of what needs to happen to add a new built-in cargo subcommand. One important realization was that cargo-install already contains some of the parts we need.
Here are some steps to get started:
src/bin/cargo/commands/add.rs(as duplicate ofinstall.rsat first)src/bin/cargo/commands/mod.rs, addaddtobuiltin/builtin_exec, and to the list ofmodssrc/bin/cargo/ops/cargo_add.rs(as duplicate ofcargo_install.rsat first)One thing we should aim for though, is to now just copy-paste the whole of cargo-edit but to re-use as much of cargo's infrastructure as possible. For example, we should try to use cargo's way of querying the registry as well as its CLI args handling and output formatting. We can, for example, also use
args.workspace.current_manifestto get the manifest and deal with workspace.