open ssl 不在によるcargo packageインストールエラー メモ

目次

環境

  • windows10 pro
  • wsl2
  • ubuntu20.02
  • build-essentialインストール済み

参考

エラー内容

なぜかcargoでpackageをインストールした際にopenssl-sysのbuild commandがうまく動かなかった。

$ cargo install skgit
error: failed to run custom build command for `openssl-sys v0.9.80`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installviRIJh/release/build/openssl-sys-d9ef8b36565a8d2a/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rustc-cfg=openssl
 --- 省略
  
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit status: 1\nerror: could not find system library 'openssl' required by the 'openssl-sys' crate\n\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'openssl' found\n"

  --- stderr
  thread 'main' panicked at '

  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.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  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-unknown-linux-gnu
  $TARGET = x86_64-unknown-linux-gnu
  openssl-sys = 0.9.80

  ', /home/murakami/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.80/build/find_normal.rs:191:5
  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 `skgit v0.2.0`, intermediate artifacts can be found at `/tmp/cargo-installviRIJh`

ちなみにこの状態でopensslのcommandを確認したらデフォルトで入ってはいる模様

エラー解消

素直にエラー内容に書いてある通り、libssl-devをインストールする

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
$ sudo apt install libssl-dev

エラーが解消されたことを確認

$ cargo install skgit

build-esseintialを入れれば解決などの記事もあったが、自分は明示的にlibssl-devをインストールしなければ解決しなかった

よかったらシェアしてね!
  • URLをコピーしました!

この記事を書いた人

数学科出身のSoftware Engineer
情報通信が好きなのでブログを活用して発信しています。

コメント

コメントする

目次
閉じる