{"record":{"id":"50b9b67d748fe51c","repo":"denoland/deno","slug":"unexpected-second-argument-to-deno-bench","errorCode":null,"errorMessage":"Unexpected second argument to Deno.bench()","messagePattern":"Unexpected second argument to Deno\\.bench\\(\\)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cli/js/40_bench.js","lineNumber":146,"sourceCode":"      }\n      if (optionsOrFn.name != undefined) {\n        throw new TypeError(\n          \"Unexpected 'name' field in options, bench name is already provided as the first argument\",\n        );\n      }\n      benchDesc = {\n        ...defaults,\n        ...optionsOrFn,\n        fn: maybeFn,\n        name: nameOrFnOrOptions,\n      };\n    }\n  } else if (typeof nameOrFnOrOptions === \"function\") {\n    if (!nameOrFnOrOptions.name) {\n      throw new TypeError(\"The bench function must have a name\");\n    }\n    if (optionsOrFn != undefined) {\n      throw new TypeError(\"Unexpected second argument to Deno.bench()\");\n    }\n    if (maybeFn != undefined) {\n      throw new TypeError(\"Unexpected third argument to Deno.bench()\");\n    }\n    benchDesc = {\n      ...defaults,\n      fn: nameOrFnOrOptions,\n      name: nameOrFnOrOptions.name,\n    };\n  } else {\n    let fn;\n    let name;\n    if (typeof optionsOrFn === \"function\") {\n      fn = optionsOrFn;\n      if (nameOrFnOrOptions.fn != undefined) {\n        throw new TypeError(\n          \"Unexpected 'fn' field in options, bench function is already provided as the second argument\",\n        );","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/js/40_bench.js#L128-L164","documentation":"In the compiled-binary install path of `deno install -g <url>`, deno resolves the output directory (same `get_installer_bin_dir` logic: `$DENO_INSTALL_ROOT/bin`, default `~/.deno/bin`, or `--root`), verifies existing metadata is a directory, or creates the directory tree when missing. If the path exists but is a file, it aborts before compiling.","triggerScenarios":"`deno install -g <module-url>` (or with `--root`) when the resolved install dir path is occupied by a regular file: `DENO_INSTALL_ROOT` misconfigured to a file path, or a file named `bin` inside the root directory.","commonSituations":"Bad `DENO_INSTALL_ROOT` in CI or container images; `--root` pointing at a file; leftover artifacts from previous experiments occupying the path.","solutions":["Inspect the path: `ls -la \"$DENO_INSTALL_ROOT\"` and check whether a file sits where the `bin` directory should be","Fix `DENO_INSTALL_ROOT` to a directory (deno creates `<root>/bin` automatically if missing)","Delete or move the stray file and re-run the install","Pass `--root <dir>` pointing at the intended install root"],"exampleFix":"# before\n$ DENO_INSTALL_ROOT=~/tools.txt deno install -g https://example.com/cli.ts\n# Installation path is not a directory\n\n# after\n$ DENO_INSTALL_ROOT=~/tools deno install -g https://example.com/cli.ts  # ok","handlingStrategy":"validation","validationCode":"# Ensure the target dir is creatable/is a directory before global install\nBIN_DIR=\"${DENO_INSTALL_ROOT:-$HOME/.deno}\"\nBIN_DIR=\"${BIN_DIR%/bin}/bin\"\nmkdir -p \"$BIN_DIR\" && [ -d \"$BIN_DIR\" ] && deno install -g \"$URL\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize DENO_INSTALL_ROOT on a real directory in dotfiles/CI images","Provision the install root with mkdir -p during environment setup","Never point DENO_INSTALL_ROOT at an existing executable file"],"tags":["install","global-install","install-root","compile"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}