Skip to content

Incorrect name in missing argument error for main command #10191

Closed

Description

@aidalgol

Describe the bug

Invoking a script with no arguments, when it contains a main command that requires a positional parameter, produces an error message referencing main rather than the name of the script.

How to reproduce

Put the following in a file named ./script.nu with the executable bit set.

#!/usr/bin/env nu

def main [foo: string] {
  print $foo
}

Run the script with no arguments.

❯ ./script.nu
Error: nu::parser::missing_positional

  × Missing required positional argument.
   ╭─[<commandline>:1:1]
 1 │ main 
   ·     ▲
   ·     ╰── missing foo
   ╰────
  help: Usage: main <foo>

Expected behavior

For an error message more like this.

Error: nu::parser::missing_positional

  × Missing required positional argument.
   ╭─[<commandline>:1:1]
 1 │ ./script.nu 
   ·     ▲
   ·     ╰── missing foo
   ╰────
  help: Usage: ./script.nu <foo>

Screenshots

No response

Configuration

key value
version 0.84.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.71.1 (eb26296b5 2023-08-03) (built from a source tarball)
cargo_version cargo 1.71.1
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator standard
features default, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. added
    status:needs-triage
    on Sep 2, 2023
  2. added
    A:error-unhelpful
    usage:script-file
    and removed
    status:needs-triage
    on Sep 2, 2023
  3. amtoine commented on Sep 2, 2023

    @amtoine
    Member

    good catch 👌

    #9948 did fix ./script.nu --help which does not mention main anymore, but yeah this kind of errors should also not mention main but rather the name of the script 👍

    @jt, that might be an easy fix?

  4. added a commit that references this issue on Oct 19, 2026
    2deff7f
  5. added this to the v0.117.0 milestone on Oct 19, 2026
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

    A:error-unhelpfulusage:script-file

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions