无法在NixOS上使用asdf-vm执行或安装东西。

huangapple go评论104阅读模式
英文:

Cannot execute or install things with asdf-vm on NixOS

问题

After moving to NixOS from Arch Linux, I installed asdf-vm (using git; commit 0adc6c1). However, I noticed that installing any rust binary fails:

在从Arch Linux迁移到NixOS后,我安装了 asdf-vm(使用git;提交0adc6c1)。然而,我注意到安装任何Rust二进制文件都会失败:

$ LC_ALL=C asdf install rust stable
info: downloading installer
main: line 494: /tmp/tmp.XmUYT687x4/rustup-init: cannot execute: required file not found

这也会在尝试安装python二进制文件时发生:

这也会在尝试安装python二进制文件时发生:

$ asdf install python 3.11.3
python-build 3.11.3 /home/jorge/.asdf/installs/python/3.11.3
Downloading Python-3.11.3.tar.xz...
-> https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tar.xz
Installing Python-3.11.3...

BUILD FAILED (NixOS 23.05 using python-build 2.3.17-10-g920ef145)

Inspect or clean up the working tree at /tmp/python-build.20230513230601.298920
Results logged to /tmp/python-build.20230513230601.298920.log

Last 10 log lines:
File "/tmp/python-build.20230513230601.298920/Python-3.11.3/Lib/ensurepip/init.py", line 202, in _bootstrap
return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/python-build.20230513230601.298920/Python-3.11.3/Lib/ensurepip/init.py", line 103, in _run_pip
return subprocess.run(cmd, check=True).returncode
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/python-build.20230513230601.298920/Python-3.11.3/Lib/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/python-build.20230513230601.298920/Python-3.11.3/python', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = ['/tmp/tmplx6zl6yc/setuptools-65.5.0-py3-none-any.whl', '/tmp/tmplx6zl6yc/pip-22.3.1-py3-none-any.whl'] + sys.path\nsys.argv[1:] = ['install', '--no-cache-dir', '--no-index', '--find-links', '/tmp/tmplx6zl6yc', '--root', '/', '--upgrade', 'setuptools', 'pip']\nrunpy.run_module("pip", run_name="main", alter_sys=True)\n']' returned non-zero exit status 1.
make: *** [Makefile:1858: install] Error 1

Installing binaries for Go works fine, but executing go fails:

安装Go的二进制文件可以正常工作,但执行go会失败:

$ LC_ALL=C go
/home/jorge/.asdf/lib/commands/command-exec.bash: line 28: /home/jorge/.asdf/installs/golang/1.19/go/bin/go: cannot execute: required file not found

同样适用于NodeJS的npm

同样适用于NodeJS的npm

$ LC_ALL=C npm
/home/jorge/.asdf/lib/commands/command-exec.bash: line 28: /home/jorge/.asdf/installs/nodejs/20.1.0/bin/node: cannot execute: required file not found

you may wonder if the files missing truly exists at the locations shown in the errors, and well, they do:

您可能会想知道错误消息中显示的位置上确实存在缺失的文件,实际上它们是存在的:

$ tree -L 5
.
├── golang
│ └── 1.19
│ └── go
│ ├── api
│ ├── bin
│ │ ├── go
│ │ └── gofmt
...
├── nodejs
│ └── 20.1.0
│ ├── bin
│ │ ├── corepack -> ../lib/node_modules/corepack/dist/corepack.js
│ │ ├── node
│ │ ├── npm -> ../lib/node_modules/npm/bin/npm-cli.js
│ │ └── npx -> ../lib/node_modules/npm/bin/npx-cli.js
...
│ ├── lib
│ │ └── node_modules
│ │ ├── corepack
│ │ └── npm
│ ├── LICENSE
│ ├── README.md
│ └── share
│ ├── doc
│ │ └── node
│ └── man
│ └── man1
├── python // empty
└── rust
├── 1.69.0 // empty
└── stable // empty

117 directories, 457 files

