Open8

LunarVimインストールやっていくぞ on MacOS x86_64

さんたむさんたむ

$ pip3 install pynvimで次のようなエラーが出てしまう

pipのエラー
[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: python3.13 -m pip install --upgrade pip
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.

    If you wish to install a Python library that isn't in Homebrew,
    use a virtual environment:

    python3 -m venv path/to/venv
    source path/to/venv/bin/activate
    python3 -m pip install xyz

    If you wish to install a Python application that isn't in Homebrew,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. You can install pipx with

    brew install pipx

    You may restore the old behavior of pip by passing
    the '--break-system-packages' flag to pip, or by adding
    'break-system-packages = true' to your pip.conf file. The latter
    will permanently disable this error.

    If you disable this error, we STRONGLY recommend that you additionally
    pass the '--user' flag to pip, or set 'user = true' in your pip.conf
    file. Failure to do this can result in a broken Homebrew installation.

    Read more about this behavior here: <https://peps.python.org/pep-0668/>

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
さんたむさんたむ

uvのインストール

$ curl -LsSf https://astral.sh/uv/install.sh | sh

グローバルな仮想環境を$HOME/.venvに作る

$ cd $HOME && uv venv

uvでグローバル環境のpythonを設定したいので、uvでグローバルなpythonを設定するuv: setting preferred/global Python versionを参考に次を.zshprofileに追記

# Check if the current directory contains a .venv folder
if [[ -d ".venv" ]]; then
    # If .venv exists in the current directory, activate it
    source .venv/bin/activate
else
    # Otherwise, activate the global virtual environment at ~/.venv
    if [[ -d "$HOME/.venv" ]]; then
        source "$HOME/.venv/bin/activate"
    else
        echo "No virtual environment found in .venv or ~/.venv"
    fi
fi
さんたむさんたむ

再度pynvimのインストール

$ uv pip install pynvim

NeoVim本体のインストール

$ brew install neovim

LunarVimのインストール

$ LV_BRANCH='release-1.4/neovim-0.9' bash <(curl -s https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.4/neovim-0.9/utils/installer/install.sh)
さんたむさんたむ

インストールオプションで、

Would you like to install LunarVim's Rust dependencies: fd::fd-find, rg::ripgrep?
[y]es or [n]o (default: no) : y

としたところ、以下のエラーが発生。

エラーメッセージ(一部省略)
error: linking with `/usr/bin/clang` failed: exit status: 1
  = note: clang: error: invalid linker name in argument '--ld-path=/usr/local/opt/llvm/bin/ld64.lld'

error: could not compile `crossbeam-utils` (build script) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: linking with `/usr/bin/clang` failed: exit status: 1
  = note: clang: error: invalid linker name in argument '--ld-path=/usr/local/opt/llvm/bin/ld64.lld'

error: could not compile `proc-macro2` (build script) due to 1 previous error
error: linking with `/usr/bin/clang` failed: exit status: 1
  = note: clang: error: invalid linker name in argument '--ld-path=/usr/local/opt/llvm/bin/ld64.lld'

error: could not compile `rustix` (build script) due to 1 previous error
error: failed to compile `fd-find v10.2.0`, intermediate artifacts can be found at `/var/folders/tg/2m4w3vm91fbbx7lkw5fgh3gm0000gn/T/cargo-installaGj8q7`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

エラーを見る限り、リンカー周りで何か問題が起こってそうである

さんたむさんたむ

$HOME/.cargo/config.tomlに

[target.x86_64-apple-darwin]
linker = "/usr/bin/clang"
rustflags = ["-C", "link-arg=--ld-path=/usr/local/opt/llvm/bin/ld64.lld"]

と書いてあったのが原因っぽい。ファイルごと削除して解決。