ENOENT: no such file or directory, open '/root/.code-server/Backups/workspaces.json'
code-serverversion: v1.31.1-100- OS Version: Ubuntu 18.10
Steps to Reproduce
- use docker to start code-server, wait a while
- and you will see this error:
ERROR SHARED stderr {"data":"Uncaught Exception: Error: ENOENT: no such file or directory, open '/root/.code-server/Backups/workspaces.json'\n\nError: ENOENT: no such file or directory, open '/root/.code-server/Backups/workspaces.json'\n at Timeout.eval [as _onTimeout] (eval at exports.requireModule (/usr/local/bin/code-server:468:27336), <anonymous
>:76664:31)\n at ontimeout (timers.js:498:11)\n at tryOnTimeout (timers.js:323:5)\n at Timer.listOnTimeout (timers.js:
290:5)\n"}
@ndom91 I tried creating the Backups folder with an empty workspace.json but now i get this:
ERROR SHARED stderr {"data":"Uncaught Exception: Error: Unexpected end of JSON input\n\nSyntaxError: Unexpected end of JSON input\n at JSON.parse (<anonymous>)\n at pfs_1.readFile.then.contents (eval at exports.requireModule (/home/cj/vscode/code-server/code-server:468:27660), <anonymous>:77277:45)\n at <anonymous>\n at Timeout.setTimeout [as _onTimeout] (eval at exports.requireModule (/home/cj/vscode/code-server/code-server:468:27660), <anonymous>:52540:31)\n at ontimeout (timers.js:498:11)\n at tryOnTimeout (timers.js:323:5)\n at Timer.listOnTimeout (timers.js:290:5)\n"}
I guess i need a proper workspaces.json? What version are you using? Does anyone know whats in that file? Even better, does anyone have a default one that they can share?
After creating a workspaces.json in the desired directory and filling it with the content
{
"folders": [
{
"path": "/home/<username_redacted>/code-server/workspace/folders"
}
]
}
I get a new error:
ERROR SHARED stderr {"data":"Uncaught Exception: Error: Cannot read property 'map' of undefined\n\nTypeError: Cannot read property 'map' of undefined\n at pfs_1.readFile.then.contents (eval at exports.requireModule (/home/<username_redacted>/code-server/code-server-1.32.0-245-linux-x64/code-server:468:27660), <anonymous>:77278:76)\n at <anonymous>\n at Timeout.setTimeout [as _onTimeout] (eval at exports.requireModule (/home/<username_redacted>/code-server/code-server-1.32.0-245-linux-x64/code-server:468:27660), <anonymous>:52540:31)\n at ontimeout (timers.js:498:11)\n at tryOnTimeout (timers.js:323:5)\n at Timer.listOnTimeout (timers.js:290:5)\n"}
Hmm strange, like I said mine worked while it was empty - as long as it was there. The full command for me was the following:
/opt/vscode-server/code-server /var/www/html -d /home/ndo/.code-server --password=####### --allow-http
OK, I never tried with --allow-http, maybe thats different then. I'll try that later and report back...
Just tried with --allow-http, same error...
Yeah sorry I should have mentioned, I only have allow http because I have it behind a reverse proxy with nginx
Windows with Docker Desktop, similar result...
$ docker run --rm -it -p 8443:8443 -v "${PWD}://root//project" codercom/code-server --allow-http --no-auth -d //root//project
INFO code-server development
INFO Additional documentation: http://github.com/codercom/code-server
INFO Initializing {"data-dir":"/root/project","working-dir":"/root/project","log-dir":"/root/.cache/code-server/logs/20190314233657085"}
INFO Starting shared process [1/5]...
INFO Starting webserver... {"host":"0.0.0.0","port":8443}
WARN No certificate specified. This could be insecure.
WARN Documentation on securing your setup: https://coder.com/docs
WARN Launched without authentication.
INFO
INFO Started (click the link below to open):
INFO http://localhost:8443/
INFO
INFO Connected to shared process
ERROR SHARED stderr {"data":"Uncaught Exception: Error: ENOENT: no such file or directory, open '/root/project/Backups/workspaces.json'\n\nError: ENOENT: no such file or directory, open '/root/project/Backups/workspaces.json'\n at Timeout.setTimeout [as _onTimeout] (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:57561:31)\n at ontimeout (timers.js:498:11)\n at tryOnTimeout (timers.js:323:5)\n at Timer.listOnTimeout (timers.js:290:5)\n"}
^CINFO Starting shared process [1/5]... {"error":"Exited with null"}
INFO Connected to shared process
ERROR SHARED stderr {"data":"Uncaught Exception: Error: ENOENT: no such file or directory, open '/root/project/Backups/workspaces.json'\n\nError: ENOENT: no such file or directory, open '/root/project/Backups/workspaces.json'\n at Timeout.setTimeout [as _onTimeout] (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:57561:31)\n at ontimeout (timers.js:498:11)\n at tryOnTimeout (timers.js:323:5)\n at Timer.listOnTimeout (timers.js:290:5)\n"}
I solved this in Docker on elementaryOS (Linux Desktop)
I tried the following docker-compose setup:
vscode:
image: codercom/code-server
entrypoint: sh -c "mkdir -p /root/.local/share/code-server/Backups/ && touch /root/.local/share/code-server/Backups/workspaces.json && code-server --allow-http"
expose:
- 8443
volumes:
- /home/henry/development:/root/project
restart: always
networks:
- vscode
depends_on:
- nginx-proxy
Notice I just overrode the entrypoint to make the file in question then run code-server
- use directory A as workspace to mount and start the docker, not error
- use directory B as workspace to mount and restart the docker,
ENOENT: no such file or directory, open '/root/.code-server/Backups/workspaces.json - switch back to directory A as workspace to mount and restart, no error
Looks like if you use a new workspace directory, it did not correctly create the workspaces.json?
Having the same issue when using the default Dockerfile.
ERROR SHARED stderr {"data":"Uncaught Exception: Error: ENOENT: no such file or directory, open '/root/.local/share/code-server/Backups/workspaces.json'\n\nError: ENOENT: no such file or directory, open '/root/.local/share/code-server/Backups/workspaces.json'\n at Timeout.setTimeout [as _onTimeout] (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:56921:31)\n at ontimeout (timers.js:498:11)\n at tryOnTimeout (timers.js:323:5)\n at Timer.listOnTimeout (timers.js:290:5)\n"}
If I manually create /root/.local/share/code-server/Backups/workspaces.json, it gives the following error:
ERROR SHARED stderr {"data":"Uncaught Exception: Error: Unexpected end of JSON input\n\nSyntaxError: Unexpected end of JSON input\n at JSON.parse (<anonymous>)\n at pfs_1.readFile.then.contents (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:81639:45)\n at <anonymous>\n at Timeout.setTimeout [as _onTimeout] (eval at exports.requireModule (/usr/local/bin/code-server:468:27625), <anonymous>:56921:31)\n at ontimeout (timers.js:498:11)\n at tryOnTimeout (timers.js:323:5)\n at Timer.listOnTimeout (timers.js:290:5)\n"}
Same error using MacOS Mojave. Running from the binary works even with the same error, so, maybe is related to another thing. 🤔
Anyone found a workaround ?? This problem still exists Tried everything from specifying different folder to creating the file manually.
I always prefer binary file compared to docker. Seems like NO one is able to use the binary file installation.
@adithyau I don't have problems running from the binary one, but from docker. That's curious.
When using the docker command shown on the homepage, I've worked around this error by additionally mounting /root/.local to a path or a volume:
$ docker run -t -p 8443:8443 -v "$(pwd)/.coder:/root/.local" -v "$(pwd):/root/project" codercom/code-server code-server --allow-http --no-auth
Note: above command is insecure, use only for testing locally and always review the security documentation provided.
Cheers.
/root/.local/share/code-server/Backups/workspaces.json Have you tried overwriting the entire file?
This error shouldn't actually cause any issues. Not sure if we should suppress it.
Originally, I couldn't load it out with black screen, but later I updated the configuration of nginx, so that vs code could be loaded out on the web page。

Same error using GCP,
- code-server version: v1.32.0-310
- OS Version:Ubuntu 16.04.1 LTS
Ran into a similar issue, but noticed that when I opened the page in "Incognito" mode, it worked. I suspect that some state is getting saved into the browsers local storage. Clearing it seemed to solve the problem.
In Chrome you can clear a single site with: Developer Tools > Application (tab) > Clear storage
Edit: This is incorrect. As @kylecarbs pointed out below, it's related to an invalid folder. Please ignore.
@mdp that's an issue with opening an invalid folder. We've fixed that on master. Will come in a release later today.