Skip to content

Instantly share code, notes, and snippets.

@swdunlop
Last active May 7, 2021 18:50
Show Gist options
  • Select an option

  • Save swdunlop/3fed235d6c6e5a58fc2f39291f5936f9 to your computer and use it in GitHub Desktop.

Select an option

Save swdunlop/3fed235d6c6e5a58fc2f39291f5936f9 to your computer and use it in GitHub Desktop.

Revisions

  1. swdunlop revised this gist May 7, 2021. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,9 +6,16 @@ Prior to April 2021, this could simply be done by replacing `.vscode-server/bin/
    there is also a library module that is not compatible with `nodejs-12_x`. Therefore, it is necessary to patch these two ELF
    files.

    ## What happens if you just replace nodejs (the pre-April solution from [nixos.wiki](https://nixos.wiki/wiki/Vscode))

    The following will occur when you try to open a terminal
    ```
    The terminal process failed to launch: A native exception occurred during launch (The module '/home/scott/.vscode-
    The terminal process failed to launch: A native exception occurred during launch (The module '.../.vscode-
    server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node_modules/node-pty/build/Release/pty.node' was compiled against a
    different Node.js version using NODE_MODULE_VERSION 83. This version of Node.js requires NODE_MODULE_VERSION 72. Please try
    re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`).).
    ```
    ```

    ## Why does this happen?

    No clue. I am not a NodeJS developer, nor do I work for Microsoft.
  2. swdunlop revised this gist May 7, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -7,5 +7,8 @@ there is also a library module that is not compatible with `nodejs-12_x`. There
    files.

    ```
    The terminal process failed to launch: A native exception occurred during launch (The module '/home/scott/.vscode-server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node_modules/node-pty/build/Release/pty.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 83. This version of Node.js requires NODE_MODULE_VERSION 72. Please try re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`).).
    The terminal process failed to launch: A native exception occurred during launch (The module '/home/scott/.vscode-
    server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node_modules/node-pty/build/Release/pty.node' was compiled against a
    different Node.js version using NODE_MODULE_VERSION 83. This version of Node.js requires NODE_MODULE_VERSION 72. Please try
    re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`).).
    ```
  3. swdunlop revised this gist May 7, 2021. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,8 @@ Microsoft that must be patched to be used on NixOS.

    Prior to April 2021, this could simply be done by replacing `.vscode-server/bin/*/node` with `nodejs-12_x`; after April 2021,
    there is also a library module that is not compatible with `nodejs-12_x`. Therefore, it is necessary to patch these two ELF
    files.
    files.

    ```
    The terminal process failed to launch: A native exception occurred during launch (The module '/home/scott/.vscode-server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node_modules/node-pty/build/Release/pty.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 83. This version of Node.js requires NODE_MODULE_VERSION 72. Please try re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`).).
    ```
  4. swdunlop created this gist May 7, 2021.
    7 changes: 7 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    NixOS does not normally install libraries in a FHS layout, which means that binaries compiled for other Linux platforms
    typically will not work. Visual Studio Code's Remote SSH extension transfers a NodeJS binary and a binary library built by
    Microsoft that must be patched to be used on NixOS.

    Prior to April 2021, this could simply be done by replacing `.vscode-server/bin/*/node` with `nodejs-12_x`; after April 2021,
    there is also a library module that is not compatible with `nodejs-12_x`. Therefore, it is necessary to patch these two ELF
    files.
    16 changes: 16 additions & 0 deletions fix-vscode-remote-blobs.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/usr/bin/env bash

    interpreter=$(nix eval --raw '((import <nixpkgs> { }).stdenv.glibc)')/lib/ld-linux-x86-64.so.2
    libstdcxx=$(nix eval --raw '((import <nixpkgs> { }).stdenv.cc.cc.lib)')/lib/libstdc++.so.6
    for dir in ~/.vscode-server/bin/*; do
    cd $dir

    patchelf \
    --set-interpreter $interpreter \
    --replace-needed libstdc++.so.6 $libstdcxx \
    node

    patchelf \
    --replace-needed libstdc++.so.6 $libstdcxx \
    node_modules/node-pty/build/Release/pty.node
    done