phcode-dev / phoenix

Phoenix is a modern open-source Code Editor for the web, built for the browser.
https://phcode.io
GNU Affero General Public License v3.0
1.72k stars 121 forks source link

Entire project directory fails to load when permission denied to a file #1846

Open nmalinoski opened 1 month ago

nmalinoski commented 1 month ago

Describe the bug

When encountering a file that Phoenix Code does not have permission to read, the entire project fails to load (no files in the file tree, directory does not appear in the project switcher (switcher reads "default project", probably because it's the only other one in the list), Start Project dialog will not open).

Reproduction

  1. Using a Windows host running a Docker container or a VM running Linux, mount a directory on the host in the VM
  2. From within the VM, create a symlink in that mounted directory
    1. Might be sufficient to just change the permissions on any file in the directory so the current user account doesn't have access to it
  3. Attempt to open the directory as a project in Phoenix Code

Expected behavior

The IDE should simply not show the inaccessible file in the file tree and continue to process everything else per usual.

OS, Browser and Phoenix versions

  1. Windows 10 x64, desktop PC
  2. Phoenix Code 3.8.8, 3.9.4 for Windows x64

logs or debug stack trace if any

{
    "name": "EACCES",
    "code": "EACCES",
    "errno": 3,
    "message": "Failed to read directory:  Permission denied: /tauri/C/path/to/project EACCES: permission denied, stat 'C:\\path\\to\\project\\.env'",
    "path": "/tauri/C/path/to/project",
    "stack": "Error: Failed to read directory:  Permission denied: /tauri/C/path/to/project EACCES: permission denied, stat 'C:\\path\\to\\project\\.env'\n    at new n (https://phtauri.localhost/v3.9.4/phoenix/virtualfs.js:1:461316)\n    at e4 (https://phtauri.localhost/v3.9.4/phoenix/virtualfs.js:1:481427)\n    at https://phtauri.localhost/v3.9.4/phoenix/virtualfs.js:1:486521",
    "nodeStack": "Error: EACCES: permission denied, stat 'C:\\path\\to\\project\\.env'\n    at async Object.stat (node:internal/fs/promises:1032:18)"
}

Additional context

I typically work on Laravel webapps where .env is a symlink to one of .env.{local,www_dev,www_prod}. This symlink gets created on the host by a Linux VM, and is ultimately inaccessible/unusable by the host (which is fine for me).

I don't have this problem with Brackets 2.2.1; the .env file simply doesn't show up in the file tree, and neither do the variants. I don't know for sure, but I'm thinking that either Brackets recognizes that the file is inaccessible and just ignores it, or it processes the .gitignore file (which contains entries for .env{,.local,.www_dev,.www_prod}) in the project root first, then just ignores them when it starts reading through the directory.

This is preventing me from migrating from Brackets to Phoenix.

abose commented 1 month ago

Thanks for reporting the issue @nmalinoski . This will be fixed when we address https://github.com/phcode-dev/phoenix/issues/1710 and other file system related issues in the next release or by November release.