I'm trying to install anchor on Ubuntu 22.04 but the installation fails. Here's the terminal output:
cargo install --git https://github.com/project-serum/anchor avm --locked --force
Updating git repository `https://github.com/project-serum/anchor`
Installing avm v0.25.0 (https://github.com/project-serum/anchor#93332766)
Updating crates.io index
Compiling libc v0.2.119
Compiling autocfg v1.1.0
Compiling proc-macro2 v1.0.36
Compiling cfg-if v1.0.0
Compiling unicode-xid v0.2.2
Compiling syn v1.0.86
Compiling memchr v2.4.1
Compiling log v0.4.14
Compiling pin-project-lite v0.2.8
Compiling cc v1.0.73
Compiling pkg-config v0.3.24
Compiling bytes v1.1.0
Compiling futures-core v0.3.21
Compiling version_check v0.9.4
Compiling itoa v1.0.1
Compiling futures-task v0.3.21
Compiling lazy_static v1.4.0
Compiling foreign-types-shared v0.1.1
Compiling futures-util v0.3.21
Compiling fnv v1.0.7
Compiling openssl v0.10.38
Compiling hashbrown v0.11.2
Compiling serde_derive v1.0.136
Compiling bitflags v1.3.2
Compiling matches v0.1.9
Compiling pin-utils v0.1.0
Compiling futures-sink v0.3.21
Compiling futures-channel v0.3.21
Compiling once_cell v1.9.0
Compiling futures-io v0.3.21
Compiling tinyvec_macros v0.1.0
Compiling httparse v1.6.0
Compiling native-tls v0.2.8
Compiling serde v1.0.136
Compiling slab v0.4.5
Compiling openssl-probe v0.1.5
Compiling percent-encoding v2.1.0
Compiling try-lock v0.2.3
Compiling ryu v1.0.9
Compiling encoding_rs v0.8.30
Compiling httpdate v1.0.2
Compiling tower-service v0.3.1
Compiling serde_json v1.0.79
Compiling unicode-bidi v0.3.7
Compiling semver v1.0.5
Compiling heck v0.4.0
Compiling anyhow v1.0.54
Compiling base64 v0.13.0
Compiling strsim v0.10.0
Compiling ipnet v2.3.1
Compiling termcolor v1.1.2
Compiling fastrand v1.7.0
Compiling remove_dir_all v0.5.3
Compiling textwrap v0.14.2
Compiling mime v0.3.16
Compiling indexmap v1.8.0
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling tracing-core v0.1.22
Compiling foreign-types v0.3.2
Compiling http v0.2.6
Compiling openssl-sys v0.9.72
Compiling tinyvec v1.5.1
Compiling form_urlencoded v1.0.1
Compiling tracing v0.1.31
error: failed to run custom build command for `openssl-sys v0.9.72`
Caused by:
process didn't exit successfully: `/tmp/cargo-installyyxHFg/release/build/openssl-sys-91e679f09e1fedf4/build-script-main` (exit status: 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_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_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 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.72
', /home/kelvin/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.72/build/find_normal.rs:180: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 `avm v0.25.0 (https://github.com/project-serum/anchor#93332766)`, intermediate artifacts can be found at `/tmp/cargo-installyyxHFg
I've also installed the recommended dependencies using the command below but still doesn't work.
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev