Skip to content

Does not work if target is a nixos #648

Closed

Description

@luxzeitlos
  • VSCode Version: 1.35.0
  • Local OS Version: MacOS 10.13.6
  • Remote OS Version: Nixos 19.03.172657.cdec6217d98 (Koi)
  • Remote Extension/Connection Type: SSH

Steps to Reproduce:

  1. Try to connecct
[email protected]
SSH Resolver called for "ssh-remote+home"
SSH Resolver called for host: home
Setting up SSH remote "home"
Using commit id "553cfb2c2205db5f15f3ee8395bbd5cf066d357d" and quality "stable" for server
Install and start server if needed
> Installing to /home/lux/.vscode-server/bin/553cfb2c2205db5f15f3ee8395bbd5cf066d357d...
> Downloading with wget
> Printing the current remote environment...
> LD_LIBRARY_PATH=/run/opengl-driver/lib
> SSH_CONNECTION=10.0.0.1 59089 10.0.1.29 22
> LANG=en_US.UTF-8
> EDITOR=nano
> MOZ_PLUGIN_PATH=/home/lux/.nix-profile/lib/mozilla/plugins:/nix/var/nix/profiles/default/lib/mozilla/plugins:/run/current-system/sw/lib/mozilla/plugins:/etc/profiles/per-user/lux/lib/mozilla/plugins
> KDEDIRS=/home/lux/.nix-profile:/nix/var/nix/profiles/default:/run/current-system/sw:/etc/profiles/per-user/lux
> NO_AT_BRIDGE=1
> QTWEBKIT_PLUGIN_PATH=/home/lux/.nix-profile/lib/mozilla/plugins/:/nix/var/nix/profiles/default/lib/mozilla/plugins/:/run/current-system/sw/lib/mozilla/plugins/:/etc/profiles/per-user/lux/lib/mozilla/plugins/
> XDG_SESSION_ID=13
> USER=lux
> PAGER=less -R
> TZDIR=/etc/zoneinfo
> LIBEXEC_PATH=/home/lux/.nix-profile/lib/libexec:/nix/var/nix/profiles/default/lib/libexec:/run/current-system/sw/lib/libexec:/etc/profiles/per-user/lux/lib/libexec
> NIX_PROFILES=/etc/profiles/per-user/lux /run/current-system/sw /nix/var/nix/profiles/default /home
> /lux/.nix-profile
> __fish_nixos_env_preinit_sourced=1
> PWD=/home/lux
> NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
> SSH_ASKPASS=/nix/store/7hnksdws6v40j087pb54x46vgd504awi-ksshaskpass-5.14.5/bin/ksshaskpass
> HOME=/home/lux
> SSH_CLIENT=10.0.0.1 59089 22
> GTK_PATH=/home/lux/.nix-profile/lib/gtk-2.0:/home/lux/.nix-profile/lib/gtk-3.0:/nix/var/nix/profiles/default/lib/gtk-2.0:/nix/var/nix/profiles/default/lib/gtk-3.0:/run/current-system/sw/lib/gtk-2.0:/run/current-system/sw/lib/gtk-3.0:/etc/profiles/per-user/lux/lib/gtk-2.0:/etc/profiles/per-user/lux/lib/gtk-3.0
> XDG_DATA_DIRS=/run/opengl-driver/share:/home/lux/.nix-profile/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share:/etc/profiles/per-user/lux/share
> STRIGI_PLUGIN_PATH=/home/lux/.nix-profile/lib/strigi/:/nix/var/nix/profiles/default/lib/strigi/:/run/current-system/sw/lib/strigi/:/etc/profiles/per-user/lux/lib/strigi/
> GIO_EXTRA_
> MODULES=/nix/store/zawby3zwsi58d5clyvjzbxfrb6j15mps-gvfs-1.38.2/lib/gio/modules
> TERMINFO_DIRS=/home/lux/.nix-profile/share/terminfo:/nix/var/nix/profiles/default/share/terminfo:/run/current-system/sw/share/terminfo:/etc/profiles/per-user/lux/share/terminfo
> GDK_PIXBUF_MODULE_FILE=/nix/store/2wldk19wpd926x4ck59d5dja1gj469l3-gdk-pixbuf-loaders.cache
> __NIXOS_SET_ENVIRONMENT_DONE=1
> MAIL=/var/mail/lux
> QT_PLUGIN_PATH=/home/lux/.nix-profile/lib/qt4/plugins:/home/lux/.nix-profile/lib/kde4/plugins:/nix/var/nix/profiles/default/lib/qt4/plugins:/nix/var/nix/profiles/default/lib/kde4/plugins:/run/current-system/sw/lib/qt4/plugins:/run/current-system/sw/lib/kde4/plugins:/etc/profiles/per-user/lux/lib/qt4/plugins:/etc/profiles/per-user/lux/lib/kde4/plugins
> NIX_USER_PROFILE_DIR=/nix/var/nix/profiles/per-user/lux
> TERM=dumb
> SHELL=/run/current-system/sw/bin/fish
> SHLVL=2
> LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
> VSCODE_AGENT_FOLDER=/home/lux/.vscode-server
> LOGNAME=lux
> NIXPKGS_CONFIG=/etc/nix/ni
> xpkgs-config.nix
> XDG_RUNTIME_DIR=/run/user/1000
> XDG_CONFIG_DIRS=/home/lux/.nix-profile/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg:/etc/profiles/per-user/lux/etc/xdg
> PATH=/home/lux/bin:/run/wrappers/bin:/home/lux/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/etc/profiles/per-user/lux/bin
> INFOPATH=/home/lux/.nix-profile/info:/home/lux/.nix-profile/share/info:/nix/var/nix/profiles/default/info:/nix/var/nix/profiles/default/share/info:/run/current-system/sw/info:/run/current-system/sw/share/info:/etc/profiles/per-user/lux/info:/etc/profiles/per-user/lux/share/info
> NIXPKGS_ALLOW_UNFREE=1
> XCURSOR_PATH=/home/lux/.icons:/home/lux/.nix-profile/share/icons:/nix/var/nix/profiles/default/share/icons:/run/current-system/sw/share/icons:/etc/profiles/per-user/lux/share/icons
> _=/run/current-system/sw/bin/printenv
> OLDPWD=/home/lux/.vscode-server/bin/553cfb2c2205db5f15f3ee8395bbd5cf066d357d
> Starting server...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
>  
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
>  
> Server did not start successfully. Full server log:
> /home/lux/.vscode-server/bin/553cfb2c2205db5f15f3ee8395bbd5cf066d357d/server.sh: line 12: /home/lux/.vscode-server/bin/553cfb2c2205db5f15f3ee8395bbd5cf066d357d/node: No such file or directory
> c7a841f3-7eb8-4937-b524-84842b5af26b====
"install" terminal command done
Received install output: c7a841f3-7eb8-4937-b524-84842b5af26b====
Failed to parse remote port from server output: c7a841f3-7eb8-4937-b524-84842b5af26b====

The problem seems to be that /home/lux/.vscode-server/bin/553cfb2c2205db5f15f3ee8395bbd5cf066d357d/node can not be executed. I'm not really sure why. Running it inside a ubuntu docker container works. That way I could figure out it seems to be a node v10.2.1. However I'm not sure which version.
https://nodejs.org/dist/v10.2.1/node-v10.2.1-linux-x64.tar.gz runs just fine.

Activity

  1. simonchatts commented on Jun 18, 2019

    @simonchatts

    For people just trying to get this working, the following works for me:

    • On the NixOS server, rm -rf ~/.vscode-server and ensure nodejs-10_x is installed (and no other nodejs version)
    • Try to initiate a remote session to the server from VSCode
    • After that fails, cd to ~/.vscode-server/bin/* on the server, and run rm node; ln -s $(which node)
    • Try to initiate a remote session again - should work this time

    One possible fix (hacky but better than nothing) for the extension authors: automate these steps in the server install script buried inside the extension:

    @@ -126,6 +126,16 @@ then
             echo "WARNING: $VSCH_DIR/server.sh doesn't exist. Download/untar may have failed."
         fi
     
    +    # If we're running on NixOS, then use the required installed nodejs-10_x dependency
    +    if [ -d /nix -a "$(echo /usr/bin/*)" == "/usr/bin/env" ]; then
    +        if nix-store --query --requisites /run/current-system | grep nodejs-10 > /dev/null; then
    +            (cd $VSCH_DIR; rm node; ln -s $(which node))
    +        else
    +            echo Need nodejs-10_x to be installed on NixOs >&2
    +            exit 1
    +        fi
    +    fi
    +
         rm vscode-server-linux-$VSCODE_ARCH.tar.gz
         cd $STASHED_WORKING_DIR
    

    I've tested this, but it's quite faffy extracting this source shell script from the minified js inside the .vsix file, so not really recommended for folks just trying to do the install. (Could the extension source code be put somewhere?)

  2. roblourens commented on Jun 19, 2019

    @roblourens
    Member

    Sorry but can you explain why you need to do this and what's different about the nixOS node version?

  3. added
    info-needed
    on Jun 19, 2019
  4. wmertens commented on Jun 19, 2019

    @wmertens

    Simon Chatterjee (@simonchatts) your code could simply be replaced with a nix-shell -p nodejs invocation every time they need to run node

  5. Luabee commented on Jun 19, 2019

    @Luabee

    The reason the node executable can't be run is because the executable is 32-bit
    EDIT: I was incorrect. see comment below.

  6. Luabee commented on Jun 19, 2019

    @Luabee
    [~/.vscode-server/bin/553cfb2c2205db5f15f3ee8395bbd5cf066d357d]$ file node
    node: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=42c88d3401728b722d7ea3e700cb81f90ec1cfb6, with debug_info, not stripped
    
    [anduril@tower-6f:~/.vscode-server/bin/553cfb2c2205db5f15f3ee8395bbd5cf066d357d]$ ls /lib64
    ls /lib64ls: cannot access '/lib64': No such file or directory
    

    Looks like it's actually just missing a dependency. Nixos handles deps with Nix, so it makes sense that it wouldn't be there.

  7. roblourens commented on Jun 20, 2019

    @roblourens
    Member

    Thanks. I'm thinking this is basically a variant of #103 which covers issues with our native binaries not running on machines that are missing dependencies. They should be statically linked (or allow running an external node from the machine itself).

  8. wmertens commented on Jun 20, 2019

    @wmertens

    In any case, it would be much nicer to use a local nodejs instead of dumping 80MB into the user's homedir. The server is just a node script and dependencies; bundle it, minify, try to run with local node, if that doesn't work try some fallbacks like nix-shell and only then download a binary.

  9. aanderse commented on Jul 16, 2019

    @aanderse

    roblourens Is there any way we can work something up along the lines of what Wout Mertens (@wmertens) is talking about regarding using a local node binary instead of the one this vscode plugin ships? Simon Chatterjee (@simonchatts) has a solution which works (thank you very much Simon Chatterjee (@simonchatts)!) but it is a bit hacky to have to run those commands to replace the node binary you ship with a symlink to the local node.

  10. roblourens commented on Jul 16, 2019

    @roblourens
    Member

    I am not planning anything like that right now.

  11. aanderse commented on Jul 17, 2019

    @aanderse

    roblourens As you are someone who doesn't use NixOS, or any of the other distros having problems like this, I can appreciate that your position... but is there any way we can meet somewhere in the middle? I'm a sysadmin who has a bunch of developers I want to get up and running on this extension and my options aren't great at the moment. What can the NixOS community do for you to make this happen?

  12. Luabee commented on Jul 17, 2019

    @Luabee
  13. wmertens commented on Jul 17, 2019

    @wmertens
  14. roblourens commented on Jul 17, 2019

    @roblourens
    Member

    Isn't this about all of our native dependencies and not just node? Having users set up custom server configurations that swap out different dependencies with their own versions, even just for node, introduces a lot of complexity for us especially when trying to debug issues over github. We have enough issues just trying to support the most basic configurations 😁

  15. wmertens commented on Jul 17, 2019

    @wmertens
  16. aanderse commented on Jul 17, 2019

    @aanderse

    roblourens I've had a developer on using this extension with NixOS for the morning and they have reported that their usual php workflow is operating flawlessly. They're asking me what it will take to replicate this across all our web servers.

    After running tree on the ~/.vscode-server directory i'm not entirely sure what you mean by native dependencies. I see a node binary which I replaced, and then mostly just .js files. Obviously I don't have the source code to your extension, but from the digging I've done I don't see any reason to believe that simply allowing users to specify a node binary won't fix the issue in a reasonably clean fashion.

    🤷‍♂️

  17. roblourens commented on Jul 18, 2019

    @roblourens
    Member

    Native code is used for search, syntax highlighting, internal logging which tends to break the product when it can't be initialized, a remote handshake module which is responsible for the error messages in #103, any third party extensions that assume they are in a normal remote environment will break, and probably some other stuff I'm not thinking of. Maybe some of that works for you now but it could break later then we will be back trying to patch it with another hack. The point is that all of this has to be considered in the context of #103.

  18. wmertens commented on Jul 18, 2019

    @wmertens
  19. aanderse commented on Jul 23, 2019

    @aanderse

    Wout Mertens (@wmertens) After the somewhat ominous warning from roblourens is it time to start considering alternatives such as buildFHSUserEnv, possibly in combination with users.users.<name?>.shell, at this point?

  20. wmertens commented on Jul 23, 2019

    @wmertens

    Urgh. Maybe just some ld preload that provides the missing /lib/ld-linux*?

  21. luxzeitlos commented on Jul 23, 2019

    @luxzeitlos
    Author

    Actually I think roblourens is right. The reason why the node binary does not work is probably dynamic linking. The provided binary can easily be patched with patchelf and the dynamic linking will work.

    So its likely that #103 would fix this.

  22. aanderse commented on Jul 23, 2019

    @aanderse

    @luxferresum I'll be very glad to see resolution to this. For now I'm continuing to have a few developers test out the extension with the custom node replacement for now... Hopefully they don't run into any problems while we await a solution to #103.

    Thanks for your continued efforts on this extension roblourens. Sorry for any hassle we have caused.

  23. locked and limited conversation to collaborators on Aug 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    info-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions