We are trying to run rbenv on El-Capitan 10.11.6. When we try to run rbenv command in the terminal we got the following error message:
command not found
We googled how to solve that issue and one possible solution is to add the "rbenv" to the system PATH, we followed the steps stated in this link. When we run the "$PATH" to check whether or not the rbenv path was added properly into the system PATH, we got the the same result:
command not found
The result of "$PATH" command is:
qwe-Mac-mini:~ amrbakri$ rbenv
-bash: rbenv: command not found
qwe-Mac-mini:~ asd$ echo $PATH
/Users/asd/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin
Can you please tell me how to add the path of rbenv properly? And what did I do wrong in the previous steps so that I can fix it.
rbenv isn't a normal command if you've installed it correctly:
$ type rbenv
rbenv is a function
. . .
According to Homebrew on Mac OS X:
You'll only ever have to run rbenv init once.
That's a bit misleading because the result of running the command is:
$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:
eval "$(rbenv init -)"
So you need to manually add eval "$(rbenv init -)" to some file that bash will source on startup. For most people ~/.bash_profile is the right place.
I notice the commands you listed seem to be run from two different users: amrbakri and asd. Combined with the question's use of "we", I wonder if there might be a problem with the environment being set correctly for one user, but not the other. Can you try using just one user?
If you are running from a non-interactive shell (such as in a crontab), you might need to add eval "$(rbenv init -)" to the startup script.
I following the instructions about "bash" command, then do the "eval" operation.
I'm in MacOS 11.2.3, in your .bash_profile, add the two lines.
export PATH="$HOME/.rbenv/bin:$PATH"#this is the required step for my mac
eval "$(rbenv init -)"
refer: https://github.com/rbenv/rbenv#homebrew-on-mac-os-x
Related
I have this line eval "$(rbenv init - zsh)" in my .zshrc. But it's throwing the command not found error for rbenv every time I start a new terminal. But rbenv works if I type it in manually, it only breaks when I start a new terminal. So in order for me to set a specific version for ruby, I need to run eval "$(rbenv init - zsh)" manually every time instead of relying on the terminal itself to run it automatically.
PS: I installed rbenv with Homebrew.
I have this line eval "$(rbenv init - zsh)" in my .zshrc.
The line should be after the rbenv binary location is loaded to the PATH environment variable.
Example:
export PATH="/home/someusername/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
When switching from bash to zsh, I looked up how to resolve an issue with my rbenv folder not being used correctly by zsh and found this:
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshenv
$ echo 'eval "$(rbenv init -)"' >> ~/.zshenv
$ echo 'source $HOME/.zshenv' >> ~/.zshrc
$ exec $SHELL
I ran all of these and seem to be using the correct rbenv folder now, but I get this error message whenever I open a new iTerm window:
/Users/myname/.zshenv:2: command not found: rbenv
What am I doing wrong? Any help would be very appreciated.
You need to add two things to your PATH.
First rbenv itself and second the ruby shims.
Part 1 rbenv
Installation
Homebrew
If you installed rbenv with brew,
then the rbenv executable should be linked to /usr/local/bin/rbenv.
See homebrew installation documentation for details.
Please add /usr/local/bin to your path PATH, if it is missing.
# in ~/.zshrc
export PATH=/usr/local/bin:$PATH
Github Checkout
If you install rbenv via a Github checkout, then the rbenv executalbe should be stored in ~/.rbenv/bin.
See github installation documentation for details.
Please add ~/.rbenv/bin to your path PATH, if it is missing.
# in ~/.zshrc
export PATH=$HOME/.rbenv/bin:$PATH
Verfiy
Please verify that rbenv is in your path by calling which rbenv.
The installation path should be returend.
Part 2 shims
Add the ruby shims to you path.
# in ~/.zshrc
eval "$(rbenv init -)"
Instead of the eval "$(rbenv init -)" command you can also add the shims folder directly.
# in ~/.zshrc
export RBENV_ROOT=$HOME/.rbenv
export PATH=$RBENV_ROOT/shims:/versions:$PATH
Part 3 rbenv doctor
You might also run the rbenv-doctor script mentioned here,
to check your installation.
I had the same problem...
when I ran ruby or rbenv, I got this error "command not found"
try this:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshenv
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshenv
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.zshenv
I had this same error. I could run which rbenv and rbenv just fine, but no matter what I would get command not found: rbenv. The issue was that I had eval "$(rbenv init -)" in my ~/.zshenv and not my ~/.zshrc file. You may still have the path to rbenv be added to $PATH within ~/.zshenv for it to work.
Long story made short, I am trying to issue myself an SSL certificate using LetsEncrypt, and have recently installed rbenv to make this process easier. After installing rbenv, I check to see if everything checks out using
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
I than get this message saying that there are no versions of ruby installed. After trying to install ruby using the command
"rbenv install 2.3.1"
I get this error
rbenv: no such command `install'
Is it because the path to my rbenv shims aren't in my PATH variable ? If this is the case how do I add directories to my PATH variable ? I know you have to add them to your bash_profile file, but am not sure where in this file I need to add something, and what I need to add.
~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
function letsencrypt_webfaction {
PATH=$PATH:$GEM_HOME/bin GEM_HOME=$HOME/.letsencrypt_webfaction/gems RUBYLIB=$GEM_HOME/lib ruby2.2 $HOME/.letsencrypt_webfaction/gems/bin/letsencrypt_webfaction $*
}
eval "$(rbenv init -)"
PATH=$PATH:$HOME/bin
export PATH
export PATH="$HOME/.rbenv/bin:$PATH"
Always be careful when editing the profile.
Better make a backup first
switch to home directory:
cd
list hiden files:
ls -la .bash*
make a backup copy of .bash_profile:
cp -p .bash_profile .bash_profile.bak
check the current PATH: echo $PATH
check if ruby is in the PATH: which ruby
check the ruby version: ruby --version
I am not sure where this function is comming from in your .bash_profile: function letsencrypt_webfaction()
Use : as a separator and add a new directory new_dir to your PATH, use $PATH to keep the contents of the actual PATH, then export the new PATH:
PATH=$PATH:/new_dir:/new_lib
export PATH
Verify if the PATH is what you need from the terminal: echo $PATH
Personaly I sugest making a backup of .bash_profile as it is. Comment out with # the 3 lines for the function and the others where the PATH appears and add this:
export RUBYLIB=$HOME/lib
export GEM_HOME=$HOME/gems
export PATH=$HOME/bin:$PATH:
After this please check the bulet points above and see if you have the ruby version you expect.
According to the documentation you should install the ruby-build plugin:
The rbenv install command doesn't ship with rbenv out of the box,
but is provided by the ruby-build project.
I have installed the Anaconda for Mac, but there is something wrong with me:
when I type the commandwhich conda or which ipython, I get conda not found and ipython not find
Then I find this command export PATH=~/anaconda/bin:"$PATH" works for me. It solves the problem above, but everytime I rerun the terminal the problem is still there, I have to type it again.
so I want to find a way to solve the problem fundamentally
I have tried to add it into the ~/.bashrc, ~/.profile, ~/.bash_profile, but these don't work for me.
Try this in .bash_profile
export PATH="$HOME/anaconda/bin:$PATH"
Then try launching a new terminal and running:
echo $PATH
The output should start with /anaconda/bin:
If that still doesn't work... A work around might be to invoke bash after running terminal i.e. type "bash". Which should cause bash to launch with .bash_profile
I run on MacOs Catalina 10.15 and this did the trick for me:
shell is zsh !
$ source /Users/myprofilename/anaconda3/bin/activate
then
$ conda init zsh
the new anaconda documentation also highlights this:
Make sure you're not using ZShell or another form of a shell. If the case you'd have to add the path to your respective shell file, e.g .zshrc.
sudo xed /etc/environment
after open this archive add :/home/youruser/anaconda3/bin
If you're using ZShell follow the steps below:
In your terminal type open ~/.zshrc
Add the following to the file export PATH=/opt/homebrew/bin:$PATH
Save your file and then run the following command source ~/.zshrc
Please note that the homebrew path on Apple silicon is /opt/homebrew/bin
I'm trying to set $PATH variable in MacVim to the same value it has in a Terminal.
From these sources I wrote in ~/.zprofile
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
eval "$(rbenv init -)" # this makes rbenv work
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
echo $PATH >> ~/path # for debugging purposes
And this are my results, in ~/path $PATH is correctly defined:
/usr/local/heroku/bin:/Users/pills/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
But when I do !echo $PATH in MacVim I get a twisted value:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/heroku/bin:/Users/pills/.rbenv/shims
I saw from https://superuser.com/a/47166/145603 how $PATH is set, but I don't get why I'm having this behaviour. Can someone help me with this?
You're using zsh, it seems. In recent OS X releases, Apple ships a misconfiguration in the form of /etc/zshenv. You should fix that with
sudo mv /etc/zshenv /etc/zprofile
If you still have issues with misconfigured PATH in Vim, try setting this in ~/.vimrc:
set shell=bash " avoids munging PATH under zsh
let g:is_bash=1 " default shell syntax
If you do this, ensure that your ~/.bashrc is also configured for rbenv the same way your ~/.zprofile is.
For more information about which shell initialization files get sourced when, refer to the Unix shell initialization guide
I wrote about my experience with this same issue in my blog. It's pretty detailed and I believe it's worth reading the entire post to better understand the root cause with a solution on how to properly fix it at the end.
Hint - The problem has to do with the path_helper command that is executed in both /etc/zshenv and /etc/zprofile.