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

[ERROR] Cannot read directory "..": operation not permitted #7956

Closed
7 tasks done
nmattia opened this issue Apr 29, 2022 · 2 comments
Closed
7 tasks done

[ERROR] Cannot read directory "..": operation not permitted #7956

nmattia opened this issue Apr 29, 2022 · 2 comments

Comments

@nmattia
Copy link

nmattia commented Apr 29, 2022

Describe the bug

When running svelte-kit dev, vite tries to read .. and fails because it does not have permission to access it (the sveltekit bug tracker suggested I open a ticket here).

I'm running node inside a macOS sandbox, which is configured something like this:

(version 1)
(allow default)
(allow network*)
(deny file* (subpath "/Users/nicolas"))
(allow file-read-metadata (subpath "/Users/nicolas"))
(allow file* (subpath "/Users/nicolas/my-project"))
(allow file* (subpath "/Users/nicolas/Library/Caches/node-gyp"))
(allow file* (subpath "/Users/nicolas/Library/Application Support"))

Commands can then be run like this: /usr/bin/sandbox-exec -f <path to profile> npx ....

Effectively, this means that /Users/nicolas/ (which is .. from my project checkout in /Users/nicolas/my-project) is not accessible by node. To make sure that node functions, I'm setting a local config cache:

$ export npm_config_cache=/Users/nicolas/my-project/.npm

When running svelte-kit dev, vite fails because I cannot read the parent directory:

[ERROR] Cannot read directory "..": operation not permitted

1:05:01 PM [vite] error while updating dependencies:
Error: Build failed with 1 error:
error: Cannot read directory "..": operation not permitted
    at failureErrorWithLog (/Users/nicolas/my-project/node_modules/esbuild/lib/main.js:1600:15
)
    at /Users/nicolas/my-project/node_modules/esbuild/lib/main.js:1246:28
    at runOnEndCallbacks (/Users/nicolas/my-project/node_modules/esbuild/lib/main.js:1031:63)
    at buildResponseToResult (/Users/nicolas/my-project/node_modules/esbuild/lib/main.js:1244:
7)
    at /Users/nicolas/my-project/node_modules/esbuild/lib/main.js:1353:14
    at /Users/nicolas/my-project/node_modules/esbuild/lib/main.js:663:9
    at handleIncomingPacket (/Users/nicolas/my-project/node_modules/esbuild/lib/main.js:760:9)
    at Socket.readFromStdout (/Users/nicolas/my-project/node_modules/esbuild/lib/main.js:629:7
)
    at Socket.emit (node:events:520:28)
    at addChunk (node:internal/streams/readable:315:12)

Repro:

  1. Create new svelte-kit project
  2. Create profile.sb as above (replace username and project name)
  3. export npm_config_cache=/Users/$USER/<project>/.npm
  4. /usr/bin/sandbox-exec -f profile.sb npm run dev

Reproduction

See description

System Info

$ npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers
Need to install the following packages:
  envinfo
Ok to proceed? (y) y

  System:
    OS: macOS 12.3.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 1.06 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.14.0 - /nix/store/s9pc5sxyx4cxqq3vyqabjamxjjgpijkb-source/bin/node
    npm: 8.3.1 - /nix/store/s9pc5sxyx4cxqq3vyqabjamxjjgpijkb-source/bin/npm

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

The error comes from esbuild. Does esbuild work in that setup?

@nmattia
Copy link
Author

nmattia commented Jul 18, 2022

I think this was actually fixed there: evanw/esbuild#2261

Sorry for the noise!

@nmattia nmattia closed this as completed Jul 18, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants