Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode extensions need NIX_LD set, but the normal install of pkgs.vscode launches without it set #96

Closed
nmay231 opened this issue Dec 2, 2024 · 3 comments

Comments

@nmay231
Copy link

nmay231 commented Dec 2, 2024

(Perhaps I should really open an issue with nixpkgs, but I'm not entirely certain where the problem needs to be fixed, and I'm still new to nix)

Here's a summary of my configuration.nix.

let
  unstable = import <nixos-unstable> { config = { allowUnfree = true; }; };
in {
  environment.systemPackages = with pkgs; [
    unstable.vscode
  ];
  programs.nix-ld.enable = true;
  programs.nix-ld.libraries = with pkgs; [];

I get the following issue where some of my python-related extensions I have installed fail with the following error:

[info] cannot execute [project_dir]/.venv/bin/python: You are trying to run an unpatched binary on nixos, but you have not configured NIX_LD or NIX_LD_x86_64-linux. See https://github.com/Mic92/nix-ld for more details

Launching code from the system launcher results with this issue, but my extensions work when launching vscode from the terminal (code .).

I have uv installed via its installer (uv sorta acts like rustup and cargo but for python). The python binaries installed using uv work just fine when running from the command line. However, the vscode extensions that use the local .venv/bin/python fail with that error. They fail because vscode doesn't set NIX_LD when run from the system launcher, but running code from the command line keeps the environment variables and allows the extensions to work. I can confirm the issue is with NIX_LD with the following test.

code . # Extensions work
NIX_LD="" code . # They do not work

I'm opening this issue for a couple of reasons.

  1. I could not find anything related to this specific issue anywhere else, so hopefully this will help someone in the future.
  2. Is there a way to have certain applications run using the nix-ld shims and, more importantly, is that a recommended solution? I've seen nix-shell being recommended as the way to launch shells with certain environment variables and other config set up to work with certain things, but I don't need that since launching code from my normal shell works perfectly well.
@Mic92
Copy link
Member

Mic92 commented Dec 2, 2024

Can you please make sure you have the latest version of nix-ld? Since nix-ld 2.0, we should no longer need NIX_LD/NIX_LD_LIBRARY_PATH because nix-ld will fallback to /run/current-system/sw/share/nix-ld/lib/ and /run/current-system/sw/share/nix-ld/lib/ld.so.

@nmay231
Copy link
Author

nmay231 commented Dec 5, 2024

I guess I'm using nix-ld 1.2.3, based on nix-store -q. I am considering updating nixpkgs to unstable anyways, so I'll do that when I have some free time. NixOS is still more of an experiment for me. :)

@nmay231
Copy link
Author

nmay231 commented Dec 11, 2024

Upgrading nixpkgs to unstable updates nix-ld to the latest version (2.0.3) which doesn't have this issue anymore. Thank you for your time.

@nmay231 nmay231 closed this as completed Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants