147 Commits

Author SHA1 Message Date
Scott Schafer
6131222ba2 feat: stabilize auto fix note 2023-01-10 13:52:29 -06:00
bors
79fe7573b0 Auto merge of #11401 - adam248:patch-1, r=ehuss
add newline char to `cargo install .` error message for easier reading.

I just noticed the `cargo install .` error message was not formatted very nicely.

Just added a newline char to make it cleaner.

Thanks
2022-11-25 13:34:10 +00:00
Adam Butler
1b7e256413 fixed typo causing broken cargo install . test case 2022-11-22 14:14:29 +09:30
Adam Butler
db0d3f9de1
fixed cargo fmt error regarding unknown escape char. 2022-11-22 13:24:59 +09:30
Adam Butler
c5836e97ba
fixed broken error made by newline char in cargo install . error message 2022-11-22 13:19:05 +09:30
Scott Schafer
8ff8eaa496 add a note that some warnings can be auto-fixed 2022-10-27 19:07:59 -05:00
Ed Page
96948f7a24 refactor(cli): Upgrade to clap v4 2022-09-28 13:32:14 -05:00
Scott Schafer
c239e407e7 add a reason to masquerade_as_nightly_cargo so it is searchable 2022-07-15 21:32:23 -05:00
Arlo Siemsen
24dac452c5 Improve testing framework for http registries
Improve integration of the http server introduced by the http-registry feature.
Now the same HTTP server is used for serving downloads, the index, and
the API.

This makes it easier to write tests that deal with authentication and
http registries.
2022-06-10 16:51:35 -05:00
bors
23ae8a0a0f Auto merge of #10650 - epage:install, r=ehuss
feat(install): Support `foo@version` like cargo-add

### What does this PR try to resolve?

This aims to make `cargo install` consistent with
- `cargo add foo@version` from #10472
- pkgid changes in #10582
- `cargo yank foo@version` from #10597

It also offers a shorthand for people installing a specific version.

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

#10582 acted as the FCP for this, see #10597

Documentation updates are split into their own commit to not clog up browsing the code.

Examine the tests to see if they make sense

### Additional information

While the `foo@vewrsion` syntax is the same, each's semantics are different.  We had decided it was better to have the same syntax with different semantics than having the user worry about what syntax they use where.  In `cargo install`s case, it has an
implicit-but-required `=` operand while `cargo-add` allows any operand.

This doesn't use the full `pkgid` syntax because that allows syntax that
is unsupported here.

This doesn't use `cargo-add`s parser because that is for version reqs.

I held off on reusing the parser from `cargo-yank` because they had
different type system needs and the level of duplication didn't seem
worth it (see Rule of Three).
2022-05-11 03:25:36 +00:00
Scott Schafer
cab6d30c1d fix typos found by the typos-cli crate 2022-05-10 16:47:28 -05:00
Ed Page
07681341da feat(install): Support foo@version like cargo-add
In #10472, cargo-add was merged with support for an inline version
syntax of `foo@version`.  That also served as the change proposal for
extending that syntax to `cargo install` for convinience and consistency.

While both commands are specifying a version-req, `cargo-install` has an
implicit-but-required `=` operand while `cargo-add` allows any operand.

This doesn't use the full `pkgid` syntax because that allows syntax that
is unsupported here.

This doesn't use `cargo-add`s parser because that is for version reqs.

I held off on reusing the parser from `cargo-yank` because they had
different type system needs and the level of duplication didn't seem
worth it (see Rule of Three).
2022-04-27 20:44:26 -05:00
Ed Page
2313edd4b2 fix(yank): Use '--version' like install
During the design conversations on cargo-add, we noticed that
`cargo-install` has a public flag `--version` and an invisible alias
`--vers` while `cargo-yank` has a public flag `--vers`.  This switches
`cargo-yank` to publicly use `--version` and have an invisible alias
`--vers`, making them consistent.

Completions are a best guess.
2022-04-19 16:45:13 -05:00
David Tolnay
b2b3bdeede
Consistently use crate::display_error on errors during drain 2022-02-17 13:59:06 -08:00
Ed Page
24defcbc14 fix(install): Keep v1 file formatting the same
Inspired by #10345, I looked for other cases where
`toml_edit::easy::to_string` is used (which outputs inline tables) to
see if we should switch to `to_string_pretty`.  The crates v1 file was
the only case I found.