I'm not sure what's wrong. I manage my configuration with home-manager and install some packages system-wide changing things in /etc/nixos/configuration.nix, maybe I'm missing something important in my installation?

我不确定问题出在哪里。我使用home-manager管理我的配置,并在/etc/nixos/configuration.nix中更改一些系统范围的包,也许我在安装过程中遗漏了一些重要的东西?

英文:

After moving to NixOS from Arch Linux, I installed asdf-vm (using git; commit 0adc6c1). However, I noticed that installing any rust binary fails:

$ LC_ALL=C asdf install rust stable
info: downloading installer
main: line 494: /tmp/tmp.XmUYT687x4/rustup-init: cannot execute: required file not found

This also happens trying to install a binary for python:

$ asdf install python 3.11.3
python-build 3.11.3 /home/jorge/.asdf/installs/python/3.11.3
Downloading Python-3.11.3.tar.xz...
-> https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tar.xz
Installing Python-3.11.3...

BUILD FAILED (NixOS 23.05 using python-build 2.3.17-10-g920ef145)

Inspect or clean up the working tree at /tmp/python-build.20230513230601.298920
Results logged to /tmp/python-build.20230513230601.298920.log

Last 10 log lines:
  File "/tmp/python-build.20230513230601.298920/Python-3.11.3/Lib/ensurepip/__init__.py", line 202, in _bootstrap
    return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/python-build.20230513230601.298920/Python-3.11.3/Lib/ensurepip/__init__.py", line 103, in _run_pip
    return subprocess.run(cmd, check=True).returncode
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/python-build.20230513230601.298920/Python-3.11.3/Lib/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/python-build.20230513230601.298920/Python-3.11.3/python', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmplx6zl6yc/setuptools-65.5.0-py3-none-any.whl\', \'/tmp/tmplx6zl6yc/pip-22.3.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmplx6zl6yc\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make: *** [Makefile:1858: install] Error 1

Installing binaries for Go works fine, but executing go fails:

$ LC_ALL=C go
/home/jorge/.asdf/lib/commands/command-exec.bash: line 28: /home/jorge/.asdf/installs/golang/1.19/go/bin/go: cannot execute: required file not found

Same thing for NodeJS' npm:

$ LC_ALL=C npm
/home/jorge/.asdf/lib/commands/command-exec.bash: line 28: /home/jorge/.asdf/installs/nodejs/20.1.0/bin/node: cannot execute: required file not found

you may wonder if the files missing truly exists at the locations shown in the errors, and well, they do:

$ tree -L 5
.
├── golang
│   └── 1.19
│       └── go
│           ├── api
│           ├── bin
│           │   ├── go
│           │   └── gofmt
...
├── nodejs
│   └── 20.1.0
│       ├── bin
│       │   ├── corepack -> ../lib/node_modules/corepack/dist/corepack.js
│       │   ├── node
│       │   ├── npm -> ../lib/node_modules/npm/bin/npm-cli.js
│       │   └── npx -> ../lib/node_modules/npm/bin/npx-cli.js
...
│       ├── lib
│       │   └── node_modules
│       │       ├── corepack
│       │       └── npm
│       ├── LICENSE
│       ├── README.md
│       └── share
│           ├── doc
│           │   └── node
│           └── man
│               └── man1
├── python // empty
└── rust
    ├── 1.69.0 // empty
    └── stable // empty

117 directories, 457 files

I'm not sure what's wrong. I manage my configuration with home-manager and install some packages system-wide changing things in /etc/nixos/configuration.nix, maybe I'm missing something important in my installation?

# home.nix, for home-manager:
{ pkgs, lib, config, ... }:
let
  inherit (pkgs) stdenv;
  inherit (lib) mkIf;

  # verifica si estamos en macOS
  onMac = stdenv.isDarwin;

  # verifica si `yay` esta instalado y existe en PATH
  hasYay = pkgs.runCommand "yay-in-path" { } "command -v yay > /dev/null" == 0;

  # obtiene el nombre del host
  hostname = builtins.getEnv "HOSTNAME";

  # revisa si estamos usando la compu del trabajo XD
  atWork = lib.strings.hasInfix "CR-400" hostname;
