pyenv / pyenv-installer

This tool is used to install `pyenv` and friends.
MIT License
3.96k stars 428 forks source link

Carrrige return error on WSL #134

Closed agamm closed 1 year ago

agamm commented 2 years ago

Steps:

  1. Open WSL terminal
  2. Run curl https://pyenv.run | bash
  3. Run exec $SHELL
  4. Run pyenv

Result:

bash: /mnt/c/Users/UserName/.pyenv/pyenv-win/bin/pyenv: /bin/sh^M: bad interpreter: No such file or directory

Take note of the ^M, seems related to this. Or I suspect it thinks it is in windows when it is running inside an ubuntu vm (via WSL).

Taar commented 1 year ago

The issue is that /mnt/c/Users/UserName/.pyenv/pyenv-win/bin/ is in your $PATH (or that your window's path is being shared with the WSL instance). Try running echo $PATH | ag "/mnt/c/Users" to see if the above statement is true. (ag can be installed with sudo apt install the-silver-searcher assuming you're using ubuntu).

To resolve the issue make sure the following is in your .bashrc file (assuming bash/zsh):

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
# omit the last eval command if you don't want to use virtualenvs
# otherwise make sure you've completed the
# install instructions found here: https://github.com/pyenv/pyenv-virtualenv
eval "$(pyenv virtualenv-init -)"

then run the following command to rerun all the commands in .bashrc

source ~/.bashrc

Now pyenv should work correctly and this error should no longer appear.

agamm commented 1 year ago

Something here worked, thanks!