Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jdsampayo opened this issue Jan 14, 2025 · 1 comment
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed

Comments

@jdsampayo
Copy link

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

@nathanwhit nathanwhit added bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed labels Jan 15, 2025
@nathanwhit
Copy link
Member

Regressed in ea30e18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed
Projects
None yet
Development

No branches or pull requests

2 participants