rbenv working but ruby version not changing - ruby

❯ rbenv version
system (set by /Users/eric.nguyen/.rbenv/version)
❯ rbenv local 2.4.2
❯ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
❯ rbenv global 2.4.2
❯ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
❯ rbenv version
2.4.2 (set by /Users/eric.nguyen/.ruby-version)
❯ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
❯ gem -v
2.0.14.1
Ruby version is is still 2.0.0p648
I'm on macOS Sierra 10.12.6.
I've done everything mentioned here
I've done:
rbenv rehash
put eval "$(rbenv init -)" in my .zshrc and source ~/.zshrc
put $HOME/.rbenv/shims into $PATH (/Users/eric.nguyen/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/eric.nguyen/Library/Android/sdk/tools:/Users/eric.nguyen/Library/Android/sdk/platform-tools:/Users/eric.nguyen/.rbenv/shims)
But it still doesn't change ruby version.

Restarting my computer resolve the issue.
❯ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
❯ gem -v
2.6.13

You always need to run rbenv rehash after you install a new ruby version using rbenv and also when you install a gem that has a command line options

Related

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

bundler, command not found

I wanna use the bundler, but after I installed rbenv, ruby and bundler, it still tells me command not found.
$ rbenv version
2.2.3 (set by /Users/khlee/.rbenv/version)
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
$ export GEM_HOME=$HOME/Software/ruby
$ gem install bundler
Successfully installed bundler-1.12.5
Parsing documentation for bundler-1.12.5
1 gem installed
$ rbenv rehash
$ bundle install
-bash: bundle: command not found
Execute below command and check list of gem in gemset:
rbenv gemset list
May be budler gem is not installed in current gemset.

rbenv cannot run gem command

Im using rbenv as my ruby versioning manager, I run these commands:
$ rbenv install 2.2.2
$ rbenv global 2.2.2
$ rbenv rehash
$ ruby -v
$ > ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin11.0]
but when I run this command:
$ gem -v
it returns an error:
/usr/local/Cellar/rbenv/0.4.0/libexec/rbenv-exec:
/Users/username/.rbenv/versions/2.2.2/bin/gem: /Users/mac/.rbenv/versions/2.2.2/bin/ruby: bad interpreter: No such file or directory
/usr/local/Cellar/rbenv/0.4.0/libexec/rbenv-exec: line 43: /Users/username/.rbenv/versions/2.2.2/bin/gem: Undefined error: 0
What do I miss? thanks in advance
I could not figure the problem out. I was using homebrew and uninstalled it. Reinstalled directly and it's working now.

setting local ruby version with rbenv not working?

I cant really understand the problem here:
➜ myflixx git:(master) ✗ rbenv local
2.1.1
➜ myflixx git:(master) ✗ rails -v
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.1
➜ myflixx git:(master) ✗ rake -T
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.1
Why is it complaining about Ruby version 2.0.0 when I've already set the local version (with rbenv) to 2.1.1?
Is it something that I'm missing? thanks for your time!
This makes sure your paths are correctly set.
In Bashrc or equivalent:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Install everything and locally define what ruby version to use for the app.
brew install rbenv ruby-build
rbenv install <ruby-version>
rbenv rehash
rbenv local <ruby-version>
Restart terminal or source the bashrc.

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 -)"

Resources