Cargo install --path . fails where cargo build --release succeeds

With the following Cargo.toml file:

[package]
name = "something"
version = "0.1.0"
authors = ["Nathan A Sculli <nathan@vegasbuckeye.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
config = "^0.10"
chrono = { version = "0.4", features = ["serde"] }
diesel = { version = "^1.4", features = ["chrono", "mysql", "r2d2"] }
dotenv = "0.15.0"
env_logger = "0.7.1"
log = "0.4"
r2d2 = "0.8"
scrypt = "0.2"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
tokio = "0.2.0-alpha.6"
tokio-executor = "=0.2.0-alpha.6"
uuid = { version = "0.8", features = ["v4", "serde"] }
warp = { git = "https://github.com/seanmonstar/warp.git", branch = "master" }

cargo install --path . fails to compile with the following error

error[E0433]: failed to resolve: could not find `main` in `tokio`
  --> src/main.rs:80:10
   |
80 | #[tokio::main]
   |          ^^^^ could not find `main` in `tokio`

error[E0277]: `main` has invalid return type `impl core::future::future::Future`
  --> src/main.rs:81:17
   |
81 | async fn main() {
   |                 ^ `main` can only return types that implement `std::process::Termination`
   |
   = help: consider using `()`, or a `Result`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0433.
For more information about an error, try `rustc --explain E0277`.
error: failed to compile `something v0.1.0 (/opt/something)`, intermediate artifacts can be found at `/opt/something/target`

Caused by:
  could not compile `something`.

To learn more, run the command again with --verbose.

However, running cargo build --release compiles sucessfully. I'm lost...

Try using --locked as well, cargo install ignores the lockfile by default and will be pulling in the released version of Tokio 0.2 instead of the alpha you specify.

1 Like

If you still want to use the alpha instead of the released version, lock the version with "=0.2.0-alpha.6"

1 Like

Thank you @Nemo157 and @alice. I ended up doing a combination of both solutions, I added the --locked flag into our Dockerfile so that we shouldn't have an issue like this in the future. Also, I upgraded the pointer for warp so that I can use the latest version of tokio and remove the alpha dependencies. (living on the bleeding edge is fun :stuck_out_tongue:)