code-server: [node.js fs] readdir with filetypes failed with error: [Error: EACCES: permission denied, scandir '/home/coder/project']

OS/Web Information

  • Web Browser: Opera
  • Local OS: Windows 10
  • Remote OS: Synology
  • Remote Architecture: Docker
  • code-server --version: 3.10.2 387b12ef4ca404ffd39d84834e1f0776e9e3c005

Steps to Reproduce

  1. Create code server
  2. Create some file in coder/project
  3. See error in logs

Expected

Files should show up

Actual

Nothing show up but there is file in the file explorer

Logs

[node.js fs] readdir with filetypes failed with error: [Error: EACCES: permission denied, scandir ‘/home/coder/project’] { errno: -13, code: ‘EACCES’, syscall: ‘scandir’, path: ‘/home/coder/project’ }

Screenshot

image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 30 (15 by maintainers)

Most upvoted comments

Alright guys, the same command works perfectly fine on Ubuntu 20.04, but it just won’t work on DSM. I have no idea what the heck is happening…

bruh i miss-click

Yes, thank for your help!

I have just reinstalled the docker… The image works just fine… Even without --pid=host So I guess this is an installation issue?

Strange, maybe wiping Docker clean and re-pulling the images will help?

Interestingly, when I try to install code server out of docker, everything works damn fine, so I guess that’s an issue produced by docker. I will try to debug by reinstalling docker 🙃

Hmm I have no idea why the mounting logic would be different from one image to another. When I try on 3.10.2 with a relative path it breaks just like 3.12.0 does. It seems to be a Docker issue?

Here is what I tried:

$ cd /tmp
$ mkdir test-dir
$ docker run -it --name code-server -p 8080:8080 -v "test-dir:/home/coder/project" codercom/code-server:3.10.2 --auth none
# Browse to localhost:8080
# Create a file using the file explorer in /home/coder/project
# Get "permission denied"

If you use an absolute path instead of relative does it work?

Are you running the exact same command while inside the exact same directory except swapping out code-server:latest for code-server:3.10.2? This seems more likely to be related to Docker than to code-server based on the results so far but if the reproduction steps have changed please post an update!

From what I can tell Docker will only mount the directory if it is an absolute path. However, it will still create the mount path but it will be empty and owned by root (thus permissions are denied).

touch testdir/hello.js also works outside dockerin my case, even in a ubuntu container, but the code-server cannot read the file. But when i try to create a file in code-server, it appears both in the server and the mounted folder

Interesting, using an absolute path works (notice $PWD/test-dir instead of test-dir):

docker run -it --name code-server -p 8080:8080 \
  -v "$PWD/test-dir:/home/coder/project"
  codercom/code-server:latest --auth none

Huh, this is weird, I am not getting the permission error in the console but I am unable to view or create files in the project directory.

Replicated in a Coder environment with this:

cd /tmp
mkdir test-dir
docker run -it --name code-server -p 8080:8080 \
  -v "test-dir:/home/coder/project"
  codercom/code-server:latest --auth none
# 1. Open 8080 in a browser
# 2. Browse to the project directory
# 3. Create or edit a file

I am able to touch test-dir/hello outside of Docker so I have permissions.

$ whoami
coder
$ touch /tmp/test-dir/hello
$ ls -la /tmp/test-dir
total 8
drwxrwxr-x   2 coder          coder    4096 2021-09-17 12:16 .
drwxrwxrwt   1 root           root     4096 2021-09-17 12:09 ..
-rw-rw-r--   1 coder          coder       0 2021-09-17 12:16 hello

Here is full log after startup, with the latest version

[main 2021-09-17T11:04:48.868Z] [File Watcher (chokidar)] Inotify limit reached (ENOSPC)
[main 2021-09-17T11:04:48.875Z] [File Watcher (chokidar)] Inotify limit reached (ENOSPC)
[2021-09-17T11:05:49.376Z] info  code-server 3.12.0 2661a690ac228872e8d1dc28ab6d33e8afc30add
[2021-09-17T11:05:49.386Z] info  Using user-data-dir ~/.local/share/code-server
[2021-09-17T11:05:49.434Z] info  Using config file ~/.config/code-server/config.yaml
[2021-09-17T11:05:49.434Z] info  HTTP server listening on http://0.0.0.0:8080 
[2021-09-17T11:05:49.435Z] info    - Authentication is enabled
[2021-09-17T11:05:49.435Z] info      - Using password from $PASSWORD
[2021-09-17T11:05:49.436Z] info    - Not serving HTTPS 
[2021-09-17T11:05:57.438Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:121:19)
    at VscodeProvider.sendWebsocket (/usr/lib/code-server/out/node/vscode.js:117:14)
    at async /usr/lib/code-server/out/node/routes/vscode.js:205:5
[2021-09-17T11:05:57.476Z] error vscode is not running Error: vscode is not running
    at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:121:19)
    at VscodeProvider.sendWebsocket (/usr/lib/code-server/out/node/vscode.js:117:14)
    at async /usr/lib/code-server/out/node/routes/vscode.js:205:5
[main 2021-09-17T11:06:06.950Z] [File Watcher (chokidar)] Inotify limit reached (ENOSPC)
[main 2021-09-17T11:06:06.953Z] [File Watcher (chokidar)] Inotify limit reached (ENOSPC)
[node.js fs] readdir with filetypes failed with error:  [Error: EACCES: permission denied, scandir '/home/coder/project'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/coder/project'
}

The error changes after updating to latest

I hear ya but we cannot reproduce with the information you have provided so more information (like the commands you use to run the code-server Docker images) may help us identify the issue.

Hi there Yes i know it is a perm issue but my another code-server with the same version work perfectly fine