in {
  # Home Manager needs a bit of information about you and the paths it should
  # manage.
  home.username = "jorge";
  home.homeDirectory =
    if (stdenv.isDarwin) then "/Users/jorge" else "/home/jorge";
  nixpkgs.config.allowUnfree = true;

  # This value determines the Home Manager release that your configuration is
  # compatible with. This helps avoid breakage when a new Home Manager release
  # introduces backwards incompatible changes.
  #
  # You should not change this value, even if you update Home Manager. If you do
  # want to update the value, then make sure to first check the Home Manager
  # release notes.
  home.stateVersion = "22.11"; # Please read the comment before changing.

  # The home.packages option allows you to install Nix packages into your
  # environment.
  home.packages = with pkgs; [
    # fuentes
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    mplus-outline-fonts.githubRelease
    (nerdfonts.override { fonts = [ "FiraCode" "DroidSansMono" "Iosevka" ]; })
    iosevka-comfy.comfy
    iosevka-comfy.comfy-motion-duo
    emacs-all-the-icons-fonts

    # linea de comandos
    xcp
    ripgrep
    thefuck
    tree
    fd
    jq
    d2

    # git
    git-crypt

    # dependencias de Emacs
    aspell
    aspellDicts.en
    aspellDicts.en-computers
    aspellDicts.es
    ccls
    nixfmt
    shellcheck

    # dependencias de Doom Emacs
    python311Packages.grip
    rust-analyzer
    plantuml
    html-tidy
    nodePackages_latest.stylelint
    nodePackages_latest.js-beautify
    nodePackages.prettier
  ];

  # Home Manager is pretty good at managing dotfiles. The primary way to manage
  # plain files is through 'home.file'.
  home.file = {
    "zellij-layouts-41" = {
      enable = true;
      target = ".config/zellij/layouts/41.kdl";
      text = ''
        layout {
               pane size=1 borderless=true {
                    plugin location="zellij:compact-bar"
               }
               pane split_direction="horizontal" {
                    pane split_direction="vertical" {
                         pane name="main"
                         pane split_direction="horizontal" {
                              pane name="aux. alpha"
                              pane name="aux. bravo"
                              pane name="aux. charlie"
                         }
                    }
                    pane size="20%" name="command-line" focus=true
               }
               pane size=2 borderless=true {
                    plugin location="zellij:status-bar"
               }
        }
      '';
    };
  };

  home = {
    sessionVariables = { EDITOR = "emacs"; };
    # ajusta $PATH
    sessionPath =
      [ "$HOME/.asdf/shims" "$HOME/.config/emacs/bin" "$HOME/.emacs.d/bin" ];
  };

  fonts.fontconfig.enable = true;

  programs.starship = {
    enable = true;
    # Configuration written to ~/.config/starship.toml
    settings = {
      add_newline = true;

      character = {
        success_symbol = "[](bold green) ";
        error_symbol = "[💀](bold red) ";
      };
    };
  };

  programs.zsh = {
    enable = true;
    history = {
      size = 10000;
      save = 100000;
      path = "${config.xdg.dataHome}/zsh/history";
      ignoreDups = true;
      ignorePatterns = [ "rm *" "pkill *" "killall *" "cd *" "mv *" ];
      ignoreSpace = true;
    };
    shellAliases = {
      ip = "ip --color=auto";
      cp = "xcp";
      mv = "mv -i";
      rm = " rm -v";
      ln = "ln -i";
      chown = "chown --preserve-root";
      chmod = "chmod --preserve-root";
      chgrp = "chgrp --preserve-root";
      cls = ''
        echo -ne "\033c"
      '';

    } // lib.optionalAttrs (hasYay) {
      yay = ''
        env PATH="''${PATH//~\/.asdf\/shims:/}" yay
      '';
    };

    enableCompletion = true;
    enableAutosuggestions = true;
    enableSyntaxHighlighting = true;
    dirHashes = {
      dev = "$HOME/code";
      gamedev = "$HOME/sotsfgs/proyectos";
      tmp = "/tmp";
    };

    zplug = {
      enable = true;
      plugins = [
        { name = "zsh-users/zsh-autosuggestions"; }
        { name = "marlonrichert/zsh-autocomplete"; }
        {
          name = "plugins/asdf";
          tags = [ "from:oh-my-zsh" ];
        }
        {
          name = "plugins/brew";
          tags = [ "from:oh-my-zsh" ''if:"[[ $OSTYPE == *darwin* ]]"'' ];
        }
      ];
    };
  };

  programs.fzf = {
    enable = true;
    enableZshIntegration = true;
    defaultOptions =
      [ "--height 40%" "--layout=reverse" "--border" "--inline-info" ];
  };

  programs.bat = {
    enable = true;
    config = { tabs = "8"; };
  };

  programs.git = {
    enable = true;
    package = pkgs.gitAndTools.gitFull;
    userEmail = "jorge@esavara.cr";
    userName = "Jorge Javier Araya Navarro";
    signing = mkIf (!atWork) {
      key = "F15FE636C8AEC2D9";
      signByDefault = false;
    };

    extraConfig = {
      core = { whitespace = "trailing-space,space-before-tab"; };
      color = { ui = "auto"; };
      rerere = { enabled = "true"; };
      rebase = { autoSquash = "true"; };
      github = { user = "shackra"; };
      init.defaultBranch = "master"; # a classic
      url = mkIf atWork {
        "ssh://git@github.com/" = { insteadOf = "https://github.com/"; };
      };
    };

    lfs = { enable = true; };

    ignores = [
      "*~"
      "*.swp"
      ".ccls-cache"
      "compile_commands.json"
      "shell.nix"
      ".tool-versions"
      ".DS_Store"
    ];
  };

  programs.exa = {
    enable = true;
    enableAliases = true;
    icons = true;
    extraOptions = [ "--group-directories-first" "--header" ];
    git = true;
  };

  services.gpg-agent = {
    enable = stdenv.isLinux;

    defaultCacheTtl = 86400;
    defaultCacheTtlSsh = 86400;
    maxCacheTtl = 86400;
    maxCacheTtlSsh = 86400;
    enableSshSupport = true;
  };

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}
# configuration.nix, for the system configuration

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:
let

  # truco de https://discourse.nixos.org/t/gdm-monitor-configuration/6356/4
  monitorsXmlContent = builtins.readFile /home/jorge/.config/monitors.xml;
  monitorsConfig = pkgs.writeText "gdm_monitors.xml" monitorsXmlContent;
