Clap: Panic with structopt `requires` magical methods

Created on 10 Jun 2020  路  12Comments  路  Source: clap-rs/clap

Make sure you completed the following tasks

  • [x] Searched the discussions
  • [x] Searched the closes issues

Code

#[derive(Debug, StructOpt)]
struct Opt {
    #[structopt(long)]
    first: Option<u64>,

    #[structopt(long, requires("third"))]
    criterion: Option<String>,

    #[structopt(long, requires("second"))]
    u: Option<u64>,
}

fn main() {
  let opt = Opt::from_args();
  println!("{:?}", opt);
}
### Steps to reproduce the issue 1. Run `cargo run -- --first 3 --criterion foo` 2. PROFIT!!! ### Version * **Rust**: rustc 1.43.1 (8d69840ab 2020-05-04) * **Clap**: 2.33.1 * **StructOpt**: 0.3.14 ### Actual Behavior Summary When you run this code, it panics. ### Expected Behavior Summary I would expect it to maybe generate some error saying what I've done wrong (could be that I've added `required("second")` where "second" does not exist, or maybe that I have some cyclic requirements for two fields?). ### Additional context Add any other context about the problem here. ### Debug output
Debug Output


DEBUG:clap:Parser::propagate_settings: self=flex_logging, g_settings=AppFlags(
    (empty),
)
DEBUG:clap:Parser::get_matches_with;
DEBUG:clap:Parser::create_help_and_version;
DEBUG:clap:Parser::create_help_and_version: Building --help
DEBUG:clap:Parser::create_help_and_version: Building --version
DEBUG:clap:Parser::get_matches_with: Begin parsing '"--first"' ([45, 45, 102, 105, 114, 115, 116])
DEBUG:clap:Parser::is_new_arg:"--first":NotFound
DEBUG:clap:Parser::is_new_arg: arg_allows_tac=false
DEBUG:clap:Parser::is_new_arg: -- found
DEBUG:clap:Parser::is_new_arg: starts_new_arg=true
DEBUG:clap:Parser::possible_subcommand: arg="--first"
DEBUG:clap:Parser::get_matches_with: possible_sc=false, sc=None
DEBUG:clap:ArgMatcher::process_arg_overrides:None;
DEBUG:clap:Parser::parse_long_arg;
DEBUG:clap:Parser::parse_long_arg: Does it contain '='...No
DEBUG:clap:OptBuilder::fmt:first
DEBUG:clap:Parser::parse_long_arg: Found valid opt '--first '
DEBUG:clap:Parser::parse_opt; opt=first, val=None
DEBUG:clap:Parser::parse_opt; opt.settings=ArgFlags(EMPTY_VALS | TAKES_VAL | DELIM_NOT_SET)
DEBUG:clap:Parser::parse_opt; Checking for val...None
DEBUG:clap:ArgMatcher::inc_occurrence_of: arg=first
DEBUG:clap:ArgMatcher::inc_occurrence_of: first instance
DEBUG:clap:Parser::groups_for_arg: name=first
DEBUG:clap:Parser::groups_for_arg: No groups defined
DEBUG:clap:Parser::parse_opt: More arg vals required...
DEBUG:clap:Parser:get_matches_with: After parse_long_arg Opt("first")
DEBUG:clap:Parser::get_matches_with: Begin parsing '"3"' ([51])
DEBUG:clap:Parser::is_new_arg:"3":Opt("first")
DEBUG:clap:Parser::is_new_arg: arg_allows_tac=false
DEBUG:clap:Parser::is_new_arg: probably value
DEBUG:clap:Parser::is_new_arg: starts_new_arg=false
DEBUG:clap:Parser::add_val_to_arg; arg=first, val="3"
DEBUG:clap:Parser::add_val_to_arg; trailing_vals=false, DontDelimTrailingVals=false
DEBUG:clap:Parser::add_single_val_to_arg;
DEBUG:clap:Parser::add_single_val_to_arg: adding val..."3"
DEBUG:clap:Parser::groups_for_arg: name=first
DEBUG:clap:Parser::groups_for_arg: No groups defined
DEBUG:clap:ArgMatcher::needs_more_vals: o=first
DEBUG:clap:Parser::get_matches_with: Begin parsing '"--criterion"' ([45, 45, 99, 114, 105, 116, 101, 114, 105, 111, 110])
DEBUG:clap:Parser::is_new_arg:"--criterion":ValuesDone
DEBUG:clap:Parser::possible_subcommand: arg="--criterion"
DEBUG:clap:Parser::get_matches_with: possible_sc=false, sc=None
DEBUG:clap:ArgMatcher::process_arg_overrides:Some("first");
DEBUG:clap:Parser::parse_long_arg;
DEBUG:clap:Parser::parse_long_arg: Does it contain '='...No
DEBUG:clap:OptBuilder::fmt:criterion
DEBUG:clap:Parser::parse_long_arg: Found valid opt '--criterion '
DEBUG:clap:Parser::parse_opt; opt=criterion, val=None
DEBUG:clap:Parser::parse_opt; opt.settings=ArgFlags(EMPTY_VALS | TAKES_VAL | DELIM_NOT_SET)
DEBUG:clap:Parser::parse_opt; Checking for val...None
DEBUG:clap:ArgMatcher::inc_occurrence_of: arg=criterion
DEBUG:clap:ArgMatcher::inc_occurrence_of: first instance
DEBUG:clap:Parser::groups_for_arg: name=criterion
DEBUG:clap:Parser::groups_for_arg: No groups defined
DEBUG:clap:Parser::parse_opt: More arg vals required...
DEBUG:clap:Parser:get_matches_with: After parse_long_arg Opt("criterion")
DEBUG:clap:Parser::get_matches_with: Begin parsing '"age"' ([97, 103, 101])
DEBUG:clap:Parser::is_new_arg:"age":Opt("criterion")
DEBUG:clap:Parser::is_new_arg: arg_allows_tac=false
DEBUG:clap:Parser::is_new_arg: probably value
DEBUG:clap:Parser::is_new_arg: starts_new_arg=false
DEBUG:clap:Parser::add_val_to_arg; arg=criterion, val="age"
DEBUG:clap:Parser::add_val_to_arg; trailing_vals=false, DontDelimTrailingVals=false
DEBUG:clap:Parser::add_single_val_to_arg;
DEBUG:clap:Parser::add_single_val_to_arg: adding val..."age"
DEBUG:clap:Parser::groups_for_arg: name=criterion
DEBUG:clap:Parser::groups_for_arg: No groups defined
DEBUG:clap:ArgMatcher::needs_more_vals: o=criterion
DEBUG:clap:ArgMatcher::process_arg_overrides:Some("criterion");
DEBUG:clap:Parser::remove_overrides:[];
DEBUG:clap:Validator::validate;
DEBUG:clap:Parser::add_defaults;
DEBUG:clap:Parser::add_defaults:iter:first: doesn't have conditional defaults
DEBUG:clap:Parser::add_defaults:iter:first: doesn't have default vals
DEBUG:clap:Parser::add_defaults:iter:criterion: doesn't have conditional defaults
DEBUG:clap:Parser::add_defaults:iter:criterion: doesn't have default vals
DEBUG:clap:Parser::add_defaults:iter:u: doesn't have conditional defaults
DEBUG:clap:Parser::add_defaults:iter:u: doesn't have default vals
DEBUG:clap:Validator::validate_blacklist;
DEBUG:clap:Validator::validate_blacklist:iter:first;
DEBUG:clap:Parser::groups_for_arg: name=first
DEBUG:clap:Parser::groups_for_arg: No groups defined
DEBUG:clap:Validator::validate_blacklist:iter:criterion;
DEBUG:clap:Parser::groups_for_arg: name=criterion
DEBUG:clap:Parser::groups_for_arg: No groups defined
DEBUG:clap:Validator::validate_required: required=[];
DEBUG:clap:Validator::validate_matched_args;
DEBUG:clap:Validator::validate_matched_args:iter:first: vals=[
    "3",
]
DEBUG:clap:Validator::validate_arg_num_vals:first
DEBUG:clap:Validator::validate_arg_values: arg="first"
DEBUG:clap:Validator::validate_arg_values: checking validator...good
DEBUG:clap:Validator::validate_arg_requires:first;
DEBUG:clap:Validator::validate_arg_num_occurs: a=first;
DEBUG:clap:Validator::validate_matched_args:iter:criterion: vals=[
    "age",
]
DEBUG:clap:Validator::validate_arg_num_vals:criterion
DEBUG:clap:Validator::validate_arg_values: arg="criterion"
DEBUG:clap:Validator::validate_arg_values: checking validator...good
DEBUG:clap:Validator::validate_arg_requires:criterion;
DEBUG:clap:Validator::missing_required_error: extra=Some("third")
DEBUG:clap:Parser::color;
DEBUG:clap:Parser::color: Color setting...Auto
DEBUG:clap:is_a_tty: stderr=true
DEBUG:clap:Validator::missing_required_error: reqs=[
    "third",
]
DEBUG:clap:usage::get_required_usage_from: reqs=["third"], extra=Some("third")
DEBUG:clap:usage::get_required_usage_from: after init desc_reqs=["third"]
DEBUG:clap:usage::get_required_usage_from: no more children
DEBUG:clap:usage::get_required_usage_from: final desc_reqs=["third"]
DEBUG:clap:usage::get_required_usage_from: args_in_groups=[]
DEBUG:clap:usage::get_required_usage_from:iter:third:


