Visual Studio Code downloads a prebuilt exe to .vscode
and tries to run it, but it errors with:
[Client.Agent E] Agent failed with error: Error: spawn /home/kevin/.vscode/extensions/ms-vsliveshare.vsliveshare-0.3.198/dotnet_modules/vsls-agent ENOENT
ldd output:
ldd vsls-agent
linux-vdso.so.1 (0x00007ffd9dda6000)
libdl.so.2 => /nix/store/27x7pinqdsl9f3rpbm8bsszd9fhwq266-glibc-2.27/lib/libdl.so.2 (0x00007f335c233000)
libpthread.so.0 => /nix/store/27x7pinqdsl9f3rpbm8bsszd9fhwq266-glibc-2.27/lib/libpthread.so.0 (0x00007f335c014000)
libstdc++.so.6 => not found
libm.so.6 => /nix/store/27x7pinqdsl9f3rpbm8bsszd9fhwq266-glibc-2.27/lib/libm.so.6 (0x00007f335bc7f000)
libgcc_s.so.1 => /nix/store/27x7pinqdsl9f3rpbm8bsszd9fhwq266-glibc-2.27/lib/libgcc_s.so.1 (0x00007f335ba69000)
libc.so.6 => /nix/store/27x7pinqdsl9f3rpbm8bsszd9fhwq266-glibc-2.27/lib/libc.so.6 (0x00007f335b6b5000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/27x7pinqdsl9f3rpbm8bsszd9fhwq266-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007f335c437000)
Install visual studio code and add the Live Share extension. Wait for it to download and error out.
Please run nix-shell -p nix-info --run "nix-info -m"
and paste the
results.
- system: `"x86_64-linux"`
- host os: `Linux 4.16.11, NixOS, 18.09.git.c8c4053 (Jellyfish)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.0.2`
- channels(root): `""`
- nixpkgs: `/etc/nixos/nixpkgs`
Wrote a bash script to patch the ext with a view to get a better understanding of how nixos hangs together.
Was hoping to get it to a derivation but times short, so here's the script in case anyone's up for a workaround (excuse sledgehammer rpath):
https://gist.github.com/b333z/5fb902161685c5141bbc91b39a152831#file-vsls
So you'd install the extension, run the script, still get the missing deps vscode notification on launch but seems ok after hitting cancel on that...
(would need to be re-ran each time ext updates...)
(updated: needed to patch more exe's as broken debugging)
(updated: needed openssl.out since nixos upgrade)
Perhaps this could be run as a pre-start script before starting VSCode somehow? Not sure if it offers hooks on extension updates...
I've started to create a package out of this (thanks for the great starting point @b333z ):
https://gist.github.com/phryneas/641ed9a316ff5166a30128575217dd0a
So far, I can log in and share, but my other PC can't join the session. Not sure if that is a problem with the extension or my network though. (The extension wants to write to it's directory and of course that's read-only)
So, if someone wants to experiment with it and has some ideas on how to make it work better, I'd be happy about feedback :)
To use it, install it into your user profile and symlink ~/.nix-profile/share/vscode/extensions/ms-vsliveshare.vsliveshare/
into your ~/.vscode/extensions
folder.
Be warned though: I've moved a few paths where the extension would store data to /tmp - for now.
I got it fully working! I can login, share, join, it all works so far. Thank you @b333z and @phryneas for the foundation. My approach has been to just build it properly with Nix, but then work around the Nix store being readonly by copying over (and partially symlinking) the build to the VS code extensions directory. I removed all issues that caused it to error on startup. In its current form it is probably over patched, but at least it works.
https://gist.github.com/ottidmes/9360fc1f0fbd8443506b45c2149388a9
I fixed over patching the binaries and it still all works. I also improved the workaround to more precisely link those files that needed linking. And the workaround now only runs when the build has actually changed.
https://gist.github.com/ottidmes/9360fc1f0fbd8443506b45c2149388a9
The biggest problem the extension still had was that it did extensive diagnostic logging, filling up the journal. After many attempts* to silence it, I finally managed a solution that is simple yet effective, by preloading a library with a noop syslog
function, it will stop logging.
*) redirecting stdout/stderr, checking for command line arguments, modifying the JS source code, LD_PRELOAD
a customized connect
, using unshare --mount
to modify the log path, using GDB to close/modify file descriptors to the log, writing a UNIX socket filter (that one actually worked, but you lose the PID of what is let through to the journal)
https://gist.github.com/ottidmes/9360fc1f0fbd8443506b45c2149388a9
I made a home-manager module to use your gist, seems to be working fine so far :)
https://gist.github.com/phryneas/9f2a4f7f10907f02bc36d44c9254ce50
Thanks for all your work!
@phryneas i would love to have this module in the main repo of home-manager
(because other users can like it too and because i don't know to use this gist)
It's still a bit messy and will need constant updating, so I'm not sure if it makes sense to add to home-manager.
But you can try to clean it up.
In the meantime, add this to your home.nix:
imports = [
"${builtins.fetchTarball {
url = "https://gist.github.com/phryneas/9f2a4f7f10907f02bc36d44c9254ce50/archive/28bd9dcd18ae7280ee3ea40bd3db8a934f5b68a9.tar.gz";
sha256 = "0gpi682rj8r6a5dqsqa9gnxawkzj5xfwm3find5x17mlb53w79cf";
}}/home-manager-module.nix"
];
services.vsliveshare = {
enable = true;
enableWritableWorkaround = true;
enableDiagnosticsWorkaround = true;
};
home-manager switch
(it works)code
with Live Share extension enabledbut the behavior is exactly the same as before
how should i debug this ? @phryneas
First thought: did you uninstall the extension before all that? If not, you might now have it twice in ~/.vscode/extensions and code might start the wrong one.
Aside from that: debugging that is a combination of random logs, a crystal ball and some weird voodoo rituals. I don't really remember what I did - sorry :/
@pinage404 did you end up getting this working?
@aanderse nope =(
i did a VM with a Debian and VSCode that i start when i need to use Live Share
@aanderse @pinage404 Last week I had to use Live Share myself again, so I updated to the latest version, which required me to make a few slight changes (such as the patch), but other than that it still works fine: https://gist.github.com/ottidmes/9360fc1f0fbd8443506b45c2149388a9
Just remember to run systemctl --user start vsliveshare-writable-workaround.service
, otherwise it will not write the patched version of the Live Share to the extensions directory.
@danbst you've worked some vscode magic in the past... do you have any thoughts?
@aanderse Any thoughts towards what? If you read this thread you know that I successfully put it together so that it works under NixOS. So if you have any concrete questions as to what is not working for you, why not just ask me?
@ottidmes seems like @pinage404 is still having some issues... so I was wondering if @danbst had any thoughts on how he might better debug/resolve them, given your solution.
I don't use vscode at all. Just looking to get issues resolved and closed.
@aanderse @Pneumaticat I think this issue can be closed, as the original issue has been resolved. When I find the time, I will try and make it easier to install, but since Live Share is still in active development and we need workarounds that are not fitting for inclusion in either Nixpkgs or home-manager, I will probably try and get it included in https://github.com/nix-community/NUR instead.
Awesome!
sorry, I don't yet have a usecase for Live Share. home-manager or NUR module would be fine.
@phryneas I get the following error when I paste your snippet from above:
error: The option value `systemd.user.services.vsliveshare-writable-workaround.Service.ExecStart' in `/nix/store/3hxy8h83s28i56fl5y39xzldykcgwbsj-source/home-manager-module.nix' is not of type `boolean or signed integer or string or list of boolean or signed integer or strings'.
(use '--show-trace' to show detailed location information)
@BenBals I have hosted the Live Share NixOS module in its own repository now. The home manager module of @phryneas is basically my module but tweaked to work with home manager. I however do not use home manager, so I have hosted my original work (which is just a regular NixOS module) updated to work for the extension version I am using. I am unable to test it (the package/module put in their own repo) until this evening, so I might have made a mistake somewhere, but it should work in theory, because the files are copied from my personal NixOS configuration project and I have used Live Share successfully some weeks ago with it.
{ ... }:
{
imports = [
(builtins.fetchTarball {
sha256 = "1qmq5zwd4qdxdxh4zxc7yr7qwajgnsjdw2npw0rfkyahmrqw3j02";
url = "https://github.com/msteen/nixos-vsliveshare/archive/86624fe317c24df90e9451dd5741220c98d2249d.tar.gz";
})
];
services.vsliveshare = {
enable = true;
enableWritableWorkaround = true;
enableDiagnosticsWorkaround = true;
extensionsDir = "/home/matthijs/.vscode/extensions";
};
}
Closing as per https://github.com/NixOS/nixpkgs/issues/41189#issuecomment-462154246
I did an overhaul of the service, it works again with the latest version and should now be more robust.
@aanderse I also implemented an auto updater for it when it notices a new version is being installed in a similar manner as I did for ~/.vscode-server
.
{
imports = [
"${builtins.fetchGit {
url = "https://github.com/msteen/nixos-vsliveshare.git";
ref = "refs/heads/master";
}}"
];
services.vsliveshare.enable = true;
}
@phryneas I updated the project to also support home manager and added the extensionsDir
option again after looking at your fork (I thought that option did not really had a reason to exist, but was not aware of ~/.vscode-oss
being used by the OSS fork). I don't use home manager myself, so could you report whether it works for you?
@msteen I'll take a look on friday! Thank you so much for keeping this up.
Wow I didn't find this when I encountered the same problem :(
@msteen I wrote a similar script but I think mine is faster (at least than the original above), since it only goes through the files once.
Too bad this got closed without any mention on the vscode pkg :(
@wmertens Not sure which exact scripts you are referring to, so I cannot really comment on that, but if you have some concrete improvements for vsliveshare on NixOS, a PR or issue at https://github.com/msteen/nixos-vsliveshare is most welcome.
Too bad this got closed without any mention on the vscode pkg :(
You mean the vsliveshare package in nixpkgs? What do you have in mind? Some comments in the code might still be missed. Maybe a warning should be added that can be disabled by passing some flag?
How about:
code
wrapper that extensions installed by vscode might contain binaries and would need patching. Add a setting to disable the warning.code
wrapper that patches binaries on startup and provides LD_LIBRARY_PATH from configurable libraries#! /usr/bin/env nix-shell
#! nix-shell -i sh -p dotnetCorePackages.netcore_3_1 icu patchelf gcc gcr liburcu openssl krb5 zlib gnome3.gnome-keyring libsecret desktop-file-utils xorg.xprop
# patch ELF loaders where needed
GCCLIB=$(dirname $(gcc -print-file-name=libstdc++.so.6))
LOADER=$(gcc -print-file-name=ld-linux-x86-64.so.2)
find ~/.vscode/extensions/ ~/.config/Code -type f -perm -100 -execdir patchelf --print-interpreter {} \; -print 2>/dev/null | awk '{t=$0;getline;if(t!~/^\/nix\//)print}' | while read f; do
echo "Patching $f" >&2
patchelf --set-interpreter "$LOADER" "$f"
RPATH=$(patchelf --print-rpath "$f")
patchelf --set-rpath "${RPATH+RPATH:}$GCCLIB" "$f"
done
# Provide all libraries
export LD_LIBRARY_PATH=$(echo "$NIX_LDFLAGS" | sed -E -e 's/\s*(-rpath|-L)\s*/:/g' -e 's/^://')
# It seems VSLS downloads dotnet itself so this may not be needed
export DOTNET_ROOT=$(dirname $(type -p dotnet))/..
# Don't know how to tell dotnet about ICU
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
exec code "$@"
There is an open issue in the repository of VSLS https://github.com/MicrosoftDocs/live-share/issues/3013
Just wondering, could this be fixed when using the vscode-with-extensions package as described here? Would be cool if the liveshare package was available directly by nixpkgs. It's a really cool extension and helps a lot when in homeoffice.
Looks like https://github.com/msteen/nixos-vsliveshare/blob/master/pkgs/vsliveshare/default.nix is pretty much package-able as is.
@msteen: Any reason why not too?
@jraygauthier Its been a while, but if I remember correctly vsliveshare did not work correctly when used from /nix/store, since it needs its installation directly to be writable (among other things), which is not the case when you install the extension through vscode-with-extensions (then the extension directory becomes within /nix/store). That is why although I still build it with Nix, it is copied over to the extension dir (outside of /nix/store). And for it to properly run it also needs some patching, which AFAIK could not be done during build time. So, yes, that particular package could be included in Nixpkgs, but it would only give the false impression that it then could be installed through vscode-with-extensions. It does not work in isolation (without the fixes).
Although normally the extension directory is normally located in $HOME, it could in theory be anywhere, but this is true for most software configured in $HOME, and such software generally tends not be included in Nixpkgs. As NixOS is focused on system configuration, not user configuration. That among it changing a lot at the time, was the reason for me not to include it in Nixpkgs.
So in conclusion, although it could probably be upstreamed to Nixpkgs without too much problems, it is AFAIK not in line with what should be included in Nixpkgs.
Thanks for the quick reply @msteen. Indeed attempted to use it (latest available version) with vscode-with-extensions
. The extension indeed attempts to write various files (modifiedInternalSettings.json
which I found a VSLS_SETTINGS_FILE="$PWD/test.json"
dirty workaround) but I am now stuck with some ./dotnet_modules/vsls-agent.lock
issue which for some obscure reason cannot be fixed with the usual touch ./dotnet_modules/vsls-agent.lock
.
This whole vscode packaging thing that mutates its own install directory is becoming quite annoying as time passes. Those extensions developers really should avoid doing such things (in my opinion).
Any one knows how to get more debug information, the default log really is insufficient. I would like to get the debug
log from out/prod/extension-prod.js
(e.g.: debug('lockSync stale')
).
Might give it another try later, but I assume that the extension code (*js
) itself might require patching.
It shouldn't write to a directory relative to the plugin install dir though. Maybe it's possible to change upstream to respect the XDG
specs?
Maybe it's possible to change upstream
Or if not, at least patch on NixOS? Having VSCode Live Share work on NixOS would be very very useful :-)
I do have something function based on @msteen's work now. @msteen: Are you ok with me creating a pull request (derivative work) from your work?
Having VSCode Live Share work on NixOS would be very very useful :-)
It does though? https://github.com/msteen/nixos-vsliveshare
Unless you meant with vscode-with-extensions
, then sure.
@jraygauthier I am definitely OK with that! It would be awesome if you managed to get it to work when you just include it in vscode-with-extensions
, without any additional fixes needed. If you do, be sure to make yourself the sole maintainer, as I don't actually use Live Share myself. And I think this project really needs an active maintainer, as many people truly depend on it for their work (some sadly even dropped NixOS because of it). I just like the idea of the feature and VS Code, but haven't really had the need myself.
@msteen: Excellent. Nice to hear :) Added the PR.
Most helpful comment
Just wondering, could this be fixed when using the vscode-with-extensions package as described here? Would be cool if the liveshare package was available directly by nixpkgs. It's a really cool extension and helps a lot when in homeoffice.