Skip to content

[bug] tauri-cli incorrectly parses application arguments #5415

@fpgaminer

Description

@fpgaminer

Describe the bug

Running cargo tauri dev -- -- --myoption causes tauri to pass --no-default-features to my application. That means cargo build doesn't get that flag, and it means my application crashes because clap isn't expecting the --no-default-features flag in my application.

This seems to be due to this code:

options.args.push("--no-default-features".into());

After that line the rest of the function splits up args into args and run_args by looking for --. Since --no-default-features is pushed onto args beforehand, it will incorrectly end up in run_args.

Likely the code that pushes --no-default-features should either use an insert to put the flag at the beginning of args, or the push needs to occur after run_args has been split off.

Reproduction

No response

Expected behavior

No response

Platform and versions

Environment
  › OS: Mac OS 12.6.0 X64
  › Node.js: 18.10.0
  › npm: 8.19.2
  › pnpm: Not installed!
  › yarn: Not installed!
  › rustup: 1.25.1
  › rustc: 1.64.0
  › cargo: 1.64.0
  › Rust toolchain: stable-aarch64-apple-darwin 

Packages
  › @tauri-apps/cli [NPM]: 1.1.1
  › @tauri-apps/api [NPM]: 1.1.0
  › tauri [RUST]: 1.1.1,
  › tauri-build [RUST]: 1.1.1,
  › tao [RUST]: 0.14.0,
  › wry [RUST]: 0.21.1,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:1420/
  › framework: React

App directory structure
  ├─ dist
  ├─ node_modules
  ├─ public
  ├─ src-tauri
  ├─ .vscode
  └─ src

Stack trace

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: cliThe tauri-cli rust crate and @tauri-apps/cli npm packagestatus: needs triageThis issue needs to triage, applied to new issuestype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions