Rustを使ってみたくて
Lambda関数を作ってみた。
その際に、いろいろドキュメントとか見たけど。
reqwestなどのopensslを使うライブラリのビルドで失敗し続けハマりにハマった。
他に詰まった人の助けになれば。
failed to run custom build command for openssl-sys v0.9.63
がでる
ひたすらこのエラー。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
$ cargo build Updating crates.io index Downloaded hyper-tls v0.5.0 Downloaded httpdate v1.0.1 Downloaded h2 v0.3.3 Downloaded tokio-native-tls v0.3.0 Downloaded http-body v0.4.2 Downloaded tokio v1.6.0 Downloaded mio v0.7.11 Downloaded tower-service v0.3.1 Downloaded reqwest v0.11.3 Downloaded hyper v0.14.7 Downloaded want v0.3.0 Downloaded ipnet v2.3.0 Downloaded socket2 v0.4.0 Downloaded tokio-util v0.6.7 Downloaded 14 crates (1.2 MB) in 1.51s Compiling tower-service v0.3.1 Compiling httpdate v1.0.1 Compiling ipnet v2.3.0 Compiling indexmap v1.6.2 Compiling tokio v1.6.0 Compiling http-body v0.4.2 Compiling openssl-sys v0.9.63 Compiling iovec v0.1.4 error: failed to run custom build command for `openssl-sys v0.9.63` Caused by: process didn't exit successfully: `/home/noff/workdir/lambda_fund |
別の最新ライブラリを使うとこんなエラー
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
cargo build Updating crates.io index Downloaded hyper-tls v0.5.0 Downloaded httpdate v1.0.1 Downloaded h2 v0.3.3 Downloaded tokio-native-tls v0.3.0 Downloaded http-body v0.4.2 Downloaded tokio v1.6.0 Downloaded mio v0.7.11 Downloaded tower-service v0.3.1 Downloaded reqwest v0.11.3 Downloaded hyper v0.14.7 Downloaded want v0.3.0 Downloaded ipnet v2.3.0 Downloaded socket2 v0.4.0 Downloaded tokio-util v0.6.7 Downloaded 14 crates (1.2 MB) in 1.51s Compiling tower-service v0.3.1 Compiling httpdate v1.0.1 Compiling ipnet v2.3.0 Compiling indexmap v1.6.2 Compiling tokio v1.6.0 Compiling http-body v0.4.2 Compiling openssl-sys v0.9.63 Compiling iovec v0.1.4 error: failed to run custom build command for `openssl-sys v0.9.63` Caused by: process didn't exit successfully: `/home/noff/workdir/dev_test/api/target/debug/build/openssl-sys-ed7d76a0dc242d85/build-script-main` (exit code: 101) --- stdout cargo:rustc-cfg=const_fn cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=OPENSSL_LIB_DIR OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset cargo:rerun-if-env-changed=OPENSSL_DIR OPENSSL_DIR unset cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG cargo:rerun-if-env-changed=PKG_CONFIG cargo:rerun-if-env-changed=OPENSSL_STATIC cargo:rerun-if-env-changed=OPENSSL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_PATH cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu 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 code: 1\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.63 ', /home/noff/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.63/build/find_normal.rs:174:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... error: build failed |
よくある対応策
探し回ると色々解決策はgithubのissueとかで挙がってた(私は全部当てはまらなかった..)
- openssl-devl(centos), libssl-dev(ubuntu)をインストールする
- 最新版のOpenSSLをインストールする
- cargo update
OpenSSLの最新版を入れるのはCentOS7は保護されたライブラリのためほぼ無理。
CentOS8の最新版OpenSSLでやってみたけどだめ。
openssl-develを入れる。(これもだめだった)
私の解決策
rust-musl-builderというDockerイメージを作ってくれている人がいました。
その人のDockerファイルを独自に書き換えてビルドすることで解決しました。
すごい。゚(゚´Д`゚)゚。
ありがたすぎる。゚(゚´Д`゚)゚。
Rust諦めるところだった。゚(゚´Д`゚)゚。
詳しくはご本人のgithubをみてね。
Dockerはほんとに偉大ですわ。
ありがたやありがたや.....
じゃあね~~~~