Description
Version: Deno 2.1.5 on GitHub Actions (runs-on: ubuntu-latest)
- yargs v17.7.2-deno
When I run a simple yargs-based CLI that has a positional, Deno 2.1.5 tries to load the locale file as a local path /x/[email protected]/locales/en.json
(or C.json if no locale sent) and fails with:
error: Uncaught (in promise) TypeError: Cannot assign to read only property 'code' of object 'NotFound: No such file or directory (os error 2): readfile '/x/[email protected]/locales/en.json''
err.code = 'ENOENT'
^
at Object.readFileSync (https://deno.land/x/[email protected]/lib/platform-shims/deno.ts:13:17)
at Y18N._readLocaleFile (https://deno.land/x/[email protected]/build/lib/index.js:133:47)
at Y18N.__ (https://deno.land/x/[email protected]/build/lib/index.js:24:18)
at Object.self.getPositionalGroupName (https://deno.land/x/[email protected]/build/lib/usage.js:92:16)
at YargsInstance.positional (https://deno.land/x/[email protected]/build/lib/yargs-factory.js:805:81)
Example code:
import yargs from "https://deno.land/x/[email protected]/deno.ts";
yargs(Deno.args)
.locale("en")
.scriptName("my name")
.strict()
.option("verbose", { alias: "v", type: "boolean" })
.command(/* ... */)
.positional("function-name", {
string: true,
describe: "the name of the function",
})
.parse();
Workaround
Pinning Deno to 2.1.4 in the workflow:
- uses: denoland/setup-deno@v2
with:
deno-version: "2.1.4"
resolves the issue—no changes to the code required. In 2.1.4 works even without .locale("en")
.