bug

All 12 comments

What's the panic message you are getting?

As a general rule, structopt issues should be reported to the structopt repo, not here. But I think this particular issue does belong here more that there.

Nitpick: requires is not magical method. It's a raw method.

If I understood the report correctly, @pscott wants derive to perform a number of additional sanity checks, like "requires refers to an existing field" or "required does not make much sense with option".

That would be wonderful indeed, and both structopt and clap_derive do perform a number - rather small number - of checks whenever possible, but for now we are limited to checks that require only the knowledge of the current field (one the #[clap()] attr is applied to). Cross field checks are next to impossible due to derive's internal one-pass architecture. This is not one of those limitations you'd call fundamental, no, but in order to pull this off, the derive essentially has to be rewritten from scratch, preferably to some sort of "AST + passes" based implementation.

It's a question of manpower - lack thereof. We will put it on the list, but it's probably going to take a while before we - or somebody else - will get to it.

I have some cyclic requirements for two fields

This is totally legitimate requirement. It simply means that "second" and "third" should either be present both, or not at all.

@pksunkara Sorry I forgot to add it in OP: thread 'main' panicked at 'Fatal internal error. Please consider filing a bug report at https://github.com/clap-rs/clap/issues'

@CreepySkeleton

As a general rule, structopt issues should be reported to the structopt repo, not here. But I think this particular issue does belong here more that there.

Indeed I thought that this particular issue belonged here, as it looked like it had little to do with structopt. If I'm wrong, please let me know :)

If I understood the report correctly, @pscott wants derive to perform a number of additional sanity checks, like "requires refers to an existing field" or "required does not make much sense with option".

So to be totally fair, this code wasn't intended. I originally had the fields first, second, third. I then wanted to change the names of second and third to criterion and u, but I forgot to change the names used in the requires raw method ! :P

Sorry to disappoint you, it's much more simple than what you thought it was ^^'

I was just surprised it would panic at runtime, even if my code is incorrect. I understand now that having requires("criterion") and requires("u") is legitimate and does not induce any cyclic requirements. However, I'm still surprised as to why it panics and as to why it doesn't panic with at least a clearer message for the user! :)

