NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.6k stars 13.07k forks source link

Packaging request for vscode-extensions.ms-vscode-remote.remote-containers #182397

Open GGG-KILLER opened 1 year ago

GGG-KILLER commented 1 year ago

Project description This extension basically allows us to create a dev environment in a container which makes things easier with e.g.: .NET since it now has a workloads component that works outside of the binary installed by dotnetCorePackages.sdk_X_Y as well as tools that are also precompiled binaries downloaded from nuget.

Metadata

GGG-KILLER commented 1 year ago

For what it's worth, I've tried to use this extension with pkgs.vscode-extensions.extensionsFromVscodeMarketplace but it fails down the line. I'll try to get the exact error to post here.

EDIT: Seems like the "prebuilt" containers work (at least the C# (.NET) template at least did), but custom ones don't.

Error reproduction steps:

  1. Ctrl + Shift + P
  2. Remote-Containers: Add Development Container Configuration Files
  3. Select Debian
  4. Select bullseye
  5. In additional features, select the following:
    • Dotnet CLI (latest version)
    • Node.js (via nvm) and yarn (lts version)
  6. Select "Reopen in Container" on the dialog that pops up on the bottom left (if you miss it, run the Developer: Reload Window command)

The following error is output:

[2022-07-21T23:02:41.542Z] Error: EACCES: permission denied, open '/tmp/vsch-ggg/container-features/0.242.0-1658444561523/local-cache/devcontainer-features.env'

(full log output, devcontainer.json and Dockerfile in this gist)

das-g commented 1 year ago

With

{
  # …
  environment.systemPackages = with pkgs; let
    vscodiumExtensions = (with vscode-extensions; [
      # …
    ]) ++ vscode-utils.extensionsFromVscodeMarketplace [
      # …
      {
        publisher = "ms-vscode-remote";
        name = "remote-containers";
        version = "0.269.0";
        sha256 = "sha256-8HY46AKbAU5W01BN4iwCUSFqTXfRbC937Gy0kvPTmn4=";
      }
    ];
    vscodium-with-extensions = pkgs.vscode-with-extensions.override {
      vscode = vscodium;
      vscodeExtensions = vscodiumExtensions;
    };
    vscode-with-extensions = pkgs.vscode-with-extensions.override {
      vscodeExtensions = vscodiumExtensions;
    };
  in [
    # …
    vscodium-with-extensions
    vscode-with-extensions
    # …
  ];
  # …
}

in /etc/nixos/configuration.nix, development containers work for me in VSCode 1.75.0, but not in VSCodium 1.75.0. (The latter might be expected, see microsoft/vscode-remote-release#1925.)

Output of nix-info -m:

GGG-KILLER commented 1 year ago

Yeah, it seems to be working fine now without any modifications.

I'll close this as it can be added with pkgs.vscode-utils.extensionsFromVscodeMarketplace.

robertodr commented 1 year ago

I'm still getting Unable to write file 'vscode-remote://dev-container+2f746d702f626172666f6f/workspaces/barfoo/foo.py' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/workspaces/barfoo/foo.py') with VSCode 1.76 (either installed in systemPackages or with home-manager) I've tried both the latest version and 0.269.0 for the extension.

EDIT I've been testing with the default Python 3 dev container.

das-g commented 1 year ago

Yeah, it seems to be working fine now without any modifications.

I'll close this as it can be added with pkgs.vscode-utils.extensionsFromVscodeMarketplace.

It might be worth to have this extension explicitly in NixPkgs, as it can be difficult for users to figure out,

~Should we thus re-open this issue? Or create a new one?~

(Edit: Re-opened inadvertently when posting this comment due to hitting the wrong button. I'll leave it open for now, though.)

GGG-KILLER commented 1 year ago

I think re-opening should be enough as it has not been packaged and it seems people are running into issues running it.

carlthome commented 1 year ago

Personally think pretty much all the Remote Development extensions (https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) are interesting enough to have them in nixpkgs directly. As a nixpkgs user I'd expect most of the "official" VS Code extensions to be included.

robertodr commented 1 year ago

Does anyone have suggestions/workarounds on how to get this extension to work? Using the vscode-fhs package and installing the extension impurely doesn't help...

nixos-discourse commented 1 year ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/using-vscode-devcontainers/29179/1

GGG-KILLER commented 1 year ago

I have it working for me by using this:

        extensionsFromVscodeMarketplace [
          {
            publisher = "ms-vscode-remote";
            name = "remote-containers";
            version = "0.294.0";
            sha256 = "sha256-Lnwan4jT5cQ/0ymd3skxS3cAhXZdwvKDRjzheX1Hqf4=";
          }
        ];
robertodr commented 1 year ago

Thanks @GGG-KILLER, but that still doesn't work for me :( Which version of VSCode are you running?

Unable to write file 'vscode-remote://dev-container+7b22686f737450617468223a222f686f6d652f726f626572746f2f576f726b73706163652f726f626572746f64722f7673636f6469756d2d70726f6a656374222c22636f6e66696746696c65223a7b22246d6964223a312c22667350617468223a222f686f6d652f726f626572746f2f576f726b73706163652f726f626572746f64722f7673636f6469756d2d70726f6a6563742f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c2265787465726e616c223a2266696c653a2f2f2f686f6d652f726f626572746f2f576f726b73706163652f726f626572746f64722f7673636f6469756d2d70726f6a6563742f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c2270617468223a222f686f6d652f726f626572746f2f576f726b73706163652f726f626572746f64722f7673636f6469756d2d70726f6a6563742f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a2266696c65227d7d/workspaces/vscodium-project/crap.txt' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/workspaces/vscodium-project/crap.txt')
GGG-KILLER commented 1 year ago

@robertodr I'm using the nixpkgs vscode: image

robertodr commented 1 year ago

Only difference appears to be in the Linux kernel version 🤔

Version: 1.79.0
Commit: b380da4ef1ee00e224a15c1d4d9793e27c2b6302
Date: 2023-06-07T14:28:44.251Z
Electron: 22.5.5
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 6.3.6
robertodr commented 1 year ago

The problem was that my UID (1001) was not being remapped to the UID of the vscode user in the container (1000) I changed my UID and now the extension works 🎉

kenranunderscore commented 10 months ago

I had/have the same UID remapping problem as well. Do you know of any workaround that doesn't require me to change my UID?

(When trying to debug this, I remember wondering why it didn't remap the UID. The extension code runs into a case where it decides "nothing to do", even though I would think it should actually do something.)

Clockwork-Muse commented 8 months ago

@kenranunderscore - If you manually install the common-utils extension (and don't use a base image with it built-in), you can manually set the UID of the internal user.

Keep in mind that if you persist the definition to a shared repo that this might cause problems if the other users don't have the same UID and it doesn't automap.