Mac Terminal -bash: rbenv: command not found - bash

Every time I open terminal on my Mac, the following outputs:
-bash: rbenv: command not found
Any idea how to stop this from appearing as it's annoying?
cat .*profile result:
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

Related

pyenv - environment "activated", but python and pip not found

I suppose there is something wrong with my bash init scripts (like .bashrc or .bash_profile). But let's start from beginning.
I can create and activate pyenv environment, but when I try to use python, I get error: -bash: python: command not found.
It looks like pyenv understands creation and swapping envorinments. I mean, it's probably not malformed. There is preview of my tries:
$ mkdir test-python-project
$ cd test-python-project/
$ pyenv versions
* system (set by /home/vagrant/.pyenv/version)
3.7.10
3.7.10/envs/k-pkb-env
$ pyenv virtualenv 3.7.10 test-env
Looking in links: /tmp/tmpkwojcc1e
Requirement already satisfied: setuptools in /home/vagrant/.pyenv/versions/3.7.10/envs/test-env/lib/python3.7/site-packages (47.1.0)
Requirement already satisfied: pip in /home/vagrant/.pyenv/versions/3.7.10/envs/test-env/lib/python3.7/site-packages (20.1.1)
$ pyenv activate test-env
pyenv-virtualenv: prompt changing will be removed from future release. configure export PYENV_VIRTUALENV_DISABLE_PROMPT=1 to simulate the behavior.
(test-env) $ python
-bash: python: command not found
(test-env) $ pyenv local test-env
(test-env) $ cd ..
(test-env) $ pyenv deactivate
$ cd test-python-project/
(test-env) $ python
-bash: python: command not found
(test-env) $ pip
-bash: pip: command not found
(test-env) $ pyenv version
test-env (set by /home/vagrant/Work/test-python-project/.python-version)
I'm not sure how to configure bash init scripts, because in pyenv readme they suggest using .profile, which I don't have.
So, there are my bash inits:
.bashrc
$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
.bash_profile
$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
# PyEnv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Some additional information:
$PATH variable
$ echo $PATH
/home/vagrant/.pyenv/plugins/pyenv-virtualenv/shims:/home/vagrant/.pyenv/bin:/home/vagrant/.local/bin:/home/vagrant/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
It's a bit strange for me, because this additional paths added by pyenv doesn't seem to contain path to desired virtual environment:
$ ls /home/vagrant/.pyenv/plugins/pyenv-virtualenv/shims
activate deactivate
$ ls /home/vagrant/.pyenv/bin
pyenv
type python
$ type python
-bash: type: python: not found
which python
$ which python
/usr/bin/which: no python in (/home/vagrant/.pyenv/plugins/pyenv-virtualenv/shims:/home/vagrant/.pyenv/bin:/home/vagrant/.local/bin:/home/vagrant/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
I tried also pyenv rehash, but also still no effect:
(test-env) [vagrant#centos test-python-project]$ pyenv rehash
(test-env) [vagrant#centos test-python-project]$ python
-bash: python: command not found
With some help from #Simba, I managed to have my configuration correct:
.bash_profile
# .bash_profile
# !!! ITS IMPORTANT THESE LINES MUST BE BEFORE . ~/.bashrc
# PyEnv - only path-related
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
# !!! ITS IMPORTANT THESE LINES ABOVE MUST BE BEFORE . ~/.bashrc
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
# PyEnv - commands
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Solution
READ THE PYENV GUIDE CAREFULLY.
You didn't follow pyenv's README guide correctly. The guide tells you put PATH related operation in .bash_profile or .profile. But eval "$(pyenv init -)" in .bashrc.
Move pyenv init script from .bash_profile to .bashrc.
# Put it in .bashrc
# PyEnv
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Extended Reading
You bash shell is not a login shell. .bash_profile is not sourced at all, which skip pyenv init -.
Bash initialization
login mode:
/etc/profile
~/.bash_profile, ~/.bash_login, ~/.profile (only the first one that exists)
interactive non-login:
/etc/bash.bashrc (some Linux; not on Mac OS X)
~/.bashrc
non-interactive:
source file in $BASH_ENV
The default shell on Linux is a non-login, interactive shell. The default shell on macOS is a login, interactive shell.
There's also a detailed explanation about the shell startup by flowblok
Ref
Unix shell initialization from pyenv wiki
Shell startup scripts

OSX Terminal not recognizing ~/.bashrc and ~/.bash_profile on startup

The only way my .bashrc and .bashprofile are recognized by OSX is if I specify in my terminal's preferences for the file to be targeted upon boot. Is there a reason why they're not working like they should be?
Here's the inside of my .bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #
Load RVM into a shell session *as a function*
#Add RVM to PATH for scripting. Make sure this is the last PATH
variable change.
export PATH="$PATH:$HOME/.rvm/bin"
smiley () { echo -e ":\\$(($??50:51))"; }
export PS1="\h\$(smiley) \e[30;1m\w\e[0m\n\$ "
Inside of .bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #
Load RVM into a shell session *as a function*
# Add RVM to PATH for scripting. Make sure this is the last PATH n .
variable change.
export PATH="$PATH:$HOME/.rvm/bin"
alias b='cd ..'
Any help would be appreciated! Thanks!
In OSX, all sessions are login sessions and will not source $HOME/.bashrc, they will source $HOME/.profile or $HOME/.bash_profile. So put the following in your .bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

Where is Ruby getting added to my $PATH?

I’m using Mac Yosemite with bash shell. I had installed Ruby 2.2.1 but then wanted to upgrade it, so I installed Ruby 2.3.0. However, when I restart my terminal, my old Ruby installations in my PATH …
Daves-MacBook-Pro-2: davea$ echo $PATH
/Users/davea/.rvm/gems/ruby-2.2.1/bin:/Users/davea/.rvm/gems/ruby-2.2.1#global/bin:/Users/davea/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin/:/opt/gradle-2.7/bin:/opt/apache-maven-3.3.3/bin:/Users/davea/.rvm/bin:/usr/local/mysql/bin
I can’t figure out how this part of my PATH is getting set. I have checked these files on my system
/etc/profile
/etc/bashrc
~/.profile
~/.bash_profile
But I don’t see references to Ruby 2.2.1 anywhere. Below are the files’ content. Are there any other files I should check to find references to the $PATH?
/etc/profile
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
JBOSS_HOME=/opt/wildfly-10.0.0.CR2
M2_HOME=/opt/apache-maven-3.3.3
CATALINA_HOME=/opt/apache-tomcat-6.0.44
GRADLE_HOME=/opt/gradle-2.7
PATH=$PATH:/usr/local/mysql/bin/:$GRADLE_HOME/bin:$M2_HOME/bin
/etc/bashrc
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
# Tell the terminal about the working directory at each prompt.
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL,
# including the host name to disambiguate local vs.
# remote connections. Percent-escape spaces.
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
fi
~/.profile
export JBOSS_HOME=$JBOSS_HOME
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
MYSQL=/usr/local/mysql/bin
export PATH=$PATH:$MYSQL
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
~/.bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
RVM is setting up Ruby and related PATHS for you.
To get 2.3 run this
rvm --default use 2.3.0

Mac Yosemite 10.10 Terminal Command Not found

I'm having a strange problem,
My path looks like this
$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/php5/bin/
$ vim ~/.bash_profile
[ [-s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export MONGO_PATH=/usr/local/mongodb
export PATH=$PATH:$MONGO_PATH/bin
export PATH=$PATH:/usr/local/bin/composer
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/php5/bin/
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
alias composer='/usr/local/bin/composer/composer.phar'
if [ -f ~/.ssh/id_rsa ]; then
ssh-add -K ~/.ssh/id_rsa 2>/dev/null
fi
I still get command not found for most of my mongod elastic-search and other commands, please help.
I Ended up reinstalling my Mongo and ElasticSearch Engine and it works fine, some thing must have gone wrong while upgrading to Yosemite.

Something in my bashrc file causing bash: command not found?

When I open up a new shell I get:
Last login: Sun Mar 23 10:14:46 on ttys000
-bash:  : command not found
I'm not totally sure how to figure out what's going on there, as its not totally clear which command its talking about.
Is it likely something in the .bashrc file?
HISTSIZE=10000
HISTFILESIZE=20000
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PS1="\[\e[01;32m\]\h \[\e[01;34m\]\W \$(parse_git_branch)\[\e[01;34m\]$\[\e[00m\] "
export PYTHONSTARTUP=/Users/JimShook/.pythonstartup
export WORKON_HOME=$HOME/.virtualenv
source /usr/local/bin/virtualenvwrapper.sh
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
PATH=$PATH:/usr/local/rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
Or maybe the bash_profile?
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi
[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Any thoughts are helpful.
Things to check - as suggested above:
anything changed recently? if so, start there... (added new line/command/sourced file?)
look for 'control codes' in the your file(s)
Try:
cat -v ~/.bashrc ## look for '^M' or other special chars - remove if present
bash -n ~/.bashrc ## try the 'sourced files' separately
If using VI, some thing to try after opening the file:
:syntax off ## turn off colors - may be easier to see 'hidden' codes
:set list ## control codes may be visible

Resources