NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.37k stars 13.6k forks source link

codium with cpptools and lldb gives errors in the output window for Extension Host. #235659

Open mohnishkodnani opened 1 year ago

mohnishkodnani commented 1 year ago

Describe the bug

I have a nix flake that installs vscode with extensions and set the code to codium. I then install extensions for cpptools and codellb. I see the following error while activating these extensions.

2023-06-01 12:46:34.266 [error] Activating extension ms-vscode.cpptools failed due to an error:
2023-06-01 12:46:34.268 [error] Error: EPERM: operation not permitted, chmod '/nix/store/bqd10ypr09rlm6p2qp7182mhiahc0r3k-vscode-extension-ms-vscode-cpptools-1.16.0/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-srv'
2023-06-02 10:08:06.772 [error] Error: EPERM: operation not permitted, chmod '/nix/store/bqd10ypr09rlm6p2qp7182mhiahc0r3k-vscode-extension-ms-vscode-cpptools-1.16.0/share/vscode/extensions/ms-vscode.cpptools/LLVM/bin/clang-format'
2023-06-01 12:46:37.670 [error] Error: EACCES: permission denied, mkdir '/nix/store/fd20wgkr2rg7zs0jiim5z9b2dbc4ms7b-vscode-extension-vadimcn-vscode-lldb-1.9.2/share/vscode/extensions/vadimcn.vscode-lldb/adapter'

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a Nix flake
    {
    inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
    nix-vscode-extensions.inputs.nixpkgs.follows = "nixpkgs";
    };
    outputs = {self, nixpkgs, flake-utils, nix-vscode-extensions, ...} @inputs: 
    flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-darwin" "x86_64-darwin"] (system:
    let 
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };
      extensions = nix-vscode-extensions.extensions.${system}; 
      custom-vscode-extensions = builtins.attrValues {
        inherit (extensions.vscode-marketplace.redhat) vscode-yaml;
        inherit (extensions.vscode-marketplace.ms-vscode) vscode-typescript-tslint-plugin cpptools cmake-tools;
        inherit (extensions.vscode-marketplace.ms-python) python;
        inherit (extensions.vscode-marketplace.bungcip) better-toml;
        inherit (extensions.vscode-marketplace.vadimcn) vscode-lldb;
        inherit (extensions.vscode-marketplace.llvm-vs-code-extensions) vscode-clangd;
      };
      codium = 
        let
         inherit (pkgs) vscode-with-extensions vscodium vscodium-fhs;
        in (vscode-with-extensions.override {
          vscode = vscodium;
          vscodeExtensions = custom-vscode-extensions;
        });
      shellHook = '''' 
      + (if pkgs.stdenv.hostPlatform.isDarwin then 
      ''
        export MACOSX_DEPLOYMENT_TARGET=13.3
        export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks
        export NIX_LDFLAGS=$(for a in $NIX_LDFLAGS; do echo $a; done |sort|uniq|xargs)
        export NIX_LDFLAGS_FOR_TARGET=$(for a in $NIX_LDFLAGS_FOR_TARGET; do echo $a; done |sort|uniq|xargs)
        export NIX_LDFLAGS_FOR_TARGET=$(comm -3 <(for l in $NIX_LDFLAGS_FOR_TARGET; do echo $l; done) <(for l in $NIX_LDFLAGS; do echo $l; done))
        export NIX_LDFLAGS=$(for lib in $NIX_LDFLAGS; do case "$lib" in *curses*);; *) echo -n "$lib ";; esac; done;)
        export NIX_LDFLAGS="-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib $NIX_LDFLAGS"
      ''
      else '''');
    in
      rec {
        devShells = {
          xyz = pkgs.mkShell {
            dontAddExtraLibs = true; # stop polluting LDFLAGS with -liconv
            nativeBuildInputs = with pkgs; [ 
              cmake 
              clang_16
              llvmPackages_16.llvm
              llvmPackages_16.libcxx
              ninja
              cppunit
              eigen
              zstd
              openssl
              boost182
              doxygen
            ];
            buildInputs = with pkgs; [
              graphviz
              mas
              jq
              shellcheck
              perl
              codium
              python39
            ];
            shellHook = shellHook;
          }; 
        };
        devShell = devShells.xyz;
      }
    );
    }
  2. Build the nix flake and launch codium.
  3. Check the Runtime status of the extensions c++ and lldb. Both say "Not yet activated"

Expected behavior

Activated and working extensions.

Screenshots

Additional context

Notify maintainers

@Synthetica9 @bobby285271

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 22.4.0, macOS 13.3.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.13.3`
 - channels(root): `""`
 - nixpkgs: `/nix/store/dnqwkazyg92hzya7400klxlk072g3zsk-source`
bobby285271 commented 1 year ago

Hi, I don't maintain these extensions, but just to make sure are you getting these extensions from Nixpkgs or from the third-party nix-vscode-extensions? I have the impression that nix-vscode-extensions is there because 90%+ extensions can be auto generated and packaged but this is probably not the case for cpptools, vscode-lldb, which needs a number of patching :thinking:

mohnishkodnani commented 1 year ago

I have tried both and on Mac and my Linux box with similar results where on Linux the EACESS error is happening under my home folder /home/mk/.vscode-oss/extensions... And in MAC it's under the nix store as highlighted here.

On Thu, Jun 8, 2023, 00:08 Bobby Rong @.***> wrote:

Hi, I don't maintain these extensions, but just to make sure are you getting these extensions from Nixpkgs or from the third-party nix-vscode-extensions https://github.com/nix-community/nix-vscode-extensions? I have the impression that nix-vscode-extensions is there because 90%+ extensions can be auto generated and packaged but this is probably not the case for cpptools https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools, vscode-lldb https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb, which needs a number of patching 🤔

— Reply to this email directly, view it on GitHub https://github.com/NixOS/nixpkgs/issues/235659#issuecomment-1582005605, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABW4SVGQVI2VP77YUXAQSM3XKF25ZANCNFSM6AAAAAAYY2RUAA . You are receiving this because you authored the thread.Message ID: @.***>