Mac에 cargo-edit 설치

4000 단어 macoscargoRust
「실천 Rust 프로그래밍 입문」을 사 왔으므로 환경을 구축했습니다만, MacOS Catalina(10.15.6)라고 cargo-edit의 인스톨시에 에러가 되어 버렸으므로, 메모

carg-edit를 설치하려고하면 다음과 같은 오류가 발생합니다.
$ cargo install cargo-edit
Could not find directory of OpenSSL installation, and this `-sys` crate cannot
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
compilation process.

If you're in a situation where you think the directory *should* be found
automatically, please open a bug at https://github.com/sfackler/rust-openssl
and include information about your system as well as this message.

    $HOST = x86_64-apple-darwin
    $TARGET = x86_64-apple-darwin
    openssl-sys = 0.9.58

It looks like you're compiling on macOS, where the system contains a version of
OpenSSL 0.9.8. This crate no longer supports OpenSSL 0.9.8.

As a consumer of this crate, you can fix this error by using Homebrew to
install the `openssl` package, or as a maintainer you can use the openssl-sys
0.7 crate for support with OpenSSL 0.9.8.

아무래도 OpenSSL 버전이 맞지 않는 것 같습니다. Homebrew에서 openssl을 설치하라고 써 있기 때문에 그렇습니다.
$ brew update
$ brew install openssl
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1g.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/1926679569c6af5337de812d86f4dad2b21ff883ad3a5d2cd9e8836ac5ac7ffe?re
######################################################################## 100.0%
==> Pouring [email protected]
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/[email protected]/certs

and run
  /usr/local/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

==> Summary
🍺  /usr/local/Cellar/[email protected]/1.1.1g: 8,059 files, 18MB
==> `brew cleanup` has not been run in 30 days, running now...
Pruned 1 symbolic links and 2 directories from /usr/local

지시에 따라 중간 인증서를 키체인에 등록합니다.
finder에서/usr/local/etc/오펜 sl @ 1.1/를 엽니다.


cert.pem을 클릭하여 키체인 액세스로 인증서를 등록합니다.


지시대로 다음 명령을 실행합니다.
$ /usr/local/opt/[email protected]/bin/c_rehash

이 상태에서는 MacOS에 들어 있는 LibreSSL이 사용되므로 .zshrc에 OpenSSL을 사용하도록 지정합니다.
$ echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

컴파일러가 오펜 sl @ 1.1를 찾으려면 아래 설명이 필요하기 때문에 다음을 추가합니다.
$ vi ~/.zshrc
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

로드합니다.
$ source ~/.zshrc

이제 cargo-edit를 설치할 수 있습니다.
$ cargo install cargo-edit
(省略)
Installed package `cargo-edit v0.6.0` (executables `cargo-add`, `cargo-rm`, `cargo-upgrade`)

좋은 웹페이지 즐겨찾기