You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Another Sudo User Can Not Install Extensions #7358
Running code-server by another sudo user(not root) does not allow for the installation of extensions and shows error 403 on the UI.
Run code-server --install-extension extension_id with or without sudo by the user, installs the extensions in /root/.local/share/code-server/extensions.
The only way is to change the owner of ~/.local/share/code-server/extensions and install the extension by importing the .vsix file. Still get error 403 with changing the owner.
Expected
I run code-server as another sudo user and I was expected to install extensions through UI easily.
Actual
It gives me error 403 on the UI and does not allow me to install any extension.
Logs
Screenshot/Video
No response
Does this bug reproduce in native VS Code?
No, this works as expected in native VS Code
Does this bug reproduce in GitHub Codespaces?
I did not test GitHub Codespaces
Are you accessing code-server over a secure context?
There is a question. Why does code-server not install the extensions in the user folder(~/.local/share/code-server/extensions) when I run code-server as another user(not root)?
By default, it should install extensions in that user's home directory (see user-data-dir). For example with sudo:
$ sudo /tmp/code-server/bin/code-server
[2025-06-02T19:26:40.900Z] info code-server 4.100.2 9dd999ba78032163d606fadd531de5e1fcae5443
[2025-06-02T19:26:40.901Z] info Using user-data-dir /root/.local/share/code-server
[2025-06-02T19:26:40.910Z] info Using config file /root/.config/code-server/config.yaml
And without sudo:
$ /tmp/code-server/bin/code-server
[2025-06-02T19:26:48.160Z] info code-server 4.100.2 9dd999ba78032163d606fadd531de5e1fcae5443
[2025-06-02T19:26:48.161Z] info Using user-data-dir /home/coder/.local/share/code-server
[2025-06-02T19:26:48.172Z] info Using config file /home/coder/.config/code-server/config.yaml
If your non-sudo command is still using /root/.local, I would guess that either --user-data-dir or --extensions-dir is set (either as a flag or in the config file), or the non-root user's home is /root for some reason?
$ sudo printenv HOME
/root
$ printenv HOME
/home/coder
What do you get for the above commands? And what do the permissions of all the related directories look like?
/tmp/code-server/bin/code-server is not exist.
I have a code-server executable binary file /usr/bin/code-server but I am not sure it is the executer file or not.
Code-server is running as a service with my sudo_user(not root).
Status of my service is:
● code-server.service - Code Server
Loaded: loaded (/etc/systemd/system/code-server.service; enabled; preset: enabled)
Active: active (running) since Mon 2025-06-02 09:56:21 UTC; 1 day 23h ago
Main PID: 2010591 (node)
Tasks: 79 (limit: 4540)
Memory: 937.1M (peak: 2.3G)
CPU: 1h 59min 1.854s
CGroup: /system.slice/code-server.service
├─2010591 /usr/lib/code-server/lib/node /usr/lib/code-server --host 127.0.0.1 --port 8080
├─2010609 /usr/lib/code-server/lib/node /usr/lib/code-server/out/node/entry
├─2013065 /usr/lib/code-server/lib/node /usr/lib/code-server/lib/vscode/out/bootstrap-fork --type=ptyHost --logsPath /home/sudo_user/.local/share/code-server/logs/20250602T095628
And:
$ sudo printenv HOME
/root
$ printenv HOME
/home/sudo_user
Oh right yeah sorry /tmp/code-server/bin/code-server is just where I have mine, it is not a common place for it.
Hmm yeah I would expect extensions to be in /home/sudo_user/.local/share/code-server/extensions, in that case. But you say it is trying to use /root/.local/share/code-server/extensions? Can you post the code-server output from the journal?
In the beginning, it could not install extensions, and I got an error of 403. But the root directory had the extensions I wanted to install with sudo_user. I think each time I try to install an extension for sudo_user, when a 403 error happens, it installs it for the root user.
After I changed the owner of /home/sudo_user/.local/share/code-server/extensions to sudo_user, it can execute and install extensions of sudo_user.
It's weird.
Jun 03 07:28:51 ubuntu code-server[2010591]: [07:28:51] [127.0.0.1][6dc6b42a][ExtensionHostConnection] The client has reconnected.
Jun 03 07:28:55 ubuntu code-server[2010591]: [07:28:55] [127.0.0.1][1ed8cdfa][ManagementConnection] The client has reconnected.
Jun 03 07:32:04 ubuntu code-server[2010591]: [07:32:04] [127.0.0.1][6dc6b42a][ExtensionHostConnection] The client has reconnected.
Jun 03 07:32:11 ubuntu code-server[2010591]: [07:32:11] [127.0.0.1][1ed8cdfa][ManagementConnection] The client has reconnected.
Jun 03 08:43:05 ubuntu code-server[2010591]: [08:43:05] [File Watcher (node.js)] Watcher shutdown because watched path got deleted
Jun 03 08:49:40 ubuntu code-server[2010591]: [08:49:40] [File Watcher (node.js)] Watcher shutdown because watched path got deleted
Jun 03 11:35:55 ubuntu code-server[2010591]: [11:35:55] [127.0.0.1][6dc6b42a][ExtensionHostConnection] The client has reconnected.
Jun 03 11:35:59 ubuntu code-server[2010591]: [11:35:59] [127.0.0.1][1ed8cdfa][ManagementConnection] The client has reconnected.
Jun 03 11:59:55 ubuntu sudo[2230388]: sudo_user : TTY=pts/7 ; PWD=/var/www/AF_project ; USER=root ; COMMAND=/usr/bin/nano /etc/postgresql/16/main/postgresql.conf
Jun 03 11:59:55 ubuntu sudo[2230388]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Jun 03 12:06:14 ubuntu code-server[2010591]: [12:06:14] [File Watcher (node.js)] Watcher shutdown because watched path got deleted
Jun 03 12:07:21 ubuntu sudo[2230388]: pam_unix(sudo:session): session closed for user root
Jun 03 12:07:29 ubuntu sudo[2232400]: sudo_user : TTY=pts/7 ; PWD=/var/www/AF_project ; USER=root ; COMMAND=/usr/bin/nano /etc/postgresql/16/main/pg_hba.conf
Jun 03 12:07:29 ubuntu sudo[2232400]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Jun 03 12:08:12 ubuntu sudo[2232400]: pam_unix(sudo:session): session closed for user root
Jun 03 12:08:15 ubuntu sudo[2232623]: sudo_user : TTY=pts/7 ; PWD=/var/www/AF_project ; USER=root ; COMMAND=/usr/bin/systemctl restart postgresql
Jun 03 12:08:15 ubuntu sudo[2232623]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Jun 03 12:08:22 ubuntu sudo[2232623]: pam_unix(sudo:session): session closed for user root
Jun 03 12:45:18 ubuntu code-server[2010591]: [12:45:18] [File Watcher (node.js)] Watcher shutdown because watched path got deleted
Jun 03 15:18:25 ubuntu code-server[2010591]: [15:18:25] [127.0.0.1][1ed8cdfa][ManagementConnection] The client has disconnected, will wait for reconnection 3h before disposing...
Jun 03 18:18:10 ubuntu code-server[2010591]: [18:18:10] [127.0.0.1][6dc6b42a][ExtensionHostConnection] <2174146> Extension Host Process exited with code: 0, signal: null.
Jun 03 18:18:33 ubuntu code-server[2010591]: [18:18:33] [127.0.0.1][1ed8cdfa][ManagementConnection] The reconnection grace time of 3h has expired, so the connection will be disposed.
Jun 06 08:43:45 ubuntu code-server[2010591]: File not found: /usr/lib/code-server/lib/vscode/node_modules/vsda/rust/web/vsda_bg.wasm
Jun 06 08:43:45 ubuntu code-server[2010591]: File not found: /usr/lib/code-server/lib/vscode/node_modules/vsda/rust/web/vsda.js
Jun 06 08:43:45 ubuntu code-server[2010591]: [08:43:45] [127.0.0.1][3982a23f][ManagementConnection] New connection established.
Jun 06 08:43:47 ubuntu code-server[2010591]: [08:43:47] [127.0.0.1][f11a8fd9][ExtensionHostConnection] New connection established.
Jun 06 08:43:47 ubuntu code-server[2010591]: [08:43:47] [127.0.0.1][f11a8fd9][ExtensionHostConnection] <2340489> Launched Extension Host Process.
Jun 06 08:43:53 ubuntu code-server[2010591]: [08:43:53] Getting Manifest... bradlc.vscode-tailwindcss
Jun 06 08:43:53 ubuntu code-server[2010591]: [08:43:53] Installing extension: bradlc.vscode-tailwindcss {
Jun 06 08:43:53 ubuntu code-server[2010591]: productVersion: { version: '1.95.3', date: '2024-11-15T19:35:09.428Z' },
Jun 06 08:43:53 ubuntu code-server[2010591]: pinned: false,
Jun 06 08:43:53 ubuntu code-server[2010591]: operation: 3,
Jun 06 08:43:53 ubuntu code-server[2010591]: isApplicationScoped: false,
Jun 06 08:43:53 ubuntu code-server[2010591]: installOnlyNewlyAddedFromExtensionPack: true,
Jun 06 08:43:53 ubuntu code-server[2010591]: profileLocation: gr {
Jun 06 08:43:53 ubuntu code-server[2010591]: scheme: 'file',
Jun 06 08:43:53 ubuntu code-server[2010591]: authority: '',
Jun 06 08:43:53 ubuntu code-server[2010591]: path: '/home/sudo_user/.local/share/code-server/extensions/extensions.json',
Jun 06 08:43:53 ubuntu code-server[2010591]: query: '',
Jun 06 08:43:53 ubuntu code-server[2010591]: fragment: '',
Jun 06 08:43:53 ubuntu code-server[2010591]: _formatted: 'file:///home/sudo_user/.local/share/code-server/extensions/extensions.json',
Jun 06 08:43:53 ubuntu code-server[2010591]: _fsPath: '/home/sudo_user/.local/share/code-server/extensions/extensions.json'
Jun 06 08:43:53 ubuntu code-server[2010591]: }
Jun 06 08:43:53 ubuntu code-server[2010591]: }
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Could not load vsce-sign module Cannot find package '@vscode/vsce-sign' imported from /usr/lib/code-server/lib/vscode/out/server-main.js
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Extension signature verification is not done: bradlc.vscode-tailwindcss
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Extracted extension to file:///home/sudo_user/.local/share/code-server/extensions/bradlc.vscode-tailwindcss-0.14.21-universal: bradlc.vscode-tailwindcss
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Renamed to /home/sudo_user/.local/share/code-server/extensions/bradlc.vscode-tailwindcss-0.14.21-universal
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Marked extension as uninstalled bradlc.vscode-tailwindcss-0.14.20-universal
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Extension installed successfully: bradlc.vscode-tailwindcss file:///home/sudo_user/.local/share/code-server/extensions/extensions.json
The problem was unexpected, but I am grateful to find a solution for it.
It is a great tool, and it helps me a lot to work with my server when I encounter network/vpn restrictions.
Activity
code-asher commentedon May 27, 2025
code-server runs everything as the user and it will not try to elevate permissions.
The best fix is probably to use use group permissions, if you need multiple users modifying the same directory.
navidbakhtiary commentedon Jun 2, 2025
There is a question. Why does code-server not install the extensions in the user folder(~/.local/share/code-server/extensions) when I run code-server as another user(not root)?
code-asher commentedon Jun 2, 2025
By default, it should install extensions in that user's home directory (see
user-data-dir). For example with sudo:And without sudo:
If your non-sudo command is still using
/root/.local, I would guess that either--user-data-diror--extensions-diris set (either as a flag or in the config file), or the non-root user's home is/rootfor some reason?What do you get for the above commands? And what do the permissions of all the related directories look like?
navidbakhtiary commentedon Jun 4, 2025
/tmp/code-server/bin/code-server is not exist.
I have a code-server executable binary file /usr/bin/code-server but I am not sure it is the executer file or not.
Code-server is running as a service with my sudo_user(not root).
Status of my service is:
And:
$ sudo printenv HOME
/root
$ printenv HOME
/home/sudo_user
code-asher commentedon Jun 4, 2025
Oh right yeah sorry
/tmp/code-server/bin/code-serveris just where I have mine, it is not a common place for it.Hmm yeah I would expect extensions to be in
/home/sudo_user/.local/share/code-server/extensions, in that case. But you say it is trying to use/root/.local/share/code-server/extensions? Can you post the code-server output from the journal?navidbakhtiary commentedon Jun 6, 2025
In the beginning, it could not install extensions, and I got an error of 403. But the root directory had the extensions I wanted to install with sudo_user. I think each time I try to install an extension for sudo_user, when a 403 error happens, it installs it for the root user.
After I changed the owner of /home/sudo_user/.local/share/code-server/extensions to sudo_user, it can execute and install extensions of sudo_user.
It's weird.
Jun 03 07:28:51 ubuntu code-server[2010591]: [07:28:51] [127.0.0.1][6dc6b42a][ExtensionHostConnection] The client has reconnected.
Jun 03 07:28:55 ubuntu code-server[2010591]: [07:28:55] [127.0.0.1][1ed8cdfa][ManagementConnection] The client has reconnected.
Jun 03 07:32:04 ubuntu code-server[2010591]: [07:32:04] [127.0.0.1][6dc6b42a][ExtensionHostConnection] The client has reconnected.
Jun 03 07:32:11 ubuntu code-server[2010591]: [07:32:11] [127.0.0.1][1ed8cdfa][ManagementConnection] The client has reconnected.
Jun 03 08:43:05 ubuntu code-server[2010591]: [08:43:05] [File Watcher (node.js)] Watcher shutdown because watched path got deleted
Jun 03 08:49:40 ubuntu code-server[2010591]: [08:49:40] [File Watcher (node.js)] Watcher shutdown because watched path got deleted
Jun 03 11:35:55 ubuntu code-server[2010591]: [11:35:55] [127.0.0.1][6dc6b42a][ExtensionHostConnection] The client has reconnected.
Jun 03 11:35:59 ubuntu code-server[2010591]: [11:35:59] [127.0.0.1][1ed8cdfa][ManagementConnection] The client has reconnected.
Jun 03 11:59:55 ubuntu sudo[2230388]: sudo_user : TTY=pts/7 ; PWD=/var/www/AF_project ; USER=root ; COMMAND=/usr/bin/nano /etc/postgresql/16/main/postgresql.conf
Jun 03 11:59:55 ubuntu sudo[2230388]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Jun 03 12:06:14 ubuntu code-server[2010591]: [12:06:14] [File Watcher (node.js)] Watcher shutdown because watched path got deleted
Jun 03 12:07:21 ubuntu sudo[2230388]: pam_unix(sudo:session): session closed for user root
Jun 03 12:07:29 ubuntu sudo[2232400]: sudo_user : TTY=pts/7 ; PWD=/var/www/AF_project ; USER=root ; COMMAND=/usr/bin/nano /etc/postgresql/16/main/pg_hba.conf
Jun 03 12:07:29 ubuntu sudo[2232400]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Jun 03 12:08:12 ubuntu sudo[2232400]: pam_unix(sudo:session): session closed for user root
Jun 03 12:08:15 ubuntu sudo[2232623]: sudo_user : TTY=pts/7 ; PWD=/var/www/AF_project ; USER=root ; COMMAND=/usr/bin/systemctl restart postgresql
Jun 03 12:08:15 ubuntu sudo[2232623]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Jun 03 12:08:22 ubuntu sudo[2232623]: pam_unix(sudo:session): session closed for user root
Jun 03 12:45:18 ubuntu code-server[2010591]: [12:45:18] [File Watcher (node.js)] Watcher shutdown because watched path got deleted
Jun 03 15:18:25 ubuntu code-server[2010591]: [15:18:25] [127.0.0.1][1ed8cdfa][ManagementConnection] The client has disconnected, will wait for reconnection 3h before disposing...
Jun 03 18:18:10 ubuntu code-server[2010591]: [18:18:10] [127.0.0.1][6dc6b42a][ExtensionHostConnection] <2174146> Extension Host Process exited with code: 0, signal: null.
Jun 03 18:18:33 ubuntu code-server[2010591]: [18:18:33] [127.0.0.1][1ed8cdfa][ManagementConnection] The reconnection grace time of 3h has expired, so the connection will be disposed.
Jun 06 08:43:45 ubuntu code-server[2010591]: File not found: /usr/lib/code-server/lib/vscode/node_modules/vsda/rust/web/vsda_bg.wasm
Jun 06 08:43:45 ubuntu code-server[2010591]: File not found: /usr/lib/code-server/lib/vscode/node_modules/vsda/rust/web/vsda.js
Jun 06 08:43:45 ubuntu code-server[2010591]: [08:43:45] [127.0.0.1][3982a23f][ManagementConnection] New connection established.
Jun 06 08:43:47 ubuntu code-server[2010591]: [08:43:47] [127.0.0.1][f11a8fd9][ExtensionHostConnection] New connection established.
Jun 06 08:43:47 ubuntu code-server[2010591]: [08:43:47] [127.0.0.1][f11a8fd9][ExtensionHostConnection] <2340489> Launched Extension Host Process.
Jun 06 08:43:53 ubuntu code-server[2010591]: [08:43:53] Getting Manifest... bradlc.vscode-tailwindcss
Jun 06 08:43:53 ubuntu code-server[2010591]: [08:43:53] Installing extension: bradlc.vscode-tailwindcss {
Jun 06 08:43:53 ubuntu code-server[2010591]: productVersion: { version: '1.95.3', date: '2024-11-15T19:35:09.428Z' },
Jun 06 08:43:53 ubuntu code-server[2010591]: pinned: false,
Jun 06 08:43:53 ubuntu code-server[2010591]: operation: 3,
Jun 06 08:43:53 ubuntu code-server[2010591]: isApplicationScoped: false,
Jun 06 08:43:53 ubuntu code-server[2010591]: installOnlyNewlyAddedFromExtensionPack: true,
Jun 06 08:43:53 ubuntu code-server[2010591]: profileLocation: gr {
Jun 06 08:43:53 ubuntu code-server[2010591]: scheme: 'file',
Jun 06 08:43:53 ubuntu code-server[2010591]: authority: '',
Jun 06 08:43:53 ubuntu code-server[2010591]: path: '/home/sudo_user/.local/share/code-server/extensions/extensions.json',
Jun 06 08:43:53 ubuntu code-server[2010591]: query: '',
Jun 06 08:43:53 ubuntu code-server[2010591]: fragment: '',
Jun 06 08:43:53 ubuntu code-server[2010591]: _formatted: 'file:///home/sudo_user/.local/share/code-server/extensions/extensions.json',
Jun 06 08:43:53 ubuntu code-server[2010591]: _fsPath: '/home/sudo_user/.local/share/code-server/extensions/extensions.json'
Jun 06 08:43:53 ubuntu code-server[2010591]: }
Jun 06 08:43:53 ubuntu code-server[2010591]: }
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Could not load vsce-sign module Cannot find package '@vscode/vsce-sign' imported from /usr/lib/code-server/lib/vscode/out/server-main.js
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Extension signature verification is not done: bradlc.vscode-tailwindcss
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Extracted extension to file:///home/sudo_user/.local/share/code-server/extensions/bradlc.vscode-tailwindcss-0.14.21-universal: bradlc.vscode-tailwindcss
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Renamed to /home/sudo_user/.local/share/code-server/extensions/bradlc.vscode-tailwindcss-0.14.21-universal
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Marked extension as uninstalled bradlc.vscode-tailwindcss-0.14.20-universal
Jun 06 08:43:56 ubuntu code-server[2010591]: [08:43:56] Extension installed successfully: bradlc.vscode-tailwindcss file:///home/sudo_user/.local/share/code-server/extensions/extensions.json
code-asher commentedon Jun 6, 2025
Hard to say why
/home/sudo_user/.local/share/code-server/extensionshad the wrong owner, but I would guess some kind of configuration issue.Looks like everything is working now though?
navidbakhtiary commentedon Jun 6, 2025
The problem was unexpected, but I am grateful to find a solution for it.
It is a great tool, and it helps me a lot to work with my server when I encounter network/vpn restrictions.