I'm trying to install the Gemfile contents using Bundle install but getting the error
rbenv: version `2.0.0' is not installed
The version of ruby installed in my system is:
ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]
and rbenv
2.1.2 (set by /home/jay/.rbenv/version)
2.1.3
The Gemfile requires ruby "2.0.0". Can any one tell how to install the required version without affecting the existing ones.
You can find a lot of information here: rbenv on github
To list all available installation candidates:
rbenv install -l
To install a ruby version you need (for example):
rbenv install 2.0.0-p643
So that you will only use this ruby version in this specific folder and not affect anything else you can do:
rbenv local 2.0.0-p643
This will generate a .ruby-version file in that directory which will force rbenv to use this ruby version here.
Just run:
rbenv install 2.0.0-p643
Which is the lastest 2.0.0 version.
If that version is not available on your system, run ruby-build --definitions to pick the lastest known 2.0.0 version on your system.
For me, I just ran
gem install bundler
and then run
bundle install
worked like a charm
You must change the ruby's version in .ruby-version file and in Gemfile
If you are getting a build failed error when trying to run rbenv install 2.0.0-p643 and after waiting for a few minutes; you might also see the last 10 lines of a log file as an output.
This can give you the hint of what would have happened for the build failure. It might miss some required library/dependency needed to be installed.
For ex. I got the following error for build failure-
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libreadline-dev` to fetch missing dependencies.
Related
I have already gone through this post
I am facing this issue on my new react-native project version 0.71.1 while enabling the new architecture for iOS
I have done all the below steps
$ brew update
$ brew install ruby-build
$ brew install rbenv
$ rbenv install 2.7.6
$ rbenv global 2.7.6
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
When I run ruby --version I get ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin22] which is the correct ruby version required to enable new architecture on iOS
but when I run bundle install && RCT_NEW_ARCH_ENABLED=1 bundle exec pod install I still get error saying
Your Ruby version is 2.6.10, but your Gemfile specified 2.7.6
What else am I missing?
I have also raised the issue in react native's GitHub repo. This might help in understanding in what I have already tried
I was able to resolve my issue by running bundle install --redownload. It Forces a redownload of all gems on the gemfile, assigning them to the new bundler
Your error message means that the Ruby version specified in your Gemfile is different from the version of Ruby installed in your system.
Try the following steps to solve this issue:
Run command 'which ruby' to confirm the path of the Ruby executable that your system is using.
Check the Ruby version specified in your Gemfile and ensure it matches the
version returned by the 'ruby --version' command.
If the Ruby versions do not match, try to update the version specified in your Gemfile to the version of Ruby installed on your system.
If you have multiple versions of Ruby installed, use the 'rbenv local' command to set the correct version for your project.
If the issue is still there, try reinstalling the required version of Ruby and the related dependencies.
Just change your ruby version in GemFile to 2.6.10 and then try it.
You'll find your GemFile in your project's root directory
The Rbenv documentation can define a version file named .ruby-version inside your project folder. Perhaps you have this file with a specific version number inside.
This setting overrides your default ruby version.
Link to Rbenv-Repo: https://github.com/rbenv/rbenv
Update: After lots of suggestion, we came to the conclusion. The command bundle install --redownload updates the local bundler and everything is fine. :-)
When I try to start my Rails server, I get the following error:
$ bundle exec rails s
Your Ruby version is 2.3.7, but your Gemfile specified ~> 2.3.8
I don't understand why that happens though, since I set Ruby to 2.3.8 both using Homebrew and using rbenv. 2.3.7 is the version of the system's ruby. I am using Mac OS 10.14.4.
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
$ rbenv version
2.3.8 (set by /Users/ceasar/foo/.ruby-version)
$ which -a ruby
/Users/ceasar/.rbenv/shims/ruby
/usr/local/opt/ruby#2.3/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
$ which -a bundle
/Users/ceasar/.rbenv/shims/bundle
/usr/local/bin/bundle
$ /usr/bin/xcodebuild -version
Xcode 10.2
Build version 10E125
$ brew list ruby#2.3
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/erb
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/gem
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/irb
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/rake
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/rdoc
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/ri
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/ruby
/usr/local/Cellar/ruby#2.3/2.3.8_1/include/ruby-2.3.0/ (25 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/libruby.2.3.0.dylib
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/pkgconfig/ruby-2.3.pc
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/ruby/ (1211 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/ (3 other files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/emacs/ (7 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/man/ (4 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/ri/ (13487 files
$ bundle env | head -n 40
## Environment
```
Bundler 2.0.1
Platforms ruby, x86_64-darwin-18
Ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
Full Path /Users/ceasar/.rbenv/versions/2.3.8/bin/ruby
Config Dir /Users/ceasar/.rbenv/versions/2.3.8/etc
RubyGems 2.5.2.3
Gem Home /Users/ceasar/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0
Gem Path /Users/ceasar/.gem/ruby/2.3.0:/Users/ceasar/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0
User Path /Users/ceasar/.gem/ruby/2.3.0
Bin Dir /Users/ceasar/.rbenv/versions/2.3.8/bin
Tools
Git 2.19.2
RVM not installed
rbenv rbenv 1.1.2
chruby not installed
```
## Bundler Build Metadata
```
Built At 2019-01-04
Git SHA d7ad2192f
Released Version true
```
## Bundler settings
```
build.libv8
Set for the current user (/Users/ceasar/.bundle/config): "--with-system-v8"
build.mysql2
Set for the current user (/Users/ceasar/.bundle/config): "--with-mysql-config=/usr/local/Cellar/mysql#5.7/5.7.24/bin/mysql_config"
path
Set for your local app (/Users/ceasar/Desktop/beacon/.bundle/config): "vendor/bundle"
disable_shared_gems
Set for your local app (/Users/ceasar/Desktop/beacon/.bundle/config): true
```
I don't see anything here which would make me think it shouuld be using 2.3.7.
I'm not sure what else to try.
How does Bundler decide which version of Ruby to use, and how can I configure it to use either rbenv or my homebrew Ruby installation?
How about to try to use 'rvm'?
rvm install 2.4.2
This command will install another version of ruby, 2.4.2
And you can simply check the versions which all you have as
rvm list.
After this, run the version which you wish as the below,
rvm <version> or rvm use <version>
Hope this will help you!
Summary: The wrong version of bundler causes the problem. Use a ruby version manager to install the needed ruby version. Then install the correct version of the bundler gem for your project.
Details: In my case I'm running a rails example on github that required an older version of ruby and bundler and got the error described.
To manage my different ruby versions, I'm using ruby-install and chruby both installed with homebrew.
I followed these steps to resolve the problem on macOS Catalina v10.15.7:
Resolution steps
% ruby-install 2.4.1
# open a new shell so chruby will find 2.4.1
% chruby 2.4.1
% which ruby
/Users/richardlogwood/.rubies/ruby-2.4.1/bin/ruby
% gem install bundler:1.16.1
% which bundle
/Users/richardlogwood/.gem/ruby/2.4.1/bin/bundle
% cd (to the rails project directory)
# Note: it's a rails project so there was a binstub
# for bundler, hence `bin/bundler` in the project directory*
% bin/bundler install
% rake db:{create,migrate}
% bin/rails s
Before running the above steps, the error messages told me which version of ruby and bundler I needed to install. The system bundler was the wrong version (I'm on a mac) and the initial error message using that version gave me the error below. Only after installing the needed bundler gem (see above) was the correct ruby version resolved (see above).
Errors before resolution
% bundle install
Your Ruby version is 2.6.3, but your Gemfile specified 2.4.1
% which ruby
/Users/richardlogwood/.rubies/ruby-2.4.1/bin/ruby
% which bundle
/usr/bin/bundle
Note, the required bundler version was indicated by this error message:
Could not find 'bundler' (1.16.1) required by your ... /Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.16.1`
I don't suggest using RVM instead of RBEnv. RBEnv is one of the most up-to-date solutions around, and most people stick with it.
Can you please try running gem update --system to update your bundler first.
Install Rbenv and run the following commands in your project directory to install 2.3.8:
rbenv install 2.3.8
rbenv local 2.3.8
bundle install --path=vendor/cache
I had rbenv installed and also installed Ruby manually at some point because of certain issues which I thought I cleaned up. But it seems I had /usr/local/bin/{bundle,bundler} still present which was evident when I did: which bundle that showed it's location not under shims (belonging to rbenv) so I simply had to remove these e.g. rm -rf /usr/local/bin/{bundle,bundler} and all was working again.
I am getting this error while running server, how do I fix this?
You better install Ruby 2.2.5 for compatibility. The Ruby version in your local machine is different from the one declared in Gemfile.
If you're using rvm:
rvm install 2.2.5
rvm use 2.2.5
else if you're using rbenv:
rbenv install 2.2.5
rbenv local 2.2.5
else if you can not change ruby version by rbenv,
read here
If you have already installed 2.2.5 and set as current ruby version, but still showing the same error even if the Ruby version 2.3.0 is not even installed, then just install the bundler.
gem install bundler
and then:
bundle install
If you are using rbenv then make sure that you run the "rbenv rehash" command after you set local or global ruby version. It solved the issue for me.
rbenv rehash
Your Gemfile has a line reading
ruby '2.2.5'
Change it to
ruby '2.3.0'
Then run
bundle install
Had same issue. I'm using rbenv and which ruby would show the rbenv version:
/Users/Mahmoud/.rbenv/shims/ruby
which bundle though would show:
/usr/local/bin/bundle
After looking in every possible place, turns out my problem was that I needed to update path in ~/.zshrc in addition to ~/.bash_profile (where I originally had the changes)
if you're running zsh add those two lines in ~/.zshrc (or the equivalent file) in addition to ~/.bash_profile
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
After saving, quit terminal and relaunch before retrying. Hopefully this would help.
Two steps worked for me:
gem install bundler
bundle install --redownload # Forces a redownload of all gems on the gemfile, assigning them to the new bundler
A problem I had on my Mac using rbenv was that when I first set it up, it loaded a bunch of ruby executables in /usr/local/bin - these executables loaded the system ruby, rather than the current version.
If you run
which bundle
And it shows /usr/local/bin/bundle you may have this issue.
Search through /usr/local/bin and delete any files that start with #!/user/bin ruby
Then run
rbenv rehash
I had this problem but I solved it by installing the version of the ruby that is specified in my gem file using the RVM
rvm install (ruby version)
After the installation, I use the following command to use the the version that you installed.
rvm --default use (ruby version)
You have to install bundler by using the following command in order to use the latest version
gem install bundler
After the above steps, you can now run following command to install the gems specified on the gemfile
bundle install
it can also be in your capistrano config (Capfile):
set :rbenv_ruby, "2.7.1"
Add the following to your Gemfile
ruby '2.3.0'
I am on Mac OS Sierra. I had to update /etc/paths and add /Users/my.username/.rbenv/shims to the top of the list.
If you have some dependency on the version of the Ruby , then install the appropriate version. otherwise change the version in the gemfile in the current directory.
rbenv install <required version>
rbenv local <required version>
Even after installation it was showing the same error for me, so I just restart the mac, then do the bundle install, it works :)
it should show something like this
<user>#<repo>% rbenv versions
system
* 2.3.7 (set by <app>)
For $ Your Ruby version is 2.3.0, but your Gemfile specified 2.4.1.
Changed 2.4.1 in Gemfile to 2.3.0
Refer the below link to install the required version.
https://nrogap.medium.com/install-rvm-in-macos-step-by-step-d3b3c236953b
$ \curl -sSL https://get.rvm.io | bash
rvm install 2.7.1
run:
rbenv global
if old version
then run:
1)
brew update
brew install ruby-build
2)
brew install rbenv
3)
rbenv install 2.7.5
4)
rbenv init
5)
rbenv shell 2.7.5
6)
eval "$(rbenv init - zsh)"
list commands for rbenv - run simple:
rbenv
I install rvm and rbenv it not help me so i go the project and open Gemfile change the ruby version with recommend version and than follow the command cd ios -> bundle install
Your project is ready to Run now.
Open Gemfile and find
ruby '2.2.5'
Change it to
ruby '2.3.0'
then install bundle
I am trying to install Rails on my OSX El Capitan v10.11.3, as per these official instructions. However, after installing ruby, I am getting the following issues with the rails installation:
Unknown-88-63-df-a3-2e-e9:~ username$ gem install rails -v 4.2.4
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Even though I am using rbenv ? What can I do to workaround / fix this?
EDIT: if I use sudo then I get:
railties's executable "rails" conflicts with /usr/bin/rails
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/rails
Any ideas would be much appreciated. Many Thanks. Also, is there somewhere I can feed the resolution of this back into the rails docs community?
You are trying to install gems into the system ruby (i.e. the ruby that comes from Apple with OSX) don't do that.
Try:
rbenv versions
to list the versions of ruby you have.
Then pick one that is NOT system.
[16:55][d#phobos:~]$ rbenv versions
* system (set by /usr/local/var/rbenv/version)
1.8.7-p357
1.9.2-p290
1.9.3-p392
1.9.3-p448
2.1.5
[16:55][d#phobos:~]$ rbenv local 2.1.5
[16:55][d#phobos:~]$ rbenv version
2.1.5 (set by /Users/d/.ruby-version)
[16:56][d#phobos:~]$
If you have nothing but system installed, install the rbenv build and install the ruby you want...
Read this carefully:
https://github.com/rbenv/rbenv
and this
https://github.com/rbenv/ruby-build#readme
Run which ruby check if it was pointing to /Library/...
Run rbenv global x.y.z to set current ruby version
You may need to relaunch terminal
I recently updated my computer to Mac OS X El Capitan and had to reinstall homebrew and rbenv.
When I go to bundle install in one of my rails app and run bundle install I get: "Your Ruby version is 2.0.0, but your Gemfile specified 2.2.0".
However, when I do ruby-v I get: ruby 2.2.0p0 . Why am I seeing two different versions and how can I change it?
rbenv -h will tell you what to do.
"rbenv versions" List all Ruby versions available to rbenv
"rbenv global" Set or show the global Ruby version
"rbenv local" Set or show the local application-specific Ruby version
to set, just do "rbenv local 2.2.0" or "rbenv global 2.2.0"
Also, there is the .ruby-version file that can also set ruby version.
Look at the instructions from rbenv main github page for more info. They do a pretty good job describing how to set the active ruby version.
https://github.com/sstephenson/rbenv
It seems that you must update your executables (bundle install), try this rbenv rehash. Take from here
rbenv rehash Installs shims for all Ruby executables known to rbenv (i.e., ~/.rbenv/versions//bin/). Run this command after you install a new version of Ruby, or install a gem that provides commands.
This is a duplicate of another question and you can find the answer here https://stackoverflow.com/a/53849574/3182171
For convenience I report also here.
Try with this.
In your rails project folder check the presence of .ruby-version file and put inside the same ruby version specified into Gemfile.
(if this file is not present, create it.)
~/your-rails-project/.ruby-version file:
2.2.0
~/your-rails-project/Gemfile file:
source 'https://rubygems.org'
ruby '2.2.0'
...
Then install that version with rbenv:
$ rbenv install 2.2.0
$ rbenv rehash
$ rbenv local 2.2.0
$ rbenv global 2.2.0
Now check that you are using the right version with:
$ ruby -v
You can now execute
$ bundle install