nixos-vscode-server
nixos-vscode-server copied to clipboard
Unable to install extensions
I have been using this flake for a while and its been working great, except I cannot seem to install server-sided extensions. Every time I try to install one I get an error of the following form:
Unable to write file '/home/guus/.vscodium-server/extensions/.a88d889b-1e75-4d34-af54-73606f9b151f/package.json' (EntryWriteLocked (FileSystemError): Error: EACCES: permission denied, open '/home/guus/.vscodium-server/extensions/.a88d889b-1e75-4d34-af54-73606f9b151f/package.json')
Did I mess up something while setting up my config? I am using the following config:
services.vscode-server = {
enable = true;
installPath = "$HOME/.vscodium-server";
};
I am using VSCodium version 1.88.1
Experiencing the same here. Are you managing local VSCodium extensions with Nix and have immutable extensions directory enabled?
Yep, you can find my local vscode configuration here
I got this, too. Is there any progress?
I do not have this issue with official Vscode and with mutable extensions directory. Feel free to open a PR that fixes this if you can figure out why it happens.
If I enable immutable extensions directory on client side, I noticed:
- This issue only happen when you try to install locally installed extensions on remote server. It will not happen if you try to install an extension that is NOT locally installed.
- The same symptom could be observed even if remote host is not NixOS.
I tried to observe the extracted directory for what is happening when I try to install a locally installed extension, and found that package.json is missing in the uploaded extension causing the error. I have also confirmed that package.json is missing in the unextracted file from the beginning.
My guess is, if immutable extensions directory is enabled, due to extensions are managed by Nix vscode is having a different behavior for installing extensions. This might have resulted in partial upload of the locally installed content.
A workaround I found is to add extension's unique identifier into vscode settings remote.SSH.defaultExtensions (link to doc), because the default extensions are downloaded from marketplace on server side instead of uploading from local.
At this point, I suspect the underlying issue is not related to this project at all. If I have more time I may try to look further into why package.json is not present in the uploaded extension.
Personally, to get around this issue, I copied the code that home-manager uses to install extensions with an immutable extensions directory:
{
config,
lib,
pkgs,
...
}: let
extensions = config.services.vscode-server-extensions;
cfg = config.services.vscode-server;
extensionDir = cfg.installPath;
extensionPath = "${extensionDir}/extensions";
extensionJson = pkgs.vscode-utils.toExtensionJson extensions;
extensionJsonFile = pkgs.writeTextFile {
name = "extensions-json";
destination = "/share/vscode/extensions/extensions.json";
text = extensionJson;
};
in {
options = {
services.vscode-server-extensions = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
};
};
config = lib.mkIf cfg.enable {
home.file = {
"${extensionPath}".source = (
let
subDir = "share/vscode/extensions";
combinedExtensionsDrv = pkgs.buildEnv {
name = "vscode-extensions";
paths =
extensions
++ lib.singleton extensionJsonFile;
};
in "${combinedExtensionsDrv}/${subDir}"
);
};
};
}
This is a bit of a crude solution, as this does mean that I have to specify all of the extensions that I want to twice, once on my client and once on my server, but for my use case, this is perfectly fine.
I stumbled upon this issue despite not using this flake as I use Remote SSH to connect to non-NixOS servers, but I had the same error (I do have VS Code installed through Home Manager with an immutable local extension directory).
For what is worth (and if anyone in a similar situation also ends up here), the information above was of great help to understand how to work around the issue, in particular this part:
A workaround I found is to add extension's unique identifier into vscode settings
remote.SSH.defaultExtensions(link to doc), because the default extensions are downloaded from marketplace on server side instead of uploading from local.At this point, I suspect the underlying issue is not related to this project at all. If I have more time I may try to look further into why
package.jsonis not present in the uploaded extension.
I did not try the default extensions solution proposed in the quoted text, but I used a similar workaround which is to install the extension in the terminal using ~/.vscode-server/bin/$SOME_HASH/bin/code-server --install-extension $EXTENSION_ID. In this case too, it looks like it download the extension directly from the marketplace.