As a side effect, we can no longer elide the empty `dev-dependencies`
table in published manifests.  This was the behavior before `toml_edit`,
so not much of a loss.
2022-01-31 10:42:05 -06:00
Weihang Lo
76301ebab9
Test: install bin with --path outside current workspace 2022-01-27 18:31:02 +08:00
Weihang Lo
d323ad672c
Test: install with path outside current workspace
Make up this test case to reflect the current incorrect behavior.
2022-01-27 18:31:01 +08:00
Ed Page
320c279f43 Port cargo from toml-rs to toml_edit
Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`
2022-01-13 09:27:27 -06:00
hi-rustin
6351472a80 Add --message-format for install
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-11-21 12:16:50 +08:00
David Tolnay
05f6604660
Swap out some outdated repo urls in documentation 2021-08-31 13:33:02 -07:00
Nipunn Koorapati
f9c2d04592 Factor into struct InstallablePackage 2021-08-19 09:57:53 -07:00
Weihang Lo
8c75e2ffa0
Update tests to use registry names 2021-07-22 00:50:30 +08:00
Joshua Nelson
9c7cc545d7 Combine rustc and cargo's diagnostic summaries
This works by introspecting rustc's error output, using the JSON format
to determine whether it's a warning or error, then skipping it
altogether if it's a summary of the diagnostics printed.

Before:

```
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: aborting due to 2 previous errors; 1 warning emitted
error: could not compile `wrong`

```

After:

```
$ cargo check --message-format short
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: could not compile `wrong` due to 2 previous errors; 1 warning emitted
```
2021-07-06 19:46:27 -04:00
hi-rustin
b3a1d0ceba Only testing on linux 2021-06-22 15:36:32 +08:00
hi-rustin
cb1a3f05f0 Detect incorrectly named cargo.toml for build 2021-06-22 15:31:28 +08:00
hi-rustin
a2f903275a Detect incorrectly named cargo.toml for install --path 2021-06-22 15:31:28 +08:00
hi-rustin
d9daaf7a84 Detect incorrectly named cargo.toml for install --git 2021-06-22 15:31:21 +08:00
hi-rustin
5e86dd455d Add more details when installing git repository errors 2021-06-14 14:41:49 +08:00
Eric Huss
9387a308f4 Fix cargo install with a semver metadata version. 2021-05-08 17:21:52 -07:00
Kornel
6977dee109 Explain cargo install is not for libraries 2021-03-03 17:10:56 +00:00
Horaci Macias
dab646eee0 Do not exit prematurely if anything failed installing.
https://github.com/rust-lang/cargo/issues/9180
2021-02-19 09:53:46 +01:00
CPerezz
b526fadca4
Impl warn for locked install withoud Cargo.lock
If we're installing in --locked mode and there's no `Cargo.lock` published
ie. the bin was published before https://github.com/rust-lang/cargo/pull/7026
the cargo install errors were not stating that it was due to the lack of
the `Cargo.lock` file. Instead, the error seemed completely unrelated.

Therefore, this tries to address this by adding a warn in the stderr
output.

Closes #9106
2021-01-30 01:09:16 +01:00
Eric Huss
b04c7fb849 Add suggestion for bad package id. 2021-01-22 13:38:53 -08:00
Weihang Lo
b9554f37ab
rustfmt 2020-10-28 02:57:22 +08:00
Weihang Lo
9d9c321c27
test: check cargo uninstall package opt with empty value 2020-10-28 02:46:20 +08:00
Eric Huss
6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
bors
f110fd9fc1 Auto merge of #8681 - weihanglo:fix/redundant-messsage-local-crate-install, r=ehuss
Sweep unrelated message from unnecessary workspace infromation

Resolves #8619

Only pass workspace information when the source is from a local crate installation.
2020-09-10 18:40:48 +00:00
Weihang Lo
a527caa248
test: check stderr containment explicitly 2020-09-10 07:57:57 +08:00
Weihang Lo
45cfd0cd12
Fix formatting 2020-09-10 00:26:30 +08:00
Weihang Lo
71cae39de0
Test for crate installation without emitting messages from cwd 2020-09-10 00:20:35 +08:00
bors
875e012325 Auto merge of #8655 - camelid:patch-1, r=ehuss
Lowercase and remove periods in error messages for consistency
2020-09-08 20:17:21 +00:00
Camelid
82c834cec2 Update tests 2020-09-07 10:57:00 -07:00
Philipp Oppermann
c5d8dcb323 Reload unstable table from config file in reload_rooted_at 2020-08-27 11:07:53 +02:00
bishtpawan
3952fdb223 Refactor code and resolve PR comments 2020-08-05 17:46:33 +05:30
bishtpawan
dd654d5576 Add pattern match for yank check and updated corresponding test cases 2020-08-05 17:31:56 +05:30
bishtpawan
844cde203f Add test case for yank validation check 2020-08-05 17:31:56 +05:30
bl2e
538d925920 Fix post-execution path checks to be compatible with Windows 2020-06-20 23:37:56 -07:00
bl2e
bb3754276a Fix test compatibility for Windows 2020-06-20 23:01:35 -07:00
bl2e
1f2de1e0a7 Add test for cargo install option --target-dir 2020-06-20 17:50:20 -07:00
kellda
1e0d38061c Add test for cargo install --index 2020-06-10 15:26:26 +00:00