4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

"WARNING: `pyenv init -` no longer sets PATH."のFish shellでの解決

Posted at

pyenvのアップデートでpyenv init -の仕様が代わり、自動でパスが設定されなくなったそうな。
その為、以前のセットアップのままの人向けに警告文が出力されるようになり、シェル起動時に件の文が出る。

python init で必要な変更に関する情報を得ろって言われるので見てみる。

# (The below instructions are intended for common
# shell setups. See the README for more guidance
# if they don't apply and/or don't work for you.)

# Add pyenv executable to PATH by running
# the following interactively:

set -Ux PYENV_ROOT $HOME/.pyenv
set -U fish_user_paths $PYENV_ROOT/bin $fish_user_paths

# Load pyenv automatically by appending
# the following to ~/.config/fish/config.fish:

status is-login; and pyenv init --path | source
pyenv init - | source

# If fish is not your login shell,
# add the following to ~/.profile:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"

読むと必要なのが次のものだと分かるので~/.config/fish/config.fishにあるpyenvのコードと置き換える。

set -Ux PYENV_ROOT $HOME/.pyenv
set -U fish_user_paths $PYENV_ROOT/bin $fish_user_paths
status is-login; and pyenv init --path | source
pyenv init - | source

実際の設定

pyenv-virtualenvtmuxにも対応したものがこれ。

set -Ux PYENV_ROOT $HOME/.pyenv
set -U fish_user_paths $PYENV_ROOT/bin $fish_user_paths
if command -v pyenv 1>/dev/null 2>&1
    if status is-login && test -z "$TMUX"
        pyenv init --path fish | source
    end
    pyenv init - fish | source
    pyenv virtualenv-init - fish | source
end

GUIのターミナルの設定

GUIのターミナルではログインシェルとして実行するかどうかの設定があるものもある。
その場合は設定によってはpyenv init --pathが実行されなくなってしまうので注意。

4
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?