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

Invalid handle problem #10464

Closed
leonardo-m opened this issue Mar 7, 2022 · 12 comments
Closed

Invalid handle problem #10464

leonardo-m opened this issue Mar 7, 2022 · 12 comments
Labels
A-git Area: anything dealing with git C-bug Category: bug O-windows OS: Windows

Comments

@leonardo-m
Copy link

Problem

I am not sure if it's really Cargo's fault, perhaps it's just an unknown problem in my system. Since few days I'm having a problem with Cargo on Windows. (I've used for years Cargo on the same system with no problems). If I try to create the project "test1" cargo gives me (the same error is generated if I run it as administrator):

error: Failed to create package test1 at ...\test1

Caused by:
  failed to open file ...\test1\.gitignore

Caused by:
  Error 6 - The handle is invalid 

Steps

cargo new test1

Possible Solution(s)

No response

Notes

I am using:

rustc 1.61.0-nightly (38a0b81b1 2022-03-06)

(rustc and rustup work well, I can update the Nightly compiler with no problems).

Version

cargo 1.61.0-nightly (3d6970d50 2022-02-28)
release: 1.61.0-nightly
commit-hash: 3d6970d50e30e797b8e26b2b9b1bdf92dc381f34
commit-date: 2022-02-28
host: x86_64-pc-windows-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:Schannel)
os: Windows 6.3.9600 (Windows 8.1) [64-bit]
@leonardo-m leonardo-m added the C-bug Category: bug label Mar 7, 2022
@weihanglo
Copy link
Member

Hmm... Just found a similar issue from Windows official support site, though it may or may not be relevant to what you reported.

Could you test against stable/beta channel to see if the problem still occurs?

@leonardo-m
Copy link
Author

Thank you for your answer. I haven't yet tried that "solution" because it doesn't seem for Windows 8.1. But I've tried both beta and stable and there is no problem for both versions:

No problem with:

rustc 1.59.0 (9d1b2106e 2022-02-23)

cargo 1.59.0 (49d8809dc 2022-02-10)
release: 1.59.0
commit-hash: 49d8809dc2d3e6e0d5ec634fcf26d8e2aab67130
commit-date: 2022-02-10
host: x86_64-pc-windows-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:Schannel)
os: Windows 6.3.9600 (Windows 8.1) [64-bit]

No problem with:

rustc 1.60.0-beta.3 (e5effbd0b 2022-03-07)

cargo 1.60.0-beta.3 (d1fd9fe2c 2022-03-01)
release: 1.60.0-beta.3
commit-hash: d1fd9fe2c40a1a56af9132b5c92ab963ac7ae422
commit-date: 2022-03-01
host: x86_64-pc-windows-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:Schannel)
os: Windows 6.3.9600 (Windows 8.1) [64-bit]

While there's the problem with the last Nightly (but it could be a bit older). So now I suspect this is a real cargo bug.

@leonardo-m
Copy link
Author

leonardo-m commented Mar 8, 2022

I've tried cargo nightly on another Windows system and this works:

rustc 1.61.0-nightly (68369a041 2022-02-22)

cargo 1.61.0-nightly (ea2a21c99 2022-02-15)
release: 1.61.0-nightly
commit-hash: ea2a21c994ca1e4d4c49412827b3cf4dcb158b1d
commit-date: 2022-02-15
host: x86_64-pc-windows-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:Schannel)
os: Windows 10.0.19044 (Windows 10 Home) [64-bit]

@leonardo-m
Copy link
Author

Now it gives me a different error:

...>cargo new test1
thread 'main' panicked at 'couldn't initialize the libgit2 library: -1, error: unknown error', C:\...\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\libgit2-sys-0.13.1+1.4.2\lib.rs:4126:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4\/library\std\src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4\/library\core\src/panicking.rs:143:14
   2: <std::sync::once::Once>::call_once::<libgit2_sys::init::{closure#0}>::{closure#0}
   3: std::sync::once::Once::call_inner
             at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4\/library\std\src\sync/once.rs:428:21
   4: libgit2_sys::init
   5: <git2::config::Config>::open_default
   6: cargo::ops::registry::http_proxy
   7: cargo::ops::registry::needs_custom_http_transport
   8: cargo::init_git_transports
   9: cargo::cli::main
  10: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Using the latest Nightly:

cargo 1.61.0-nightly (65c826642 2022-03-09)
release: 1.61.0-nightly
commit-hash: 65c82664263feddc5fe2d424be0993c28d46377a
commit-date: 2022-03-09
host: x86_64-pc-windows-gnu
libgit2: 1.4.1 (sys:0.14.1 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:Schannel)
os: Windows 6.3.9600 (Windows 8.1) [64-bit]

@weihanglo
Copy link
Member

weihanglo commented Mar 10, 2022

It seems like the git_libgit2_init function in libgit2 was broken, and it's weird that the backtrace reported a C:\...\libgit2-sys\... path, while the libgit2 is actually vendored 🤔 this path shouldn’t affect anything since it might belongs to the system that built cargo and rustup you downloaded.

Besides, I found a suspect1 and it was fixed2 and released with libgit2 v1.4.2. In short, it fails when there is no "Git for Windows" installed in your system. If you are available, could you install Git for Windows and try again? I'll try to send a patch later on.

Footnotes

  1. https://github.com/libgit2/libgit2/issues/6225

  2. https://github.com/libgit2/libgit2/pull/6228

@leonardo-m
Copy link
Author

After installing "Git for Windows" I'm back to the "Error 6 - The handle is invalid" (now using the latest cargo 1.61.0-nightly 65c8266 2022-03-09).

@leonardo-m
Copy link
Author

leonardo-m commented Mar 11, 2022

I've done some bisection, and the first rust/cargo Nightly that gives that Error 6 is:

rustc 1.61.0-nightly (9fcbc3205 2022-03-04)
cargo 1.61.0-nightly (3d6970d50 2022-02-28)
release: 1.61.0-nightly
commit-hash: 3d6970d50e30e797b8e26b2b9b1bdf92dc381f34
commit-date: 2022-02-28
host: x86_64-pc-windows-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:Schannel)
os: Windows 6.3.9600 (Windows 8.1) [64-bit]

@weihanglo weihanglo added O-windows OS: Windows and removed O-windows OS: Windows labels Mar 14, 2022
@AndreKR
Copy link

AndreKR commented Mar 14, 2022

I can confirm that the issue can be worked around with

rustup install nightly-2022-02-27
rustup default nightly-2022-02-27-x86_64-pc-windows-gnu

@ehuss
Copy link
Contributor

ehuss commented Mar 14, 2022

@weihanglo Can you post a PR to update git2/libgit2-sys to see if that will resolve the problem?

@ehuss ehuss added A-git Area: anything dealing with git O-windows OS: Windows labels Mar 14, 2022
@leonardo-m
Copy link
Author

I've updated Nightly, with the Cargo improvements, so far no change.

@ehuss
Copy link
Contributor

ehuss commented Mar 20, 2022

I tracked down the issue to rust-lang/rust#95154

@leonardo-m
Copy link
Author

Now it's fixed, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-git Area: anything dealing with git C-bug Category: bug O-windows OS: Windows
Projects
None yet
Development

No branches or pull requests

4 participants