Please let me know if I'm missing something, would love to learn more about it!

Yeah this is fixed in master branch. It has a clear message for panic and only panics during development

... I have the same issue with actually matching names in the requiresmethod:

use std::path::PathBuf;

use structopt::StructOpt;

#[derive(Debug, StructOpt)]
struct Opt {
    #[structopt(short, long, requires("blog_url"))]
    rss_feed_file: Option<PathBuf>,
    #[structopt(short, long)]
    blog_url: Option<String>,
}

fn main() {
    let opt = Opt::from_args();
    println!("{:?}", opt);
}
Invoking with `cargo run -- -r test` produces a panic:
thread 'main' panicked at 'Fatal internal error. Please consider filing a bug report at https://github.com/clap-rs/clap/issues', /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/usage.rs:475:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Full backtrace:
RUST_BACKTRACE=full cargo run -- -r test
thread 'main' panicked at 'Fatal internal error. Please consider filing a bug report at https://github.com/clap-rs/clap/issues', /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/usage.rs:475:22
stack backtrace:
   0:     0x55aededccd35 - backtrace::backtrace::libunwind::trace::h34afbfad7fd770fc
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x55aededccd35 - backtrace::backtrace::trace_unsynchronized::h460d522b1619a600
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x55aededccd35 - std::sys_common::backtrace::_print_fmt::ha45fac10086813b4
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x55aededccd35 - ::fmt::hde84f63fcfd0e6de
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x55aededec13c - core::fmt::write::h540ac4a6a1232abc
                               at src/libcore/fmt/mod.rs:1076
   5:     0x55aededca6a2 - std::io::Write::write_fmt::hc344eafd6e850b4d
                               at src/libstd/io/mod.rs:1537
   6:     0x55aededcf1c0 - std::sys_common::backtrace::_print::h4db88ff15cb5d61d
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x55aededcf1c0 - std::sys_common::backtrace::print::h5fc39e1b1f610bd3
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x55aededcf1c0 - std::panicking::default_hook::{{closure}}::h59e55edacb1d974a
                               at src/libstd/panicking.rs:198
   9:     0x55aededcef0c - std::panicking::default_hook::heee4c8016dfbf328
                               at src/libstd/panicking.rs:217
  10:     0x55aededcf803 - std::panicking::rust_panic_with_hook::h8405b6301c79fb5a
                               at src/libstd/panicking.rs:526
  11:     0x55aededcf3fb - rust_begin_unwind
                               at src/libstd/panicking.rs:437
  12:     0x55aededeb541 - core::panicking::panic_fmt::h78830ea6a34e7206
                               at src/libcore/panicking.rs:85
  13:     0x55aededeb2d3 - core::option::expect_failed::hfc0519cb1ecb957f
                               at src/libcore/option.rs:1261
  14:     0x55aedecea90e - core::option::Option::expect::h67095d756119bbba
                               at /home/caleb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/option.rs:344
  15:     0x55aedecdecca - clap::app::usage::get_required_usage_from::{{closure}}::hfb8961eef91fc572
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/usage.rs:473
  16:     0x55aedece2743 - core::option::Option::unwrap_or_else::h8243bc0015b384dc
                               at /home/caleb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/option.rs:425
  17:     0x55aedecdd522 - clap::app::usage::get_required_usage_from::h83fdee3a440a9739
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/usage.rs:470
  18:     0x55aeded72c29 - clap::app::validator::Validator::missing_required_error::h8f048a06a54ccaed
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/validator.rs:561
  19:     0x55aeded709b3 - clap::app::validator::Validator::validate_arg_requires::ha543a9416a04fff9
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/validator.rs:445
  20:     0x55aeded6d4b2 - clap::app::validator::Validator::validate_matched_args::hf290b7454c17fc8d
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/validator.rs:293
  21:     0x55aeded68053 - clap::app::validator::Validator::validate::h6891da2788ad062b
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/validator.rs:80
  22:     0x55aedec967f9 - clap::app::parser::Parser::get_matches_with::hc41946877b7f6d33
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/parser.rs:1249
  23:     0x55aeded73f05 - clap::app::App::get_matches_from_safe_borrow::h146924c805e28157
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/mod.rs:1639
  24:     0x55aeded734b2 - clap::app::App::get_matches_from::h0e410ccdc9e2086f
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/mod.rs:1519
  25:     0x55aeded733fe - clap::app::App::get_matches::h1a168dc60042ef04
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/mod.rs:1460
  26:     0x55aedec88c82 - structopt::StructOpt::from_args::h06f952e3169397f8
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-0.3.15/src/lib.rs:1086
  27:     0x55aedec86a31 - structopt_test::main::hd2ada87aaf0e4a68
                               at src/main.rs:14
  28:     0x55aedec8997b - std::rt::lang_start::{{closure}}::h944262ebf94246fc
                               at /home/caleb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  29:     0x55aededcfbd3 - std::rt::lang_start_internal::{{closure}}::h7cea099ad4edf1eb
                               at src/libstd/rt.rs:52
  30:     0x55aededcfbd3 - std::panicking::try::do_call::h42d93372c44025d2
                               at src/libstd/panicking.rs:348
  31:     0x55aededcfbd3 - std::panicking::try::hb47a4182362d3341
                               at src/libstd/panicking.rs:325
  32:     0x55aededcfbd3 - std::panic::catch_unwind::h2afcfbf3125915b4
                               at src/libstd/panic.rs:394
  33:     0x55aededcfbd3 - std::rt::lang_start_internal::h4f696727fe904f48
                               at src/libstd/rt.rs:51
  34:     0x55aedec89957 - std::rt::lang_start::h8d79c768d1bafecd
                               at /home/caleb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  35:     0x55aedec8712a - main
  36:     0x7f853fa17002 - __libc_start_main
  37:     0x55aedec8616e - _start
  38:                0x0 - 


