cargo-generate: Error: ⛔ Git Error: invalid version 0 on git_proxy_options; class=Invalid (3)

Not working after updating to 0.10.0 version.

cargo 1.55.0 (32da73ab1 2021-08-23)
cargo-generate 0.10.0
git version 2.33.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 33 (19 by maintainers)

Commits related to this issue

Most upvoted comments

FYI: Just installed cargo-generate today, and ran directly into this issue.

cargo generate --git https://github.com/rust-embedded/cortex-m-quickstart ⚠️ Unable to load config file: ~/.cargo/cargo-generate.toml Error: ⛔ Git Error: invalid version 0 on git_proxy_options; class=Invalid (3)

cargo generate --version cargo-generate 0.10.3

As I tried to write the other day: I finally got it to work, but I don’t know why!

The system installed version somhow inteferred - but after trying out another system installed version (which caused the linker step of cargo-generate to fail, why?), I reverted back to my distros default (which is what I started with), and suddenly it worked!

I know libgit2-sys should be independent of the system installed version, but reality is; it’s not! Somehow, somewhere, they can conflict during development.

Kinda hard to do any development then - especially as I want the other fixes

Simply genius - now it no longer works - again

To me, this change stops me from using cargo-generate as it basically reverts back to the error.

@sassman It worked without an error! Thanks a lot.

So for me cargo-generate works, but I went down this path to reproduce the issue:

  • git at /usr/local/bin/git @ v2.32.0
  • git at /usr/bin/git @ v2.30.1 (Apple Git-130)
  • libgit2-sys cargo bindings at
$ find ~/.cargo -name "libgit2"
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.14+1.1.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.7.11/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.9.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.17+1.1.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.9+1.0.1/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.10.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.23+1.2.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.20+1.1.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.7+1.0.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.22+1.1.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.13+1.0.1/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.21+1.1.0/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.9.2/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.12+1.0.1/libgit2
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.18+1.1.0/libgit2
  • so now cleaning this up, to see how things would behave: find ~/.cargo -name "libgit2" -exec rm -rf {} \;
  • then on installing cargo install cargo-generate this error occurred:
error: failed to run custom build command for `libgit2-sys v0.12.22+1.1.0`

Caused by:
  process didn't exit successfully: `/var/folders/m8/084p1v0x4770rpwpkrgl5b6h0000gn/T/cargo-installf55CVI/release/build/libgit2-sys-db72ee0cdf73f99a/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBGIT2_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBGIT2_STATIC
  cargo:rerun-if-env-changed=LIBGIT2_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  fatal: not a git repository (or any of the parent directories): .git
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.22+1.1.0/build.rs:194:39
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-generate v0.10.1`, intermediate artifacts can be found at `/var/folders/m8/084p1v0x4770rpwpkrgl5b6h0000gn/T/cargo-installf55CVI`

Caused by:
  build failed
  • seems to relate to missing cmake see this issue so brew install cmake
  • retry install cargo-generate -> cargo install cargo-generate -> same error
  • installing libgit2 -> brew install libgit2
  • retry install cargo-generate -> cargo install cargo-generate -> WORKS!
  • retesting cargo generate:
cargo generate demo3
💡   Using application config: /Users/d34dl0ck/.cargo/cargo-generate
Error: ⛔   Git Error: invalid version 0 on git_proxy_options; class=Invalid (3)

DOPE! now my system is also broken 😃

So my conclusion is that the brew installed libgit2 would not fit to the rust binding that cargo installs, that is:

find ~/.cargo -name "libgit2"

/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.24+1.3.0/libgit2
  • So I upgraded the Cargo.toml on the pinned version of libgit2-sys to
index ee1f0ad..5d5fb57 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,7 @@ dirs = "4.0.0"
 indicatif = "0.16.2"
 # git2:0.13.22 pulls libgit2-sys:0.12.23+1.2.0, which causes errors on some systems
 git2 = "0.13.21"
-libgit2-sys = "=0.12.22+1.1.0"
+libgit2-sys = "0.12"
 tempfile = "3.2.0"
 regex = "1.5.4"
 heck = "0.3.3"
  • then ran cargo update && cargo install --path .
  • then verified the final version of libgit2 that is installed:
find ~/.cargo -name "libgit2"
/Users/d34dl0ck/.cargo/registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.24+1.3.0/libgit2

⚠️ NOTE: so it seems the version pinning in cargo-generate does not properly work at all

  • now verifying if cargo-generate works (with success!!)
cargo generate demo3
💡   Using application config: /Users/d34dl0ck/.cargo/cargo-generate
🤷   Project Name : asdf
🔧   Generating template ...
✔ 🤷   Which board do you use? · Arduino Uno
[ 1/19]   Done: .cargo/config.toml
[ 2/19]   Done: .cargo
[ 3/19]   Done: .gitignore
[ 4/19]   Done: Cargo.toml
[ 5/19]   Done: LICENSE-APACHE
[ 6/19]   Done: LICENSE-MIT
[ 7/19]   Done: README.md
[ 8/19]   Done: avr-specs/avr-atmega1280.json
[ 9/19]   Done: avr-specs/avr-atmega168.json
[10/19]   Done: avr-specs/avr-atmega2560.json
[11/19]   Done: avr-specs/avr-atmega328p.json
[12/19]   Done: avr-specs/avr-atmega32u4.json
[13/19]   Done: avr-specs/avr-atmega48p.json
[14/19]   Done: avr-specs/avr-attiny85.json
[15/19]   Done: avr-specs/avr-attiny88.json
[16/19]   Done: avr-specs
[17/19]   Done: rust-toolchain.toml
[18/19]   Done: src/main.rs
[19/19]   Done: src
🔧   Moving generated files into: `/Users/d34dl0ck/workspaces/rust/cargo-generate-org/cargo-generate/asdf`...
✨   Done! New project created /Users/d34dl0ck/workspaces/rust/cargo-generate-org/cargo-generate/asdf
  • checking the linked libraries (like ldd )
otool -L ~/.cargo/bin/cargo-generate
/Users/d34dl0ck/.cargo/bin/cargo-generate:
	/usr/local/opt/libgit2/lib/libgit2.1.3.dylib (compatibility version 1.3.0, current version 1.3.0)
	/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5)
	/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)

So maybe you can check the cargo-generate linked version of libgit2 on your system?

I’m not even sure it’s a git2 crate specific issue - seems to be a fairly wellknown issue: https://www.google.com/search?q=invalid version 0 on git_proxy_options%3B class%3DInvalid (3)

@TonalidadeHidrica it is unfortunately out of our control as this is something to do with a dependency inside git2 (not git).

I discovered this error as I couldn’t run the testcases after the git2 dependency had been upgraded. Downgrading to out to be really hard, as it is one of git2s dependencies that caused the issue, and once updated, both new and old git2 version is quite happy to use the problematic 3’rd dependency. - Convoluted, I know!

Even worse, I could only reproduce this on my Manjaro machine - the error was not present on Windows, nor Ubuntu nor Debian. Some user had the issue also on Arch Linux.

Just for clarification, could we get your exact OS version etc? I’d still like to see if we could somehow replicate this as I think a lot of ppl even outside cargo-generate would like to know the culpritt.