Skip to content

cargo run cannot accept non-unicode arguments #2511

Closed
@oconnor663

Description

@oconnor663

Say I write a small program that just prints its args:

fn main() {
    for arg in std::env::args_os() {
        println!("{:?}", arg);
    }
}

Because it uses args_os() instead of args(), this program can handle command line args that aren't valid unicode. However, cargo run chokes:

$ cargo run $(printf '\xff')             
invalid unicode in argument: "\u{fffd}"

I have to invoke the binary directly to test the program:

$ ./target/debug/scratch $(printf '\xff')
"./target/debug/scratch"
"\u{fffd}"

Does Cargo need to inspect the command line args at all? It not, it would be nice if it didn't require them to be utf8.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions