LoginSignup
0
0

More than 1 year has passed since last update.

cargo install cargo-generateに失敗する (fatal error: zlib.h: No such file or directory)

Last updated at Posted at 2021-05-29

環境

  • Debian (WSL2)
  • linuxbrew
  • cargo 1.52.0

起こったこと

cargo install cargo-generateを実行すると、以下のメッセージを吐いて異常終了する

The following warnings were emitted during compilation:

warning: libssh2/src/comp.c:41:10: fatal error: zlib.h: No such file or directory
warning:  #include <zlib.h>
warning:           ^~~~~~~~
warning: compilation terminated.

error: failed to run custom build command for `libssh2-sys v0.2.21`

どうやら、libssh2周りで不足がある模様

試したこと

  • pkg-configを叩く
pkg-config --cflags zlib
pkg-config --cflags libssh2
# どちらとも、linuxbrewのパスが表示される… 一応入ってるみたい
  • libssh2をインストールする
sudo apt install libssh2-1-dev    # が、うまくいかない…
  • libzをインストールする
sudo apt install libz-dev    # ビルドに成功した!

何がダメだったのか

検索したところ、それっぽいissueがいくつかヒットしました。
cargoはlinuxbrew経由でインストールしたライブラリを見に行ってくれない(※)ようなので、
aptでインストールする必要があるようです。
※語弊があるかもしれません…

終わりに

brew reinstall ...をやっても解決しないよ、という話でした。
素直に環境構築をすれば遭遇しなさそうですが、備忘として残しておきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0