in {
  imports = [ # Include the results of the hardware scan.
    ./hardware-configuration.nix
  ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";
  # Copied from virtualisation.lxd.recommendedSysctlSettings
  boot.kernel.sysctl = {
    "fs.inotify.max_queued_events" = 1048576;
    "fs.inotify.max_user_instances" = 1048576;
    "fs.inotify.max_user_watches" = 1048576;
    "vm.max_map_count" = 2147483642; # use by Steam Deck
    "kernel.dmesg_restrict" = 1;
    "net.ipv4.neigh.default.gc_thresh3" = 8192;
    "net.ipv6.neigh.default.gc_thresh3" = 8192;
    "kernel.keys.maxkeys" = 2000;
  };

  systemd.tmpfiles.rules =
    [ "L+ /run/gdm/.config/monitors.xml - - - - ${monitorsConfig}" ];

  networking.hostName = "woody"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "America/Costa_Rica";

  # Select internationalisation properties.
  i18n.defaultLocale = "es_CR.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "es_CR.UTF-8";
    LC_IDENTIFICATION = "es_CR.UTF-8";
    LC_MEASUREMENT = "es_CR.UTF-8";
    LC_MONETARY = "es_CR.UTF-8";
    LC_NAME = "es_CR.UTF-8";
    LC_NUMERIC = "es_CR.UTF-8";
    LC_PAPER = "es_CR.UTF-8";
    LC_TELEPHONE = "es_CR.UTF-8";
    LC_TIME = "es_CR.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;
  services.xserver.videoDrivers = [ "nvidia" ];

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "us";
    xkbVariant = "";
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;
  services.printing.drivers = [ pkgs.hplip ];
  services.avahi.enable = true;
  services.avahi.nssmdns = true;
  # for a WiFi printer
  services.avahi.openFirewall = true;

  # activa accesorios para Xbox one
  hardware.xone.enable = true;

  # Steam
  hardware.steam-hardware.enable = true;
  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true;
  };

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Ledger
  hardware.ledger.enable = true;

  # habilita ZSH
  programs.zsh.enable = true;

  # habilita kdeconnect
  programs.kdeconnect.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.jorge = {
    isNormalUser = true;
    description = "Jorge Javier Araya Navarro";
    extraGroups = [ "networkmanager" "wheel" "docker" "libvirtd" ];
    shell = pkgs.zsh;
    packages = with pkgs; [ firefox nextcloud-client brave bitwarden-cli ];
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;
  nixpkgs.config.permittedInsecurePackages =
    [ "electron-11.5.0" "electron-21.4.0" "python-2.7.18.6" ];

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    # otros
    bindfs

    # fuentes
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    mplus-outline-fonts.githubRelease
    (nerdfonts.override { fonts = [ "FiraCode" "DroidSansMono" "Iosevka" ]; })
    iosevka
    iosevka-comfy.comfy
    iosevka-comfy.comfy-motion-duo
    fira
    fira-code

    # linea de comandos
    aspell
    aspellDicts.en
    aspellDicts.en-computers
    aspellDicts.es
    bitwarden
    bitwarden-cli
    bitwarden-menu
    butler
    ccls
    clang
    cmake
    cmake-format
    cmake-language-server
    coreutils
    curl
    d2
    dig
    emacs
    evince
    fd
    firefox-devedition
    git
    git-crypt
    gnumake
    html-tidy
    hunspell
    hunspellDicts.en_US
    hunspellDicts.es_CR
    hunspellDicts.es_ES
    jq
    libreoffice-fresh
    nixfmt
    nodePackages.prettier
    nodePackages_latest.js-beautify
    nodePackages_latest.stylelint
    plantuml
    python311Packages.grip
    ripgrep
    rust-analyzer
    shellcheck
    stow
    thefuck
    tree
    wget
    xcp
    libtool
    clipgrab
    texlive.combined.scheme-full
    texlab
    lua53Packages.digestif

    alacritty
    firefox
    gimp
    inkscape
    notion-app-enhanced
    signal-desktop-beta
    smplayer
    spotify
    tdesktop
    teams
    todoist-electron
    discord
    slack
    vlc
    zoom-us
    pdfarranger
    hplip
    newsflash
    avidemux
    audacity
    libsForQt5.kdenlive
    mediainfo
    # davinci-resolve
    deluge
    xsane

    # entretenimiento y juegos
    itch
    prismlauncher
    protonup-qt
    rpcs3
    heroic

    # Gnome
    gnomeExtensions.auto-move-windows
    gnomeExtensions.clipman
    gnomeExtensions.gnome-bedtime
    gnomeExtensions.memento-mori
    gnomeExtensions.no-overview
    gnomeExtensions.pop-shell
    gnomeExtensions.stonks
    gnomeExtensions.time-awareness
    gnomeExtensions.wallpaper-switcher
    gnomeExtensions.weather
    gnomeExtensions.weather-oclock
    gnomeExtensions.zilence
    gnomeExtensions.appindicator
    gnome.gnome-tweaks

    # privacidad
    protonmail-bridge
    protonvpn-gui

    # docker
    # el paquete docker ya es activado como servicio más abajo
    kubecolor
    kubectl
    kubectx
    docker-compose

    # virtualization
    virt-manager

    # dependencias para construir Python
    gcc
    zlib
    libffi
    openssl
    bzip2
    readline
    sqlite
    xz

    # Android
    scrcpy

    # cripto
    ledger-live-desktop
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  services.openssh.enable = true;
  virtualisation.docker = {
    enable = true;
    autoPrune.enable = true;
  };
  virtualisation.libvirtd.enable = true;
  programs.dconf.enable = true;

  # Open ports in the firewall.
  networking.firewall.allowedTCPPorts = [ 22 ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "23.05"; # Did you read the comment?

}

答案1

得分: 2

将以下内容添加到您的~/.zshrc文件中:

# 实际上是此文件 (https://github.com/asdf-vm/asdf/blob/v0.11.3/asdf.sh)
# 从/nix/store中
. $(dirname $(dirname $(readlink -f $(which asdf))))/share/asdf-vm/asdf.sh

如果您查看官方asdf安装说明,它们说:

  • 将存储库克隆到~/.asdf
  • 源自~/.asdf/asdf.sh(例如此文件

现在,如果您从nix安装asdf-vm

  • asdf存储库被克隆到/nix/store
    • 这是nix的工作方式,所有内容都被克隆到/nix/store,而不是到您的$HOME
  • 并且您将在~/.nix-profile/bin中获得一个好用的命令(asdf),它是您的$PATH的一部分

如果您在/nix/store中查找,您会发现asdf存储库在那里,所以使用我上面使用的命令源自asdf.sh文件。

英文:

TLDR

Add this to your ~/.zshrc

# effectively this file (https://github.com/asdf-vm/asdf/blob/v0.11.3/asdf.sh)
# from inside /nix/store 
. $(dirname $(dirname $(readlink -f $(which asdf))))/share/asdf-vm/asdf.sh

Explanation

If you look at the official asdf installation instructions, they say:

  • clone the repo to ~/.asdf
  • source ~/.asdf/asdf.sh (e.g. this file)

Now, if you install asdf-vm from nix:

  • the asdf repo is cloned in /nix/store
    • this is how nix works, everything gets cloned to /nix/store, rather than in your $HOME
  • and you get a nice command (asdf) in ~/.nix-profile/bin, which is part of your $PATH

If you poke around /nix/store, you'll realise the asdf repo is in there, so source the asdf.sh file with the command I used above.

答案2

得分: 0

以下是要翻译的内容:

缺失的文件不是您正在执行的二进制文件,而是它们的一些动态链接库,这些库未存储在NixOS的通常位置。

总的来说,在NixOS上下载预编译的二进制文件相当不方便。

解决方案是通过nix安装asdf-vm,而不是手动安装,因为仓库中的软件包已经经过了适当的补丁,以找到它们实际所在的库。

英文:

The file that are missing are not the binaries that you are executing, but some of their dinamically linked libraries which are not stored in the usual place in NixOS.

This makes it, in general, quite inconvenient to download pre-compiled binaries on NixOS.

The solution here would be to install asdf-vm through nix, rather than by hand, because packages in the repo are duly patched to find the libraries where they actually are.

答案3

得分: 0

"Taking @jb007's answer one step further, if you use programs.zsh to configure your .zshrc, you can add this programs.zsh.initExtra line to write the proper line for your:

initExtra = \". ${pkgs.asdf-vm}/share/asdf-vm/asdf.sh\";
```"
<details>
<summary>英文:</summary>
Taking @jb007&#39;s answer one step further, if you use `programs.zsh` to configure your .zshrc, you can add this `programs.zsh.initExtra` line to write the proper line for your:

initExtra = ". ${pkgs.asdf-vm}/share/asdf-vm/asdf.sh";


</details>

huangapple
  • 本文由 发表于 2023年5月14日 13:22:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76245966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定