Skip to content

Deno 2.1.5 attempts to read a locale file as a local path (/x/.../locales/en.json) for yargs, causing an error on GitHub Actions #27672

Closed
@jdsampayo

Description

@jdsampayo

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").

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlydeno_coreChanges in "deno_core" crate are needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions