denoland/deno · error · AnyError

unexpected argument '{arg}' found

Error message

unexpected argument '{arg}' found

What it means

dcore accepts exactly one positional argument — the script file to run. The first non-option token becomes file_path; any additional non-option token hits the `file_path.is_some()` guard and bails as unexpected. There is no `--` extra-args passthrough in dcore.

Source

Thrown at libs/dcore/src/main.rs:225

            // `--inspect-brk` is accepted but not wired up to the inspector
            // server, matching the previous clap-based behavior.
            _ => {}
          }
        }
        "--strace-ops" => out.strace_ops = true,
        "--strace-ops-summary" => out.strace_ops_summary = true,
        "--v8-flags" => {
          let Some(value) = value else {
            bail!("equal sign is needed when assigning values to '--v8-flags'");
          };
          out.v8_flags.extend(value.split(',').map(String::from));
        }
        _ if name.starts_with('-') && name != "-" => {
          bail!("unexpected argument '{name}' found");
        }
        _ => {
          if file_path.is_some() {
            bail!("unexpected argument '{arg}' found");
          }
          file_path = Some(arg);
        }
      }
    }

    let Some(file_path) = file_path else {
      bail!(
        "the following required arguments were not provided:\n  <file_path>"
      );
    };
    out.file_path = file_path;
    Ok(Some(out))
  }

  fn inspect(&self) -> Option<(SocketAddr, InspectMode)> {
    let default = || "127.0.0.1:9229".parse::<SocketAddr>().unwrap();
    if let Some(addr) = self.inspect {

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Pass only the entry file: `dcore app.js`.
  2. If you meant an inspect address, use the equals form: `--inspect=host:port`.
  3. If your script needs runtime arguments, read them inside the script (env vars, prompts) — dcore forwards no extra args.

Example fix

# before
dcore --inspect 127.0.0.1:9229 app.js   # address becomes a second positional
# error: unexpected argument '127.0.0.1:9229' found

# after
dcore --inspect=127.0.0.1:9229 app.js
Defensive patterns

Strategy: validation

Validate before calling

# allow exactly one positional argument
pos=0
for a in "$@"; do case "$a" in -*) ;; *) pos=$((pos+1));; esac; done
[ "$pos" -gt 1 ] && { echo "dcore accepts exactly one <file_path>"; exit 2; }

Prevention

When it happens

Trigger: `dcore a.js b.js`; or an option value accidentally detached so it parses as positional — notably `--inspect 127.0.0.1:9229 app.js`, since inspect takes its address only via `=`, leaving the address as a stray second positional.

Common situations: Trying to pass script arguments on the command line; forgetting the `=` on an inspect flag so host:port lands as a positional; wrapper scripts forwarding arbitrary args.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/e3ca8dd6a7b0f34e. Report an issue: GitHub.