[Bug]: pyenv plugin (or just pathmunge?) breaks over SSH
SwampFalc opened this issue · comments
Expected behavior
When connecting to my laptop over SSH, bashit should work the same as when I open a local session.
Current behavior
With the pyenv
plugin enabled:
$ ssh -X lapx-fhq-042
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-121-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
0 updates can be applied immediately.
Last login: Fri Jul 1 10:24:48 2022 from 127.0.0.1
Command 'mktemp' is available in '/bin/mktemp'
The command could not be located because '/bin' is not included in the PATH environment variable.
mktemp: command not found
Command 'tput' is available in '/usr/bin/tput'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
tput: command not found
Command 'tput' is available in '/usr/bin/tput'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
tput: command not found
Command 'tty' is available in '/usr/bin/tty'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
tty: command not found
Command 'setxkbmap' is available in '/usr/bin/setxkbmap'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
setxkbmap: command not found
Command 'jump' is available in '/usr/bin/jump'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
jump: command not found
Command 'sed' is available in '/bin/sed'
The command could not be located because '/bin' is not included in the PATH environment variable.
sed: command not found
-bash: /usr/bin/grep: No such file or directory
-bash: /usr/bin/grep: No such file or directory
Without the plugin enabled:
$ ssh -X lapx-fhq-042
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-121-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
0 updates can be applied immediately.
Last login: Fri Jul 1 10:24:48 2022 from 127.0.0.1
Possible solution
I'm guessing something goes wrong in pathmunge?
Context
No response
Steps to reproduce
- Install bashit
- Install pyenv
- Enable pyenv plugin
- Enable sshd on the machine
- Open an ssh connection to the machine
Bash-it version
Version type: dev Current git SHA: 2ef5d48 on 2022-05-19T00:11:54+03:00 Commit info: 2ef5d483 Compare to latest: 2ef5d48...master
List of enabled plugins, themes and aliases
base [x] miscellaneous tools
extract [x] one command to extract them all...
history [x] improve history handling with sane defaults
jump [x] initialize jump (see https://github.com/gsamokovarov/jump). Add `export JUMP_OPTS=("--bind=z")` to change keybinding
powerline [x] enables powerline daemon
pyenv [x] load pyenv, if you are using it
thefuck [x] Initialization for fuck
xterm [x] automatically set your xterm title with host and location info
Bash version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Operating system and version
Ubuntu 20.04
bash-it doctor output
# How to get: bash-it doctor
Your ~/.bashrc
#!/usr/bin/env bash
# Path to the bash it configuration
export BASH_IT="/home/ldt/.bashit"
# Lock and Load a custom theme file.
# Leave empty to disable theming.
# location /.bash_it/themes/
export BASH_IT_THEME='powerline'
# (Advanced): Change this to the name of your remote repo if you
# cloned bash-it with a remote other than origin such as `bash-it`.
# export BASH_IT_REMOTE='bash-it'
# Your place for hosting Git repos. I use this for private repos.
export GIT_HOSTING='git@git.domain.com'
# Don't check mail when opening terminal.
unset MAILCHECK
# Change this to your console based IRC client of choice.
export IRC_CLIENT='irssi'
# Set this to the command you use for todo.txt-cli
export TODO="t"
# Set this to false to turn off version control status checking within the prompt for all themes
export SCM_CHECK=true
# Disable sudo check
export THEME_CHECK_SUDO=false
# Set Xterm/screen/Tmux title with only a short hostname.
# Uncomment this (or set SHORT_HOSTNAME to something else),
# Will otherwise fall back on $HOSTNAME.
#export SHORT_HOSTNAME=$(hostname -s)
# Set Xterm/screen/Tmux title with only a short username.
# Uncomment this (or set SHORT_USER to something else),
# Will otherwise fall back on $USER.
#export SHORT_USER=${USER:0:8}
# Set Xterm/screen/Tmux title with shortened command and directory.
# Uncomment this to set.
#export SHORT_TERM_LINE=true
# Set vcprompt executable path for scm advance info in prompt (demula theme)
# https://github.com/djl/vcprompt
#export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt
# (Advanced): Uncomment this to make Bash-it reload itself automatically
# after enabling or disabling aliases, plugins, and completions.
# export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=1
# Uncomment this to make Bash-it create alias reload.
# export BASH_IT_RELOAD_LEGACY=1
# Load Bash It
source "$BASH_IT"/bash_it.sh
Notes
No response
@SwampFalc I'm struggling to see how pyenv is related. When you disable that plugin, does everything else start working again?
There are two sections in the "Current behavior" part, where I show that yes, without pyenv it works.
@SwampFalc I see that, but the errors presented don't indicate that bash-it is the culprit. It looks like your remote host does not have the binaries needed to support pyenv. That, or your remote host is not setting up your environment properly. I created a test ubuntu virtual machine and I can ssh into it with bash-it and pyenv installed and enabled. Without being able to reproduce this, I'm at a loss.
@cornfeedhobo just to confirm, there is no remote host, the user is ssh-ing into the very same machine (local laptop) ie
Methinks some configuration causes a different bash environment when ssh-ing vs local terminal ...
BUT @SwampFalc the pyenv.plugin.bash
script is pretty short, so I recommend you make some local edits and try to debug it real quick, ie what is the value of $PATH
before / after pathmunge, etc:
# shellcheck shell=bash
cite about-plugin
about-plugin 'load pyenv, if you are using it'
# https://github.com/pyenv/pyenv
# Load after basher
# BASH_IT_LOAD_PRIORITY: 260
# Don't modify the environment if we can't find the tool:
# - Check if in $PATH already
# - Check if installed manually to $PYENV_ROOT
# - Check if installed manually to $HOME
_command_exists pyenv \
|| [[ -n "$PYENV_ROOT" && -x "$PYENV_ROOT/bin/pyenv" ]] \
|| [[ -x "$HOME/.pyenv/bin/pyenv" ]] \
|| return 0
# Set PYENV_ROOT, if not already set
export PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}"
#!!!
echo "PYENV_ROOT = ${PYENV_ROOT}"
echo PATH before munge = ${PATH}"
#!!!
# Add PYENV_ROOT/bin to PATH, if that's where it's installed
if ! _command_exists pyenv && [[ -x "$PYENV_ROOT/bin/pyenv" ]]; then
pathmunge "$PYENV_ROOT/bin"
fi
#!!!
echo PATH after munge = ${PATH}"
#!!!
#!!! Maybe disabled these below lines to remove them from the equation
# Initialize pyenv
pathmunge "$PYENV_ROOT/shims"
eval "$(pyenv init - bash)"
# Load pyenv virtualenv if the virtualenv plugin is installed.
if pyenv virtualenv-init - &> /dev/null; then
eval "$(pyenv virtualenv-init - bash)"
fi
Unfortunately, something happened between when I made the report about two months ago, and now, and the error no longer occurs.
One of the things I did in the meantime was update bashit, perhaps something else fixed pathmunge?
The one thing I do remember is that I did check what the path was after the error, and it was only the added pieces (ie. pyenv-related), all the basics had been dropped.
Like if someone had done export PATH=<pyenv paths>
instead of export PATH=PATH:<pyenv paths>