nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.2k stars 40 forks source link

invalid or unknown remote ssh hostkey #232

Open dsully opened 1 year ago

dsully commented 1 year ago

I'm getting a failure when using cargo-update, which has worked fine until recently:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -17, klass: 23, message: "invalid or unknown remote ssh hostkey" }', /Users/dsully/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-update-13.0.1/src/ops/mod.rs:496:149
stack backtrace:
   0:        0x1006ad804 - std::backtrace_rs::backtrace::libunwind::trace::h2000fb4d08dbcc59
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x1006ad804 - std::backtrace_rs::backtrace::trace_unsynchronized::h2b5e61495350674d
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x1006ad804 - std::sys_common::backtrace::_print_fmt::h05f5bfbdb3415936
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:65:5
   3:        0x1006ad804 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h105074e3d85f800b
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x1006c85c8 - core::fmt::write::h34766cf8fff7af1e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:1232:17
   5:        0x1006aa70c - std::io::Write::write_fmt::hd64c4cf6e7adea59
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/io/mod.rs:1684:15
   6:        0x1006ad618 - std::sys_common::backtrace::_print::hd92783a665d3ebfb
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:47:5
   7:        0x1006ad618 - std::sys_common::backtrace::print::h2a6828a537036cf9
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:34:9
   8:        0x1006aec48 - std::panicking::default_hook::{{closure}}::h4e82ce6ccef941b2
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:271:22
   9:        0x1006ae9a0 - std::panicking::default_hook::h29f62f8795c5cb00
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:290:9
  10:        0x1006af158 - std::panicking::rust_panic_with_hook::h19862cbd0fbda7ba
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:692:13
  11:        0x1006af08c - std::panicking::begin_panic_handler::{{closure}}::h3f3626935e1669fe
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:583:13
  12:        0x1006adc24 - std::sys_common::backtrace::__rust_end_short_backtrace::h5054ef52bd507d0a
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:150:18
  13:        0x1006aede8 - rust_begin_unwind
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:579:5
  14:        0x1006da6e4 - core::panicking::panic_fmt::h7e47e10600a90221
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:64:14
  15:        0x1006daa1c - core::result::unwrap_failed::h6a1757e313e2d291
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/result.rs:1750:5
  16:        0x10048f0e8 - cargo_update::ops::GitRepoPackage::pull_version_impl::h369c7f02a47dd86b
  17:        0x100461a38 - cargo_install_update::actual_main::hfbbf523314c1a551
  18:        0x100460570 - cargo_install_update::main::ha07532a1db37e7b7
  19:        0x10046a01c - std::sys_common::backtrace::__rust_begin_short_backtrace::hfb10d9966f6c583f
  20:        0x10046a034 - std::rt::lang_start::{{closure}}::h22d0b3256894a6cd
  21:        0x1006a5450 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hf2f6b444963da11f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:287:13
  22:        0x1006a5450 - std::panicking::try::do_call::h9152231fddd58858
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:487:40
  23:        0x1006a5450 - std::panicking::try::hcc27eab3b8ee3cb1
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:451:19
  24:        0x1006a5450 - std::panic::catch_unwind::hca546a4311ab9871
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panic.rs:140:14
  25:        0x1006a5450 - std::rt::lang_start_internal::{{closure}}::h4e65aa71fe685c85
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:48
  26:        0x1006a5450 - std::panicking::try::do_call::h61aea55fbdf97fc2
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:487:40
  27:        0x1006a5450 - std::panicking::try::hcfc3b62fb8f6215e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:451:19
  28:        0x1006a5450 - std::panic::catch_unwind::h61a201e98b56a743
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panic.rs:140:14
  29:        0x1006a5450 - std::rt::lang_start_internal::h91996717d3eb1d2a
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:20
  30:        0x100462d94 - _main

This is repeatable. I've tried removing github.com from my .ssh/known_hosts just in case.

nabijaczleweli commented 1 year ago

That's for a git package, what's your ~/.cargo/.crates.toml?

What if you export CARGO_NET_GIT_FETCH_WITH_CLI=a=true?

dsully commented 1 year ago

That works. config.toml is:

# Use the new sparse registry.
[registries.crates-io]
protocol = "sparse"
nabijaczleweli commented 1 year ago

Does it also happen without -g, and if not, what's your .crates.toml?

dsully commented 1 year ago

"cloudflare-dns 0.0.1 (git+git+ssh://git@github.com/dsully/zoned#8cd2481c664b3dc49929272ff23cb6d61a78995e)" = ["cloudflare-dns-updater"]

Is the line you're looking for from .crates.toml

I'm not calling cargo-install-update directly, but rather from topgrade. It is passing --git:

https://github.com/topgrade-rs/topgrade/blob/ac6330fac85564832170237379a226f1f16545bf/src/steps/generic.rs#L59

nabijaczleweli commented 1 year ago

funnily enough, I get:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 23, message: "error loading known_hosts: " }', src\ops\mod.rs:496:149
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

on win32 and

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -17, klass: 23, message: "invalid or unknown remote ssh hostkey" }', src/ops/mod.rs:496:149
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

under linux. or i did the first few times before i got throttled. idk, looks like libgit2 URL parsing bull shit. set net.git-fetch-with-cli = true for now if running git works

nabijaczleweli commented 1 year ago

And now my repro says

$ target/debug/cargo-install-update install-update -lag
    Polling registry 'https://index.crates.io/'.............

Package        Installed  Latest                             Needs update
b3sum          v1.3.1     v1.3.3                             Yes
cargo-bloat    v0.11.0    v0.11.1                            Yes
cargo-deb      v1.35.0    v1.43.1                            Yes
checksums      v0.6.0     v0.9.1                             Yes
hyperfine      v1.14.0    v1.16.1                            Yes
termimage      v1.1.0     v1.2.0                             Yes
xargo          v0.3.24    v0.3.26                            Yes
zoxide         v0.8.3     v0.9.1                             Yes
cargo-tree     v0.29.0    v0.29.0                            No
gen-epub-book  v2.3.2     v2.3.2                             No
pijul          v0.12.2    v0.12.2 (v1.0.0-beta.5 available)  No
pixelmatch     v0.1.0     v0.1.0                             No
treesize       v0.5.0     v0.5.0                             No

[src/ops/mod.rs:500] "aaa" = "aaa"
[src/ops/mod.rs:516] &self.url = "git+ssh://git@github.com/dsully/zoned"
[src/ops/mod.rs:527] &self.url = "git+ssh://git@github.com/dsully/zoned"
[src/ops/mod.rs:527] &clone_dir = "/tmp/cargo-update/cloudflare-dns"
[src/ops/mod.rs:520] a = "git+ssh://git@github.com/dsully/zoned"
[src/ops/mod.rs:520] b = Some(
    "git",
)
[src/ops/mod.rs:520] c = SSH_KEY | SSH_MEMORY | SSH_CUSTOM
[src/ops/mod.rs:528] GitError::last_error(0) = Some(
    Error {
        code: 0,
        klass: 0,
        message: "an unknown git error occurred",
    },
)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 0, message: "error authenticating: no auth sock variable; class=Ssh (23): failed to authenticate when downloading repository git+ssh://git@github.com/dsully/zoned (tried ssh-agent, but none of the following usernames worked: \"git\")" }', src/ops/mod.rs:1469:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

so idk