How to Install Cargo Generate on M1 Macbook
Asked Answered
T

2

6

I'm trying to install cargo-generate on my M1 Macbook air. It looks like the linker is finding the x86_64 version of openssl:

λ: cargo install cargo-generate                  
    Updating crates.io index
  Installing cargo-generate v0.13.1
   Compiling libc v0.2.126
...
// ********** snipped **********
...
   Compiling pest_derive v2.1.0
   Compiling thiserror-impl v1.0.31
   Compiling structopt-derive v0.4.18
   Compiling rhai_codegen v1.4.0
   Compiling failure v0.1.8
   Compiling pwd v1.3.1
   Compiling git-config v0.2.1
   Compiling thiserror v1.0.31
   Compiling rhai v1.7.0
   Compiling structopt v0.3.26
   Compiling kstring v2.0.0
   Compiling toml v0.5.9
   Compiling liquid-core v0.26.0
   Compiling liquid-lib v0.26.0
   Compiling liquid v0.26.0
   Compiling git2 v0.14.2
   Compiling cargo-generate v0.13.1
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-arch" "arm64" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/deps/cargo_generate-3b067bb1f3f7f98a.cargo_generate.1172600b-cgu.0.rcgu.o" "-L" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/deps" "-L" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/build/libgit2-sys-33c3e15ed2a1170c/out/build" "-L" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/build/libssh2-sys-d45cf615a1338664/out/build" "-L" "/usr/local/opt/openssl@3/lib" "-L" "/Users/carsonrajcan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/rustcgt1KX4/liblibgit2_sys-ea90ee25efac1064.rlib" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/rustcgt1KX4/liblibssh2_sys-31bfafe03b9ec440.rlib" "/Users/carsonrajcan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-4d2eba102ddf9fce.rlib" "-liconv" "-framework" "Security" "-framework" "CoreFoundation" "-lssl" "-lcrypto" "-lz" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/Users/carsonrajcan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR/release/deps/cargo_generate-3b067bb1f3f7f98a" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: ld: warning: ignoring file /usr/local/opt/openssl@3/lib/libssl.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
          ld: warning: ignoring file /usr/local/opt/openssl@3/lib/libcrypto.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
          Undefined symbols for architecture arm64:
            "_EVP_ripemd160", referenced from:
                _mac_method_hmac_ripemd160_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
            "_EVP_md5", referenced from:
                _mac_method_hmac_md5_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
            "_HMAC_Final", referenced from:
                _mac_method_hmac_sha2_256_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_sha2_512_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_sha1_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_md5_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_ripemd160_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
            "_HMAC_CTX_free", referenced from:
                _mac_method_hmac_sha2_256_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_sha2_512_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_sha1_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_md5_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
                _mac_method_hmac_ripemd160_hash in liblibssh2_sys-31bfafe03b9ec440.rlib(mac.o)
            "_EVP_cast5_cbc", referenced from:
                _libssh2_crypt_method_cast128_cbc in liblibssh2_sys-31bfafe03b9ec440.rlib(crypt.o)
...
// ********** snipped **********
...
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: failed to compile `cargo-generate v0.13.1`, intermediate artifacts can be found at `/var/folders/1t/n07x82ln3gn5b40gnv28x_cc0000gn/T/cargo-install93sXCR`

Caused by:
  could not compile `cargo-generate` due to previous error

I'm not sure if I have the correct version of openssl on my system.

How can I ensure I have the correct (macOS-arm64) openssl version installed and visible for the linker?

Or if that's not the problem, how do I get the compiler to play nicely with the version I do have?

Tumbrel answered 30/5, 2022 at 16:59 Comment(2)
probably you can enforce some prebuilt? I remember seeing something like that in other crates.Goodtempered
You are correct. I found the vendored-openssl flag and it worked.Tumbrel
G
6

You have to enaable the vendored-openssl flag:

cargo install cargo-generate --features "vendored-openssl"
Goodtempered answered 30/5, 2022 at 17:21 Comment(0)
T
0

I'm still not sure how you would use the system's openssl, but as @Netwave suggested, I was able to continue anyway with the vendored-openssl flag:

cargo install cargo-generate --features vendored-openssl

Which I found in the docs.

Tumbrel answered 30/5, 2022 at 17:21 Comment(2)
oh, I was writing it at the same time :DGoodtempered
glad it helped thoughGoodtempered

© 2022 - 2024 — McMap. All rights reserved.