CLI arguments ignored for crate added with cargo install

I have following socket server launcher:

use std::{env, io::Result, net::TcpListener, thread};

fn main() -> Result<()> {
    let address = format!(
        "{}:{}",
        env::args().nth(1).unwrap(),
        env::args().nth(2).unwrap()
    );
// ..

running it without any problems using cargo run -- 127.0.0.1 4321 in development folder

but can't apply arguments with crate_name -- 127.0.0.1 4321 command (when crate installed with cargo install globally)

Following message mean that CLI arguments skipped or index order was changed (e.g. argument #0 not exist anymore, I don't know how to dump):
Error: Error { kind: InvalidInput, message: "invalid port value" }

Should I change something in the profile or just change something in code?
Thanks

Leave out the -- when running your binary. The -- is to separate the Cargo args from your binary's args.

3 Likes

Aw, so simple, thank you much!

1 Like