Same behavior on latest stable...

latest stable backtrace

thread 'main' panicked at 'Fatal internal error. Please consider filing a bug report at https://github.com/clap-rs/clap/issues', /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/usage.rs:473:17
stack backtrace:
   0:     0x55d509f40625 - backtrace::backtrace::libunwind::trace::h396c07d2071b43af
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x55d509f40625 - backtrace::backtrace::trace_unsynchronized::h7aa0e4bb23d9c158
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x55d509f40625 - std::sys_common::backtrace::_print_fmt::hd15ac5d4adcd355b
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x55d509f40625 - ::fmt::hec5354be8ccc3ecc
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x55d509f5fc4c - core::fmt::write::h3d34909eeb4f225b
                               at src/libcore/fmt/mod.rs:1076
   5:     0x55d509f3e383 - std::io::Write::write_fmt::h1da287b3de55ed16
                               at src/libstd/io/mod.rs:1537
   6:     0x55d509f42b80 - std::sys_common::backtrace::_print::h4d206838e1ace354
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x55d509f42b80 - std::sys_common::backtrace::print::h1f778e9940ee5977
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x55d509f42b80 - std::panicking::default_hook::{{closure}}::h704403a56cbf5783
                               at src/libstd/panicking.rs:198
   9:     0x55d509f428cc - std::panicking::default_hook::ha4567a10dec4ef8d
                               at src/libstd/panicking.rs:218
  10:     0x55d509f431b7 - std::panicking::rust_panic_with_hook::h88a1f16ec8a7bb20
                               at src/libstd/panicking.rs:486
  11:     0x55d509f42dbb - rust_begin_unwind
                               at src/libstd/panicking.rs:388
  12:     0x55d509f5f051 - core::panicking::panic_fmt::hbddb7fe6f399b81a
                               at src/libcore/panicking.rs:101
  13:     0x55d509f5ede3 - core::option::expect_failed::hfee7773bbf1a340a
                               at src/libcore/option.rs:1264
  14:     0x55d509e57e7a - core::option::Option::expect::h3ae5eb54fcd32a4b
                               at /home/caleb/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/option.rs:349
  15:     0x55d509e68ffa - clap::app::usage::get_required_usage_from::{{closure}}::h14589074bdddcb98
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/usage.rs:473
  16:     0x55d509e4f9b3 - core::option::Option::unwrap_or_else::h9de54e7ee81b3a77
                               at /home/caleb/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/option.rs:430
  17:     0x55d509e67842 - clap::app::usage::get_required_usage_from::h6a1dbf5f0647e391
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/usage.rs:470
  18:     0x55d509ee6379 - clap::app::validator::Validator::missing_required_error::he158fcc271311c0b
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/validator.rs:561
  19:     0x55d509ee3cd3 - clap::app::validator::Validator::validate_arg_requires::h38235d93334f4cd7
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/validator.rs:445
  20:     0x55d509ee0c40 - clap::app::validator::Validator::validate_matched_args::h5d243a77e6ad12a2
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/validator.rs:293
  21:     0x55d509edb6ef - clap::app::validator::Validator::validate::hab0eb75ba41c758a
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/validator.rs:80
  22:     0x55d509e05828 - clap::app::parser::Parser::get_matches_with::hfbf6d633d5d8b722
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/parser.rs:1249
  23:     0x55d509ee7655 - clap::app::App::get_matches_from_safe_borrow::h8eeeda40d611a879
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/mod.rs:1639
  24:     0x55d509ee6c02 - clap::app::App::get_matches_from::h3d48e153571e8629
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/mod.rs:1519
  25:     0x55d509ee6b4e - clap::app::App::get_matches::hafcff1c6f12f3bfd
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.1/src/app/mod.rs:1460
  26:     0x55d509df7ac2 - structopt::StructOpt::from_args::h81aa893ad151c5b3
                               at /home/caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-0.3.15/src/lib.rs:1086
  27:     0x55d509df5ab1 - structopt_test::main::hb81c244a1f45b78c
                               at src/main.rs:14
  28:     0x55d509df861b - std::rt::lang_start::{{closure}}::h429601eba475d644
                               at /home/caleb/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  29:     0x55d509f43588 - std::rt::lang_start_internal::{{closure}}::h6d21eebfa4beaf70
                               at src/libstd/rt.rs:52
  30:     0x55d509f43588 - std::panicking::try::do_call::h560a27b87db38b9c
                               at src/libstd/panicking.rs:297
  31:     0x55d509f43588 - std::panicking::try::h453d4afd696011f9
                               at src/libstd/panicking.rs:274
  32:     0x55d509f43588 - std::panic::catch_unwind::h211d02671f23030f
                               at src/libstd/panic.rs:394
  33:     0x55d509f43588 - std::rt::lang_start_internal::h464df2bbf46c7e7c
                               at src/libstd/rt.rs:51
  34:     0x55d509df85f7 - std::rt::lang_start::ha5ace468fc4e7340
                               at /home/caleb/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  35:     0x55d509df61aa - main
  36:     0x7fcc6c117002 - __libc_start_main
  37:     0x55d509df516e - _start
  38:                0x0 - 

@c-x-berger blog_url is renamed to blog-url by default, so you need to use requires("blog-url")

Ah. That... makes sense, though it's still frustrating.

This bug is still present, and it's actually quite frustrating to not know _where_ the error comes from :/

@ClementNerma What clap version are you using? And please show us code.

@CreepySkeleton Shouldn't this actually provide a better message because of our validations?

@pksunkara Nope. Incidentally, https://github.com/clap-rs/clap/pull/2000 fixes exactly that. (This is one of its manifestations.)

I was wrong. The panic message is clear now. I think the beta doesn't have these checks released.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kbknapp picture kbknapp  路  16Comments

Licenser picture Licenser  路  25Comments

casey picture casey  路  25Comments

Walther picture Walther  路  22Comments

ruabmbua picture ruabmbua  路  17Comments