Skip to content

REPL error "only the last flag can take args" for a short flag with an argument not separated by a space #19639

Done

Description

@MetaflameDragon

Bug report form

  • I have done a basic search of the issue tracker to find any existing issues that are similar.
  • I have checked that my version is at least the latest stable release available via my installation method.

Describe the bug

After I installed completions for cargo:

let dir = $nu.user-autoload-dirs | first; mkdir $dir; generate completions 'cargo' | save --force ($dir | path join cargo.nu)

the following stopped working:

V:\tmp> cargo -Zscript fp_asm.rs
Error: nu::parser::only_last_flag_in_batch_can_take_arg

  × Only the last flag in a short flag batch can take an argument.
   ╭─[repl_entry #3:1:8]
 1 │ cargo -Zscript fp_asm.rs
   ·        ┬
   ·        ╰── only the last flag can take args
   ╰────

Separating the arg (-Z script) still works. Without the completions installed, the REPL doesn't complain, and the joined arg (Zscript) works just fine.

How to reproduce

  1. Install completions for cargo:
let dir = $nu.user-autoload-dirs | first; mkdir $dir; generate completions 'cargo' | save --force ($dir | path join cargo.nu)
  1. Attempt to run cargo with a flag with args, placing the arg directly after the flag, e.g. cargo -Zscript test.rs. This should start showing a repl error, and fail when executed. Running the command with the argument separated, cargo -Z script test.rs, does not fail.
  2. Try to run the same command without completions installed. The command should execute without issue in both cases.

Expected behavior

The REPL should parse and allow short flags with arguments directly after them. I believe that entering the argument without a separating space is quite common, cargo parses it correctly, and the Cargo book lists both examples (-Zscript example here).

Configuration

key value
version 0.117.1
major 0
minor 117
patch 1
branch main
commit_hash 3d8a9cc
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.102.0-nightly (5f4effd57 2026-11-13)
rust_channel nightly-x86_64-pc-windows-msvc
cargo_version cargo 1.102.0-nightly (ede6cefea 2026-11-11)
build_time 2026-11-19 21:00:50 +01:00
build_rust_channel release
allocator standard
features dap, default, full, lsp, mcp, network, plugin, rustls-tls, sqlite, system-clipboard, trash-support
installed_plugins dns 4.0.9, formats 0.105.1, gstat 0.105.1, inc 0.105.1, polars 0.105.1, query 0.105.1
experimental_options example=false, dc-glob=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=true, native-clip=false, cell-path-types=false

Activity

  1. added
    status:needs-triage
    on Nov 22, 2026
  2. fdncred commented on Nov 23, 2026

    @fdncred
    Contributor

    Looking into this

  3. fdncred commented on Nov 23, 2026

    @fdncred
    Contributor

    Can you test this to see if it helps #19642 ?

  4. added this to the v0.118.0 milestone on Nov 24, 2026
  5. added a commit that references this issue on Nov 24, 2026
    a349f32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions