Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does reqwest require an OpenSSL installation?

I was trying to get an elementary reqwest http-request going like so

extern crate reqwest;
extern crate url;

use url::Url;

fn main() {
    let resp = reqwest::get("http://google.com".parse::<Url>().unwrap());
    println!("{:?}", resp.unwrap())
}

However, this produces the error

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.

...

Well, this was easy enough to fix. One call to sudo apt install libssl-dev and sudo apt install pkg-config and it's working. But I still don't understand what exactly went wrong here. I thought cargo was supposed to take care of dependencies. Why am I now hunting them manually with apt?

like image 520
Sebastian Oberhoff Avatar asked Oct 17 '22 13:10

Sebastian Oberhoff


1 Answers

reqwest depends on rust-native-tls, which on Linux depends on openssl-sys, which is where this message comes from. So cargo did do its job, taking care of Rust dependencies.

However, openssl-sys depends on a C library (OpenSSL), at which point cargo stops caring.

like image 117
mcarton Avatar answered Oct 20 '22 20:10

mcarton