-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read-only --extensions-dir break remote extension installation #151543
Comments
This is probably because when we install a local extension into remote, we zip the local extension and unzip it on remote. I suspect that while zipping we are also including file modes. |
This seems like something a developer who is familiar with the code can fix quickly, right? Or alternatively, any hints as to where that code exists and I can try to fix it myself? |
I own this code and if you are interested to contribute the fix, you are welcome and appreciated. Here is the code pointer vscode/src/vs/platform/extensionManagement/node/extensionManagementService.ts Lines 107 to 112 in 1a7d1b4
|
Any luck so far? Also hitting this and interested in a fix. |
We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider. If you wonder what we are up to, please see our roadmap and issue reporting guidelines. Thanks for your understanding, and happy coding! |
This is still important to me, please re-open. Without this there is no reproducible and/or offline installation option (AFAIK). |
@isidorn: How can a (presumably) trivial fix to |
@isidorn Sorry for the noise, but seconding this for visibility. Please reopen. It means that when I use vscode on nixos to access a remote, things are broken when they shouldn't be, and it's not straightforward to fix as a user. |
Let's reopen and for now leave on the backlog. |
This is my temporary hack until this gets fixed, run this on the server (requires #!/usr/bin/env bash
inotifywait -m -q -r -e create --format '%w%f' "$HOME/.vscode-server/extensions" |
while read -r path; do
chmod +w "$path"
done It is racey, and does not work for extensions with many files, but for small extensions such as |
This workaround didn't work for me. I resorted to tarring up my local extensions directory, and extracting it over at What I don't understand is why updateMetadata is trying to write to package.json. Surely it can just leave that file alone? I don't think the solution is to modify the permission bits as they're represented in the zip. |
I am hitting this now. If you manage VS Code with Nix you cannot install extensions into a remote SSH VS Code server. I'll try the workaround but I'd love a proper solution. |
@sandy081 Do you have suggestions for how to reproduce this locally? I would like to tackle this and have done the following:
But now I am stuck. The extension I loaded locally is probably not going to emulate the read-only extension directory. Analyzing it from the code itself has also proved difficult. I can see from your pointers where zipping likely happens, and can find callers -- but I'm not sure if changing that code makes sense. I'd prefer to understand what VSCode is trying to write to the remote file system and what is triggering it to know what a proper fix is. However, there is no stack trace from the error, since it is being swallowed by |
I can reproduce this today with the { pkgs }: {
programs.vscode = {
enable = true;
extensions = with pkgs.vscode-extensions; [ mkhl.direnv ];
};
} What this does is (on the client) unpack mkhl into a directory with no read permisson and then put a symlink to it such that it is readable via a couple of symlinks:
One thing to note though is that I was unable to reproduce this reliably. It happened on the first attempt, but when I quit vscode and repeated the procedure it did not hit the problem. I was able to reproduce this by trying a second package though ( |
@bjornfor I am wondering, how you could install extensions in to this folder if it is read only? |
The (read-only) extensions directory is managed by the Nix package manager. So I don't put stuff in there manually, I just declare what plugins I want in a Nix file and let it build/realize that configuration. Here's a stand-alone example that can be used on any Linux distro: # file vscode.nix
let
# branch nixos-24.11 @ 2025-03-05
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/48913d8f9127ea6530a2a2f1bd4daa1b8685d8a3.tar.gz";
sha256 = "0h3yzgn0mw74039xaqpvhvd2f924d923ax3kb8gh79f2m1jgla6i";
};
pkgs = import nixpkgs { config = {}; overlays = []; };
in
with pkgs;
vscode-with-extensions.override {
vscodeExtensions = [
vscode-extensions.asciidoctor.asciidoctor-vscode
vscode-extensions.eamodio.gitlens
vscode-extensions.ms-vscode.cmake-tools
];
} Install it with
See perms/ownership of the directory:
|
Yeah, and the fact it is read only is a non-negotiable feature of the nix store; things are put there to be read only, so you can be confident it has not been interfered with and you can reproduce different configurations. This enables answering questions like 'did my configuration change break something', across the whole system, because you can still run exactly the old configuration without worrying too much if you missed some file somewhere, with respect to things like this. |
Does this issue occur when all extensions are disabled?: No. (The issue is about installing extensions on a remote system.)
Steps to Reproduce:
code --extensions-dir /path/to/read-only-tree-of-extensions
. (Why read-only? Because that's how Nix does software deployment. This command just reproduces howvscode-with-extensions
from Nixpkgs works.)Unable to write file '/home/$USER/.vscode-server/extensions/.6661fce6-c826-4679-8f01-8421850781b5/package.json' (EntryWriteLocked (FileSystemError): Error: EACCES: permission denied, open '/home/$USER/.vscode-server/extensions/.6661fce6-c826-4679-8f01-8421850781b5/package.json')
It seems VSCode first copies files from the local system
/path/to/read-only-tree-of-extensions
to~/.vscode-server/
on the remote host and then tries to update~/.vscode-server/extensions/.UUID/package.json
(still on the remote), which fails because the file still has read-only permissions.I tried to chmod the files myself, but it seems VSCode creates a new UUID every time, so it doesn't work.
When copying extensions/files from somewhere to $HOME on a remote machine, with the intention to update some of the files, I think it's reasonable to explicitly set the writeable bit on said files, after the copy operation completes.
The text was updated successfully, but these errors were encountered: