rbenv on OS X Mavericks not work - osx-mavericks

I try to change my ruby version and I get this on my terminal :
Cristians-MacBook-Air% rbenv versions
system
1.9.3-p448
2.0.0-p247
* 2.1.0 (set by /Users/Cristian/.ruby-version)
Cristians-MacBook-Air% ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
rbenv say 2.1.0 is active but then I run ruby -v my active ruby version is other 2.1.0p0
In my .bash_profile :
eval "$(rbenv init -)"
export PATH='brew --prefix rbenv'/shims:'brew --prefix rbenv'/bin:$PATH
I am not using ZSH yet.
Some idea??..
Thanks!!

Related

Mac M1 rbenv and ruby -v do not match

Thoughs as to why on an Apple M1
rbenv lists:
rbenv versions
system
2.7.6
* 3.1.2 (set by /Users/xxxxxx/.rbenv/version)
and ruby -v shows:
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin21
Enter this command in your terminal:
eval "$(rbenv init - zsh)"

Can't change ruby version with rbenv on mac

/usr/local/opt/ruby/bin/ruby
/usr/bin/ruby
/Users/mac_pro/.rbenv/shims/ruby
I'am trying to do rbenv global 2.5.8 and after
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
but my version is always -
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
i need 2.5.8 version
The rbenv global command only specifies, which ruby version should be used globally.
You also need to install this version with rbenv install 2.5.8.

Can't find correct version of ruby with rbenv?

I am working in OSX El Capitan. I have put the following at the end of my ~/.bash_profile, and restarted my terminal:
export RBENV_ROOT=/usr/local/var/rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Then I have run the following, without any errors:
brew install rbenv
brew install ruby-build
rbenv install 2.2.2
But when I try ruby --version I see:
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
What am I doing wrong that means I see Ruby 2.0.0 not Ruby 2.2.2?
These are my paths:
~ $ which ruby
/usr/local/var/rbenv/shims/ruby
~ $ which rbenv
/usr/local/bin/rbenv
I think you have to change ruby version by following:
rbenv shell 2.2.2

Can't run the correct Ruby version with rbenv

After installing rbenv, I wanted to switch to the correct Ruby version to work on a project, but there seems to be an issue recognizing it.
$ cd project/
$ bundle install
$ Your Ruby version is 2.0.0, but your Gemfile specified 2.1.1
$ rbenv local
$ rbenv: no local version configured for this directory
$ rbenv global
$ 2.1.1
$ ruby --version
$ ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
Am I overlooking something?
There was an issue with my $PATH variable.
This worked for me (in .bash_profile):
export PATH="/usr/local/bin:$PATH"
eval "$(rbenv init -)"

rbenv can't change global ruby version

My Mac OS X has a default ruby.
$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
I installed rbenv and ruby version 2.1.2.
$ rbenv versions
system
* 2.1.2 (set by /Users/sdw/.rbenv/version)
and I tried to set the global ruby version to 2.1.2, but nothing happened.
$ rbenv global 2.1.2
$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
So I tried to do the same thing with command sudo, but the result is the same.
$ sudo rbenv global 2.1.2
$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
How can I change my global ruby version to 2.1.2? I never installed rvm or other ruby version managing system.
Did you add the following lines to your ~/.bash_profile?
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
See: https://github.com/sstephenson/rbenv#installation
Type $ rbenv version (without "s")
It is possible that output will show a path to the file that is locking the version
2.0.0p451 (set by /path/to/some/directory/.ruby-version)
It is even possible that the file is a hidden file named .ruby-version in your current dir. If its the case just remove that .ruby-version file
Run the below commands before change ruby version:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
It works for me :)
Uninstall ruby and then install agains:
brew uninstall -f ruby
brew install ruby
Add this two line to you ~/.bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Reopen the console and that's it and run
ruby -v
I realize that I occasionally set local ruby version in home folder, from which I use terminal by default :)
So that's what worked for me:
rm /home/MYUSERNAME/.ruby-version
I had the same issue ("ruby -v" showing the initial version) but reloading (exit/start) my terminal made the trick.
Did you try that first?
If you are installing ruby on rails on ubuntu,and you rbenv doesn't change your ruby version
> rbenv list # This lists all the rbenv versions available
2.6.8
2.7.4
3.0.2
jruby-9.3.1.0
mruby-3.0.0
rbx-5.0
-truffleruby-21.3.0
-truffleruby+graalvm-21.3.0
In my case I need to install ruby 3.0.2
rbenv install 3.0.2
After this also it shows ruby v [2.7.0-]
rbenv global 3.0.2
This will help you change your ruby version.
instead of:
rbenv global 2.7.1
do:
sudo rbenv global 2.7.1

Resources