DEV Community

loading...
Cover image for Issue installing cargo-generate

Issue installing cargo-generate

Turbo Panumarch
・2 min read

Problem 1: libgit2 missing

I tried to install cargo-generate. My current machine is MacOS BigSur 11.3 Beta.

cargo install cargo-generate --features vendored-openssl
Enter fullscreen mode Exit fullscreen mode

somehow I got an error related to libgit2 and it confused me.

fatal: not a git repository (or any of the parent directories): .git


  error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-arch" "x86_64" "-I" "/var/folders/70/91y0tylx71x1wjv_275y8x8c0000gn/T/cargo-install6KpOP3/release/build/libgit2-sys-1319684400f5f70f/out/include" "-I" "libgit2/src" "-I" "libgit2/deps/http-parser" "-I" "libgit2/deps/pcre" "-I" "/var/folders/70/91y0tylx71x1wjv_275y8x8c0000gn/T/cargo-install6KpOP3/release/build/libssh2-sys-4c230072710e2672/out/include" "-fvisibility=hidden" "-DGIT_REGEX_BUILTIN=1" "-DHAVE_STDINT_H=1" "-DHAVE_MEMMOVE=1" "-DNO_RECURSE=1" "-DNEWLINE=10" "-DPOSIX_MALLOC_THRESHOLD=10" "-DLINK_SIZE=2" "-DPARENS_NEST_LIMIT=250" "-DMATCH_LIMIT=10000000" "-DMATCH_LIMIT_RECURSION=MATCH_LIMIT" "-DMAX_NAME_SIZE=32" "-DMAX_NAME_COUNT=10000" "-DSHA1DC_NO_STANDARD_INCLUDES=1" "-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\"" "-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\"" "-o" "/var/folders/70/91y0tylx71x1wjv_275y8x8c0000gn/T/cargo-install6KpOP3/release/build/libgit2-sys-1319684400f5f70f/out/build/libgit2/src/streams/stransport.o" "-c" "libgit2/src/streams/stransport.c" with args "cc" did not execute successfully (status code exit code: 1).
Enter fullscreen mode Exit fullscreen mode

Solution

The libgit2 was somehow missing from my machine. So we just need to install it.

For MacOS brew user,

brew install libgit2
Enter fullscreen mode Exit fullscreen mode

Problem 2: CoreFoundation not found

After fixing the previous issue and installed again, I encountered the new issue.

cargo install cargo-generate --features vendored-openssl
Enter fullscreen mode Exit fullscreen mode
ld: framework not found CoreFoundation
          clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: aborting due to previous error

error: failed to compile `cargo-generate v0.6.1`
Enter fullscreen mode Exit fullscreen mode

Solution

It is probably the issue on MacOS BigSur which removed some of the built-in libraries.

1. Reinstall xcode command line tools to make sure we have the latest version.

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Enter fullscreen mode Exit fullscreen mode

2. Install gcc & llvm via Homebrew. If it mentions that you already installed, perform the next step.

# WARNING: This can take several hours
brew install gcc
brew install llvm
Enter fullscreen mode Exit fullscreen mode

3. Reinstall (only for machine with gcc and llvm installed via home brew.)

brew cleanup
brew update
brew upgrade
brew reinstall gcc
brew reinstall llvm
Enter fullscreen mode Exit fullscreen mode

4. Try installing cargo-generate again. 🎉


Special thanks to @iporsut for helping me solve the issue. 🙏

Discussion (0)

Forem Open with the Forem app