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

node: Error when running deno run -A npm:firebase-tools #2995

Closed
ayame113 opened this issue Dec 10, 2022 · 1 comment · Fixed by #2996
Closed

node: Error when running deno run -A npm:firebase-tools #2995

ayame113 opened this issue Dec 10, 2022 · 1 comment · Fixed by #2996
Labels
bug Something isn't working needs triage

Comments

@ayame113
Copy link
Contributor

ayame113 commented Dec 10, 2022

I get an error when running firebase cli (npm:firebase-tools) on Windows.

> deno --version
deno 1.28.3 (release, x86_64-pc-windows-msvc)
v8 10.9.194.5
typescript 4.8.3
> deno run -A npm:firebase-tools --version
error: Uncaught NotSupported: The operation is not supported
  Deno.chmodSync(pathModule.toNamespacedPath(path), mode);
       ^
    at Object.chmodSync (deno:runtime/js/30_fs.js:22:9)
    at Object.chmodSync (https://deno.land/[email protected]/node/_fs/_fs_chmod.ts:32:8)
    at Function.writeFileSync [as sync] (file:///C:/Users/ayame/AppData/Local/deno/npm/registry.npmjs.org/write-file-atomic/3.0.3/index.js:236:12)
    at Configstore.set all (file:///C:/Users/ayame/AppData/Local/deno/npm/registry.npmjs.org/configstore/5.0.1/index.js:61:20)
    at Configstore.set (file:///C:/Users/ayame/AppData/Local/deno/npm/registry.npmjs.org/configstore/5.0.1/index.js:91:12)
    at Object.<anonymous> (file:///C:/Users/ayame/AppData/Local/deno/npm/registry.npmjs.org/firebase-tools/11.17.0/lib/track.js:20:31)
    at Object.<anonymous> (file:///C:/Users/ayame/AppData/Local/deno/npm/registry.npmjs.org/firebase-tools/11.17.0/lib/track.js:153:4)
    at Module._compile (deno:ext/node/02_require.js:734:36)
    at Object.Module._extensions..js (deno:ext/node/02_require.js:767:12)
    at Module.load (deno:ext/node/02_require.js:645:34)

I debugged this error and found it was caused by fs.chmodSync() incompatibility on windows. The code below gives an error only on deno.

// import fs from "node:fs";
import fs from "https://deno.land/[email protected]/node/fs.ts";
fs.chmodSync("tmp.txt", 0o0600);
> deno run ./tmp.mjs
error: Uncaught NotSupported: The operation is not supported
    at async Object.chmod (deno:runtime/js/30_fs.js:26:5)

According to denoland/deno#4357 (comment), when you perform an operation that is not available in windows (such as changing read permissions), node does not throw, but deno throws.

@ayame113 ayame113 added bug Something isn't working needs triage labels Dec 10, 2022
@ayame113
Copy link
Contributor Author

According to denoland/deno#4357 (comment), when you perform an operation that is not available in windows (such as changing read permissions), node does not throw, but deno throws.

Introducing this behavior into Deno seems to have been a deliberate decision (denoland/deno#4446).

Perhaps the solution is to enclose the Deno.chmod{,Sync} in the _fs_chmod.ts with try-catch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant