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

[Bug] Failed to output json. #1170

Open
Adamska1008 opened this issue Sep 21, 2024 · 1 comment
Open

[Bug] Failed to output json. #1170

Adamska1008 opened this issue Sep 21, 2024 · 1 comment

Comments

@Adamska1008
Copy link

Adamska1008 commented Sep 21, 2024

Environment

Version

>= v13.0.0-alpha.2

OS

wsl

Description

when running cargo run -- --output json, it shows:

thread 'main' panicked at src/cli.rs:296:30:
Mismatch between definition and access of `output`. Could not downcast to tokei::input::Format, need to downcast to alloc::string::String

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Steps to Reproduce

checkout

git checkout v13.0.0-alpha.2 # or any tags later

run

cargo run -- --output json

Additional Info

I can see some warnings at compiling

warning: `/home/adamska/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
warning: `/home/adamska/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:24:23
    |
24  |                   #[cfg(feature = $feature)] extern crate $krate;
    |                         ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: `#[warn(unexpected_cfgs)]` on by default
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:36:23
    |
36  |                   #[cfg(feature = $feature)] $variant
    |                         ^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:36:23
    |
36  |                   #[cfg(feature = $feature)] $variant
    |                         ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:46:31
    |
46  |                           #[cfg(feature = $feature)] stringify!($name)
    |                                 ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:66:35
    |
66  |                           #[cfg(not(feature = $feature))] stringify!($name)
    |                                     ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:82:27
    |
82  |                       #[cfg(feature = $feature)]
    |                             ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:105:31
    |
105 |                           #[cfg(feature = $feature)] Format::$variant => {
    |                                 ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:122:35
    |
122 |                               #[cfg(feature = $feature)]
    |                                     ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:125:39
    |
125 |                               #[cfg(not(feature = $feature))]
    |                                         ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `tokei` (bin "tokei") generated 9 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s

I guess it's related to the issue but don't know how to handle it.

@Zyx-A
Copy link

Zyx-A commented Sep 25, 2024

+1

OS

$ cat /etc/os-release 
PRETTY_NAME="Deepin 23"
NAME="Deepin"
VERSION_ID="23"
VERSION="23"
ID=deepin
HOME_URL="https://www.deepin.org/"
BUG_REPORT_URL="https://bbs.deepin.org"
VERSION_CODENAME=beige

$ uname -r
6.9.6-amd64-desktop-rolling

Log

$ RUST_BACKTRACE=full tokei --output json
thread 'main' panicked at /home/User/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.15/src/parser/error.rs:32:9:
Mismatch between definition and access of `output`. Could not downcast to TypeId { t: 207046535542829422490669049113020495836 }, need to downcast to TypeId { t: 298976536365314247976339737694047053527 }

stack backtrace:
   0:     0x5654888220ed - std::backtrace_rs::backtrace::libunwind::trace::hef57b64ea6437390
                               at /usr/src/packages/BUILD/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x5654888220ed - std::backtrace_rs::backtrace::trace_unsynchronized::h69171217439ab1e4
                               at /usr/src/packages/BUILD/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5654888220ed - std::sys_common::backtrace::_print_fmt::hee818f0598d5d5c9
                               at /usr/src/packages/BUILD/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x5654888220ed - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2ec833a9ded8dc4e
                               at /usr/src/packages/BUILD/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5654886cae70 - core::fmt::rt::Argument::fmt::h58b76280a1617793
                               at /usr/src/packages/BUILD/library/core/src/fmt/rt.rs:142:9
   5:     0x5654886cae70 - core::fmt::write::h1a501565478054da
                               at /usr/src/packages/BUILD/library/core/src/fmt/mod.rs:1120:17
   6:     0x5654888162ed - std::io::Write::write_fmt::h01f35b8e7cb591d9
                               at /usr/src/packages/BUILD/library/std/src/io/mod.rs:1810:15
   7:     0x565488821e84 - std::sys_common::backtrace::_print::h828add582fee1be6
                               at /usr/src/packages/BUILD/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x565488821e84 - std::sys_common::backtrace::print::h9c70023e40f34bcb
                               at /usr/src/packages/BUILD/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x565488802270 - std::panicking::default_hook::{{closure}}::h8b98b96ff2295b83
  10:     0x565488801f39 - std::panicking::default_hook::hd987d973483cd784
                               at /usr/src/packages/BUILD/library/std/src/panicking.rs:292:9
  11:     0x5654888025ef - std::panicking::rust_panic_with_hook::h99c996d3ba17c8f1
                               at /usr/src/packages/BUILD/library/std/src/panicking.rs:779:13
  12:     0x56548882266a - std::panicking::begin_panic_handler::{{closure}}::hda2a41d1763db297
                               at /usr/src/packages/BUILD/library/std/src/panicking.rs:657:13
  13:     0x565488822326 - std::sys_common::backtrace::__rust_end_short_backtrace::h0fd0e52d6bdaa627
                               at /usr/src/packages/BUILD/library/std/src/sys_common/backtrace.rs:171:18
  14:     0x565488802340 - rust_begin_unwind
                               at /usr/src/packages/BUILD/library/std/src/panicking.rs:645:5
  15:     0x565488633f95 - core::panicking::panic_fmt::hac1099e8d4c293b3
                               at /usr/src/packages/BUILD/library/core/src/panicking.rs:72:14
  16:     0x5654888cba83 - tokei::cli::Cli::from_args::h33c579ab2f518714
  17:     0x5654888dbd85 - tokei::main::h43aacd786e2f01a9
  18:     0x5654888ce513 - std::sys_common::backtrace::__rust_begin_short_backtrace::h4eee52fa0ab40a06
  19:     0x5654888c264f - std::rt::lang_start::{{closure}}::h47252933fa2c3d6b
  20:     0x565488807f61 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hbdf79115ab297954
                               at /usr/src/packages/BUILD/library/core/src/ops/function.rs:284:13
  21:     0x565488807f61 - std::panicking::try::do_call::h859acc5aaa71e139
                               at /usr/src/packages/BUILD/library/std/src/panicking.rs:552:40
  22:     0x565488807f61 - std::panicking::try::h48fd1fa18a69de10
                               at /usr/src/packages/BUILD/library/std/src/panicking.rs:516:19
  23:     0x565488807f61 - std::panic::catch_unwind::h517cab8a2cd614af
                               at /usr/src/packages/BUILD/library/std/src/panic.rs:142:14
  24:     0x565488807f61 - std::rt::lang_start_internal::{{closure}}::h730784f21e5dfa55
                               at /usr/src/packages/BUILD/library/std/src/rt.rs:148:48
  25:     0x565488807f61 - std::panicking::try::do_call::hc13cc6ddffa52b46
                               at /usr/src/packages/BUILD/library/std/src/panicking.rs:552:40
  26:     0x565488807f61 - std::panicking::try::h5b5b31fa089cc8f9
                               at /usr/src/packages/BUILD/library/std/src/panicking.rs:516:19
  27:     0x565488807f61 - std::panic::catch_unwind::h9b1a52e0b2f78218
                               at /usr/src/packages/BUILD/library/std/src/panic.rs:142:14
  28:     0x565488807f61 - std::rt::lang_start_internal::h5fde120f6592570f
                               at /usr/src/packages/BUILD/library/std/src/rt.rs:148:20
  29:     0x5654888deeb5 - main
  30:     0x7f8f6185eb8a - <unknown>
  31:     0x7f8f6185ec45 - __libc_start_main
  32:     0x565488648b91 - _start
  33:                0x0 - <unknown>
已放弃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants