no method named `listen_https` found for type `nickel::Nickel`
iamsebastian opened this issue · comments
Hello,
If I clone the repository and execute the https-example, all is running fine:
Listening on https://127.0.0.1:6767
Ctrl-C to shutdown server
If I switch into the .cargo cached repositories, it is also fine:
❯ cd ~/.cargo/registry/src/github.com-1ecc6299db9ec823/nickel-0.8.1/
...
Listening on https://127.0.0.1:6767
Ctrl-C to shutdown server
Now the problem:
But if I try to use the listen_https
feature in an own repository, I just get the error which says:
❯ cargo run --bin try_nickel_https --features ssl
...
no method named `listen_https` found for type `nickel::Nickel` ...
cargo.toml
[package]
name = "diesel_pg_test"
version = "0.1.0"
authors = ["Sebastian Blei <s.blei@banking-partner.de>"]
[features]
diesel_huge_tables = ["diesel/huge-tables"]
ssl = ["hyper/ssl"]
unstable = ["hyper/nightly"]
[dependencies]
diesel = "0.6.2"
dotenv = "0.8.0"
dotenv_macros = "0.8.0"
[dependencies.hyper]
version = "=0.8"
default-features = false
[dependencies.nickel]
git = "https://github.com/nickel-org/nickel.rs.git"
features = ["unstable"]
[dependencies.diesel_codegen]
version = "0.6.2"
default-features = false
features = ["nightly", "postgres"]
try_nickel_https.rs
#[macro_use]
extern crate nickel;
extern crate hyper;
extern crate dotenv;
use dotenv::dotenv;
use std::env;
#[cfg(not(feature = "ssl"))]
fn main() {
println!("You have to start this binary with \"--features ssl\" activated.");
}
#[cfg(feature = "ssl")]
fn main() {
use hyper::net::Openssl;
use nickel::{Nickel, HttpRouter};
let ssl = Openssl::with_cert_and_key("cert.pem", "key.pem").expect("Could not successfully read https certificates.");
// Check if .env file is flawless.
dotenv().ok();
let adr = format!("127.0.0.1:{port}", port=6767);
let mut server = Nickel::new();
server.listen_https(&*adr, ssl);
}
I've also tried to switch the dependencies in the cargo.toml to:
[dependencies]
nickel = "0.8.1"
... or
[dependencies]
nickel = "0.8.0"
... but I always get the same errors.
cargo clean
or rm -rf ~/.cargo/registry/*
also did nothing.
Here's the verbose log:
~/Projects/rust_diesel_postgres master*
❯ cargo run --bin try_nickel_https --features ssl --verbose
warning: TOML file found which contains invalid syntax and will soon not parse
at `/home/sblei/.cargo/registry/src/github.com-1ecc6299db9ec823/url-0.5.9/Cargo.toml`.
The TOML spec requires newlines after table definitions (e.g. `[a] b = 1` is
invalid), but this file has a table header which does not have a newline after
it. A newline needs to be added and this warning will soon become a hard error
in the future.
Fresh utf8-ranges v0.1.3
Fresh pkg-config v0.3.8
Fresh language-tags v0.2.2
Fresh log v0.3.6
Fresh semver v0.1.20
Fresh byteorder v0.3.13
Fresh mime v0.2.1
Fresh libc v0.2.11
Fresh groupable v0.2.0
Fresh bitflags v0.7.0
Fresh hpack v0.2.0
Fresh rand v0.3.14
Fresh memchr v0.1.11
Fresh lazy_static v0.2.1
Fresh solicit v0.4.4
Fresh uuid v0.2.2
Fresh modifier v0.1.0
Fresh unicode-normalization v0.1.2
Fresh winapi-build v0.1.1
Fresh matches v0.1.2
Fresh traitobject v0.0.1
Fresh gcc v0.3.28
Fresh winapi v0.2.7
Fresh unicode-bidi v0.2.3
Fresh compiletest_rs v0.1.3
Fresh idna v0.1.0
Fresh httparse v1.1.2
Fresh kernel32-sys v0.2.2
Fresh rustc_version v0.1.7
Fresh url v1.1.1
Fresh traitobject v0.0.3
Fresh thread-id v2.0.0
Fresh time v0.1.35
Fresh unsafe-any v0.4.1
Fresh thread_local v0.2.6
Fresh lazy_static v0.1.16
Fresh typemap v0.3.3
Fresh aho-corasick v0.5.2
Fresh unicase v1.4.0
Fresh plugin v0.2.6
Fresh num_cpus v0.2.13
Fresh typeable v0.1.2
Fresh rustc-serialize v0.3.19
Fresh regex-syntax v0.3.3
Fresh mustache v0.6.3
Fresh url v0.5.9
Fresh openssl-sys v0.7.14
Fresh regex v0.1.71
Fresh pq-sys v0.2.1
Fresh openssl-sys-extras v0.7.14
Fresh dotenv v0.8.0
Fresh diesel v0.6.2
Fresh openssl v0.7.14
Fresh dotenv_codegen v0.8.1
Fresh diesel_codegen v0.6.2
Fresh cookie v0.2.5
Fresh dotenv_macros v0.8.0
Fresh hyper v0.8.1
Fresh nickel v0.8.1 (https://github.com/nickel-org/nickel.rs.git#c3aeb722)
Compiling diesel_pg_test v0.1.0 (file:///home/sblei/Projects/rust_diesel_postgres)
Running `rustc src/bin/try_nickel_https.rs --crate-name try_nickel_https --crate-type bin -g --cfg feature=\"hyper\" --cfg feature=\"ssl\" --out-dir /home/sblei/Projects/rust_diesel_postgres/target/debug --emit=dep-info,link -L dependency=/home/sblei/Projects/rust_diesel_postgres/target/debug -L dependency=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps --extern dotenv_macros=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libdotenv_macros-b005ef1b47b27d5c.so --extern hyper=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libhyper-cf1096967127487f.rlib --extern dotenv=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libdotenv-695bff8444756e3d.rlib --extern diesel_codegen=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libdiesel_codegen-8f029d49eb946c25.so --extern nickel=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libnickel-9b9140cf9f498372.rlib --extern diesel=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libdiesel-dbed8681b2d75af8.rlib --extern diesel_pg_test=/home/sblei/Projects/rust_diesel_postgres/target/debug/libdiesel_pg_test.rlib -L native=/home/sblei/Projects/rust_diesel_postgres/target/debug/build/openssl-5464f8f6e728c35a/out -L native=/home/sblei/Projects/rust_diesel_postgres/target/debug/build/openssl-sys-extras-5c7e4d8925825f00/out -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu`
src/bin/try_nickel_https.rs:29:12: 29:24 error: no method named `listen_https` found for type `nickel::Nickel` in the current scope
src/bin/try_nickel_https.rs:29 server.listen_https(&*adr, ssl);
^~~~~~~~~~~~
error: aborting due to previous error
error: Could not compile `diesel_pg_test`.
Caused by:
Process didn't exit successfully: `rustc src/bin/try_nickel_https.rs --crate-name try_nickel_https --crate-type bin -g --cfg feature="hyper" --cfg feature="ssl" --out-dir /home/sblei/Projects/rust_diesel_postgres/target/debug --emit=dep-info,link -L dependency=/home/sblei/Projects/rust_diesel_postgres/target/debug -L dependency=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps --extern dotenv_macros=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libdotenv_macros-b005ef1b47b27d5c.so --extern hyper=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libhyper-cf1096967127487f.rlib --extern dotenv=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libdotenv-695bff8444756e3d.rlib --extern diesel_codegen=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libdiesel_codegen-8f029d49eb946c25.so --extern nickel=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libnickel-9b9140cf9f498372.rlib --extern diesel=/home/sblei/Projects/rust_diesel_postgres/target/debug/deps/libdiesel-dbed8681b2d75af8.rlib --extern diesel_pg_test=/home/sblei/Projects/rust_diesel_postgres/target/debug/libdiesel_pg_test.rlib -L native=/home/sblei/Projects/rust_diesel_postgres/target/debug/build/openssl-5464f8f6e728c35a/out -L native=/home/sblei/Projects/rust_diesel_postgres/target/debug/build/openssl-sys-extras-5c7e4d8925825f00/out -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu` (exit code: 101)
I haven't had a chance to try locally, but at first glance this looks like you just need to amend:
ssl = ["hyper/ssl"]
into:
ssl = ["nickel/ssl", "hyper/ssl"]
As the nickel/ssl
feature also activates hyper/ssl
you probably only need to have the nickel feature active.
Oh yeah. This did it. I thought the nickel/ssl
also got activated, if I execute the binary with --features ssl
.
Never thought about just adding nickel/ssl
to the features-section.
Thank you, @Ryman.
Btw.:
[features]
ssl = ["nickel/ssl"]
... is enough. There's no need to add hyper/ssl
. Maybe it get's invoked by nickel.