code-server: "Insufficient permission" error on save

  • code-server version: 1.621
  • OS Version: Ubuntu 18.04.2 LTS (on GCP)

Description

Files cannot be saved nor folders cannot be created from the editor. This problem only started to occur on the latest release. (I think)

Steps to Reproduce

  1. Start the server with docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/code-server:1.621 --allow-http --no-auth
  2. Open the editor on another page and try to make change to any file or folder. You will get this error Failed to save 'README.md': Insufficient permissions. Select 'Retry as Sudo' to retry as superuser..

image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 18 (7 by maintainers)

Most upvoted comments

I think @DavisAre’s solution seems like the best path forward here, typically when I’ve needed to edit files from inside a container this has been the recommended approach. The alternative seems to be changing host file permissions which isn’t great…

I will note though that in my case when I try to run it with a forwarded user I get:

ERROR { Error: EACCES: permission denied, mkdir '/.cache'
  [stack]: 'Error: EACCES: permission denied, mkdir \'/.cache\'',
  [message]: 'EACCES: permission denied, mkdir \'/.cache\'',
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/.cache' }
free(): invalid pointer
services:
  visual:
    image: codercom/code-server:latest
    restart: always
    user: "0:0"

It’s not pretty but it solves the issue.

I’ve created an image of my own which uses the coder binary + fixuid and it is working great! I combine that with docker compose commands and I’m able to spin up lots of coder instances for myself and colleagues. Image at https://hub.docker.com/r/acondura/code-server.

I already logged a fix but its stuck at pending for god knows how long.

#679

Ok, I circumvented this by passing -u variables and running as current user. In my case - root. You can also specify other user’s/group’s IDs like -u 1000:1000 docker run -it -p 127.0.0.1:8443:8443 -u $(id -u):$(id -g) -v "${PWD}:/home/coder/project" codercom/code-server:1.621 --allow-http

Might not be the best approach but may be helpful for someone as quick workaround without dealing with directory, file ownership.

Setting wider access settings on those files/directories worked for me - from 664 to 666.

If access rights are not the case, you can use chmod o+w file or chmod o+w -R dir on whole directory if needed. However, mind that this is not the safe solution.

I believe it’s due to trying to edit files by user ‘docker’ or something similar (since we’re operating from inside of the container) and it is not issue with code-server itself.