setting local ruby version with rbenv not working? - ruby

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.

Related

rbenv working but ruby version not changing

❯ 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

Ruby gem show "Invalid argument" error for almost every command

I am working through NativeScript's set-up on OS X El Capitan and I am stuck at the point where I am supposed to install xcodeproj and cocoapods. Almost everything that I try to do with gem shows the same error:
$ sudo gem install xcodeproj
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument
The following commands show the same error, wether I run it with sudo or not:
$ gem update --system
$ gem update
$ gem install whatever
$ gem install cocoapods
I have the following versions:
$ ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
$ gem --version
2.6.7
I've tried some of the help that I've found online, including reinstalling gem and ruby, restarting but nothing has helped.
I guess that I have a configuration problem with Ruby.
Any suggestions on how to troubleshoot this?
I just had a similar issue after updating everything via Homebrew.
I solved the issue by uninstalling Ruby and installing it via rbenv, then reinstalling cocoa pods.
Steps:
Uninstall ruby
brew uninstall ruby
Install rbenv and ruby-build
brew install rbenv ruby-build
You need to add Ruby to your path.
A. If Terminal is your shell.
Add eval "$(rbenv init -)" to ~/.bash_profile
B. Or if you use another shell
You can find the instruction by entering the command rbenv init NAME_OF_YOUR_SHELL.
Install Ruby
rbenv install 2.3.1
Set the Ruby version
rbenv global 2.3.1
rbenv local 2.3.1
Reinstall Cocoapods
gem install cocoapods

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

Your Ruby version is 2.1.0, but your Gemfile specified 2.0.0

In my Gemfile I specified ruby version 2.0.0:
ruby '2.0.0'
But my console tells me I have 2.1.0dev:
$ ruby -v
ruby 2.1.0dev (2013-09-16 trunk 42951) [x86_64-darwin12.4.0]
I am using rbenv and it tells my I don't have 2.1.0 installed,
$ rbenv versions
system
* 2.0.0-dev
Bundle update or bundle install says:
"Your Ruby version is 2.1.0, but your Gemfile specified 2.0.0"
but using 'rbenv local 2.0.0-dev' leaves me with ruby 2.1.0dev again. Furthermore:
$ rbenv global
2.0.0-dev
$ cat ~/.bash_profile:
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
As far as I know, 2.1.0dev doesn't even exist yet.
How can i get ruby 2.0.0 selected?
You may need to update your version of ruby-build to make sure you have the update where ruby-2.0.0-dev switched to follow the ruby_2_0_0 branch.
Try running ruby-build --version and make sure it's one of these (or later):
v20130907
v20130901
v20130806
v20130628
v20130518
v20130514
v20130501
v20130408
v20130227
v20130226
v20130225
If not, run brew upgrade ruby-build.
Go to your Gemfile and change the description there
I just got the same problem and couldn't find a "working" solution. So I made my own.
source 'https://rubygems.org'
ruby '2.0.0' #Change this one to this '2.1.0'
gem 'rails', '4.0.3'

Resources