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

'Cannot parse version' when try to debugging dfx executable #3625

Open
q2333gh opened this issue Feb 29, 2024 · 1 comment
Open

'Cannot parse version' when try to debugging dfx executable #3625

q2333gh opened this issue Feb 29, 2024 · 1 comment
Labels
needs-triage This ticket needs investigation.

Comments

@q2333gh
Copy link
Contributor

q2333gh commented Feb 29, 2024

I tried the following:

  1. build
git clone https://github.com/dfinity/sdk.git 
cd sdk
cargo build 
  1. debug:
    in vscode luanch.json:
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "canister_upgrader debug",
      "type": "lldb",
      "request": "launch",
      "program": "${workspaceFolder}/target/debug/dfx",
      // simulate: `dfx deploy backend --verbose`
      "args": ["deploy", "backend","--verbose"],
      // a folder gen by : `dfx new test_canister --type=rust`
      "cwd": "/home/btwl/code/ic/test_canister/",
      "stopOnEntry": true,
      "env": { "RUST_BACKTRACE": "1", "DFX_VERSION": "0.17.0", "CARGO_PKG_VERSION": "0.17.0"}
    }
  ]
}

I expected to see this happen:
set a breakpoint at src/dfx/src/main.rs and program pause at breakpoint.

Instead, this happened:

thread 'main' panicked at src/dfx/src/config/mod.rs:9:51:
Cannot parse version.: Error("unexpected character '+' after major version number")
stack backtrace:
   0: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
   3: core::result::Result<T,E>::expect
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1034:23
   4: <dfx::config::VERSION as core::ops::deref::Deref>::deref::__static_ref_initialize
             at ./src/dfx/src/config/mod.rs:9:9
   5: core::ops::function::FnOnce::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
   6: lazy_static::lazy::Lazy<T>::get::{{closure}}
             at /home/btwl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:31:29
   7: std::sync::once::Once::call_once::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sync/once.rs:149:41
   8: std::sys_common::once::futex::Once::call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/once/futex.rs:124:21
   9: std::sync::once::Once::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sync/once.rs:149:9
  10: lazy_static::lazy::Lazy<T>::get
             at /home/btwl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:30:9
  11: <dfx::config::VERSION as core::ops::deref::Deref>::deref::__stability
             at /home/btwl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/lib.rs:142:21
  12: <dfx::config::VERSION as core::ops::deref::Deref>::deref
             at /home/btwl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/lib.rs:144:17
  13: dfx::config::dfx_version
             at ./src/dfx/src/config/mod.rs:20:5
  14: dfx::get_args_altered_for_extension_run
             at ./src/dfx/src/main.rs:166:36
  15: dfx::main
             at ./src/dfx/src/main.rs:185:16
  16: core::ops::function::FnOnce::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Meta

dfx --version: latest github pull. 2024-2-29 . should be 0.17.0

 0.17.0
@q2333gh q2333gh added the needs-triage This ticket needs investigation. label Feb 29, 2024
@q2333gh q2333gh changed the title 'Cannot parse version' when try to debugging dfx binary 'Cannot parse version' when try to debugging dfx executable Feb 29, 2024
@q2333gh
Copy link
Contributor Author

q2333gh commented Feb 29, 2024

fixed by modding the code :

lazy_static! {
    // This expect cannot happen, we make sure that CARGO_PKG_VERSION is correct.
    // static ref VERSION: Version =
    //     Version::parse(env!("CARGO_PKG_VERSION")).expect("Cannot parse version.");

    // static ref VERSION_STR: String = env!("CARGO_PKG_VERSION").to_string();
    static ref VERSION: Version = Version::parse("0.17.0").expect("Cannot parse version.");
    static ref VERSION_STR: String = "0.17.0".to_string();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage This ticket needs investigation.
Projects
None yet
Development

No branches or pull requests

1 participant