Comments (17)
Sometimes it's related to your terminal (such as zsh
). Try wrapping it into quotes: --allow-fs-write="/Users/skypesky/workSpaces/javascript/github/temp/*"
from node.
Actually, thinking more about it... It's not a bug,
temp
never existed, so the system cannot identify iftemp
is supposed to be a folder or just a filetemp
.I'm pretty sure if you try to create a file
/Users/skypesky/workSpaces/javascript/github/temp
it will work with success.Hence, for non-existent folders you must add the wildcard: *.
But give then case:
node --experimental-permission --allow-fs-write=$PWD/foo --allow-fs-read=$PWD/test.js test.js
const { mkdir } = require('node:fs/promises');
(async () => {
await mkdir('./foo/', { recursive: true });
await mkdir('./foo/tmp/a/b/c/d', { recursive: true });
})();
The folder is created succesfully so it should word
PS: Accidentally closed
from node.
IIRC, when the permission model is being initialized, it implicitly adds wildcards to the end of paths that are (existing) directories. If $PWD/foo
does not exist, no wildcard is implicitly added, so the permission model only allows access to the exact path $PWD/foo
.
from node.
I'm going to close it as this is expected behaviour. Feel free to re-open if something is misleading.
from node.
Thanks for the explanation @tniessen @RafaelGSS I traced to is_granted
method in fs_permission.cc
and found out it was cached. I am thinking this probably should be documented in the Limitations and Known Issues section of the api/permissions
doc? (👍 or 👎)
from node.
It's not a limitation as it's designed to work in that way. We could mention it on https://nodejs.org/api/permissions.html#file-system-permissions specifically on wildcard mention.
from node.
You have set allow-write to /Users/skypesky/workSpaces/javascript/github/temp
and trying to write on
/Users/skypesky/workSpaces/javascript/github/tmp/
it's working as supposed, you need set write-permission to /Users/skypesky/workSpaces/javascript/github/tmp
from node.
@marco-ippolito
please ignore my spelling mistakes, this is indeed a bug, here is a screenshot.
from node.
does the folder temp
exists?
from node.
- The temp folder does not exist! Specifically, I can actually create temp successfully, but I cannot create subfolders of temp.
const { mkdir } = require('node:fs/promises');
(async () => {
await mkdir('/Users/skypesky/workSpaces/javascript/github/temp', { recursive: true }); // exec ok!
await mkdir('/Users/skypesky/workSpaces/javascript/github/temp/a/b/c/d', { recursive: true }); // exec failed!!!
})();
from node.
does the folder
temp
exists? if not it wont work To create the foldertemp
you need to have write access in the parent directory for example:/Users/skypesky/workSpaces/javascript/github/
I do not want it to have the permission to write data in this folder on github, this is not what we intended.
from node.
I can reproduce, I confirm its a bug @RafaelGSS
node --experimental-permission --allow-fs-write=$PWD/foo --allow-fs-read=$PWD/test.js test.js
const { mkdir } = require('node:fs/promises');
(async () => {
await mkdir('./foo/', { recursive: true });
await mkdir('./foo/tmp/a/b/c/d', { recursive: true });
})();
from node.
Meanwhile, can you try adding a *
after temp
? --allow-fs-write=/Users/skypesky/workSpaces/javascript/github/temp/*
Anyway, I'll fix it.
from node.
Just tested it this as well, if adding *
after temp
it will say no matches found: --allow-fs-write=/file path/
from node.
Thanks, it was my terminal (zsh), after adding *
it works, it can create the folders recursively.
from node.
Actually, thinking more about it... It's not a bug, temp
never existed, so the system cannot identify if temp
is supposed to be a folder or just a file temp
.
I'm pretty sure if you try to create a file /Users/skypesky/workSpaces/javascript/github/temp
it will work with success.
Hence, for non-existent folders you must add the wildcard: *.
from node.
IIRC, when the permission model is being initialized, it implicitly adds wildcards to the end of paths that are (existing) directories. If
$PWD/foo
does not exist, no wildcard is implicitly added, so the permission model only allows access to the exact path$PWD/foo
.
That's correct. If you created $PWD/foo
folder during runtime, the permission model won't be able to identify if that's a folder and add the wildcard.
from node.
Related Issues (20)
- 52 bits support to Buffer.write(U)Int(LE|BE) HOT 1
- `sqlite` repo label HOT 4
- Hey-c6fc3
- Spelling Mistake On Readme HOT 2
- `napi_create_external_buffer` is super slow HOT 1
- FinalizationRegistry is not working for Timeout Object correctly, but WeakRef works fine HOT 4
- Erronous import failure message HOT 12
- test_runner: using module mocking confuses all future esm imports to use cjs path resolution HOT 3
- fetch failed with TypeError: Class extends value #<newConstructor> is not a constructor or null HOT 3
- v22.4.1 C++ addon incurs segmentation faults HOT 5
- Security question: Why are data: URIs and file: URIs treated differently in your security policy? HOT 5
- `ReadableStream.from({})` returns confusing error HOT 7
- `fsPromises.glob` doesn't call `exclude` with dirent when called `withFileTypes: true` HOT 3
- Web change HOT 2
- Add `--root-directory` optional flag for `node --run` HOT 4
- Easier MultiDimensional Array's HOT 2
- Support for running bin scripts using `node --run` HOT 4
- test: parallel/test-worker-node-options fails on IBM i HOT 1
- Got failure message - "FailureMessage Object: 0x7fedbceff920" HOT 1
- When `ReadableStream` read fails, stack trace does not include the line responsible HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node.