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

install fails earlier when no binaries can be found #9576

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bin/cargo/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
if let CompileFilter::Default { .. } = opts.filter {
opts.filter = CompileFilter::Only {
all_targets: true,
warn_unmatched: true,
lib: LibRule::Default,
bins: FilterRule::All,
examples: FilterRule::All,
Expand Down
14 changes: 13 additions & 1 deletion src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::command_prelude::*;

use cargo::core::{GitReference, SourceId};
use cargo::ops;
use cargo::ops::{self, CompileFilter, FilterRule, LibRule};
use cargo::util::IntoUrl;

pub fn cli() -> App {
Expand Down Expand Up @@ -137,6 +137,18 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
compile_opts.build_config.requested_profile =
args.get_profile_name(config, "release", ProfileChecking::Custom)?;

if !compile_opts.filter.is_specific() {
compile_opts.filter = CompileFilter::Only {
all_targets: false,
warn_unmatched: false,
lib: LibRule::False,
bins: FilterRule::All,
examples: FilterRule::none(),
benches: FilterRule::none(),
tests: FilterRule::none(),
}
}

if args.is_present("list") {
ops::install_list(root, config)?;
} else {
Expand Down
9 changes: 7 additions & 2 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ pub enum CompileFilter {
},
Only {
all_targets: bool,
warn_unmatched: bool,
lib: LibRule,
bins: FilterRule,
examples: FilterRule,
Expand Down Expand Up @@ -714,6 +715,7 @@ impl CompileFilter {
{
CompileFilter::Only {
all_targets: false,
warn_unmatched: true,
lib: rule_lib,
bins: rule_bins,
examples: rule_exms,
Expand All @@ -730,6 +732,7 @@ impl CompileFilter {
pub fn new_all_targets() -> CompileFilter {
CompileFilter::Only {
all_targets: true,
warn_unmatched: true,
lib: LibRule::Default,
bins: FilterRule::All,
examples: FilterRule::All,
Expand Down Expand Up @@ -1003,6 +1006,7 @@ fn generate_targets(
ref examples,
ref tests,
ref benches,
..
} => {
if *lib != LibRule::False {
let mut libs = Vec::new();
Expand Down Expand Up @@ -1158,14 +1162,15 @@ fn unmatched_target_filters(
) -> CargoResult<()> {
if let CompileFilter::Only {
all_targets,
lib: _,
warn_unmatched,
ref bins,
ref examples,
ref tests,
ref benches,
..
} = *filter
{
if units.is_empty() {
if units.is_empty() && warn_unmatched {
let mut filters = String::new();
let mut miss_count = 0;

Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ fn no_binaries() {
.with_status(101)
.with_stderr(
"\
[ERROR] there is nothing to install in `foo v0.0.1 ([..])`, because it has no binaries[..]
[..]
[..]",
[..]
[ERROR] no binaries are available for install using the selected features",
)
.run();
}
Expand Down