I'm trying to get a Middleman static site going but for the life of me cannot get Bundler to act right. This is my first time using Ruby on Rails.
Using rbenv I’ve cloned ruby 2.2.0 into a plugin folder but even after running rbenv global 2.2.0 and getting Middleman and Bundler to install, I can't get the "bundle install" or any other "bundle --" commands to work.
I was having issues with permissions and different versions of Ruby even after rbenv so I added "export RBENV_ROOT="$HOME/.rbenv" to my bash profile.
Once that was done the Ruby version issue that was keeping me from installing Bundler and Middleman was gone. But now that they're installed, I can't get these gems to follow any commands.
Try ruby -v to see what local ruby version is set in the app.
rbenv versions to see if you have that version installed. If you don't have the right version installed, run rbenv install ruby-x.x.x or whatever version is required, or if it is already installed do rbenv local x.x.x.
After installing a new ruby you need to run rbenv rehash to rehash your shims.
Then probably gem install bundler, then you can try bundle install.
Related
I'm trying to set the environment for a RoR project on a new work pc.
When I try to install using bundle install, I get the following error:
Your Ruby version is 2.6.8, but your Gemfile specified 2.5.5
I'm using rbenv so I tried all the necessary rbenv tricks. Specifically I tried the following commands, each seperately:
rbenv install 2.5.5
rbenv rehash
rbenv local 2.5.5
rbenv global 2.5.5
I then retry bundle install but I'm still getting the same error.
I even tried
rbenv uninstall 2.6.8
but I'm getting:
rbenv: version `2.6.8' not installed
I of course tried restarting the computer totally after each of the steps but I'm still getting the same error. What am I doing wrong? How can I fix the correct version?
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 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
I get to work with a new project and it's based on ruby 1.8.7, I'm using rvm to manage my ruby versions and I have installed 1.8.7 and 1.9.2.
The thing is when I do:
rvm use 1.8.7
and try to run:
bundle install
I get:
ERROR: Gem bundler is not installed, run `gem install bundler` first.
I've installed bundler 5 times and even after that it says it's not installed. What can cause this? Bundle even shows up at my gem list.
update from comments:
The ouput of the which ruby && which gem is:
/home/username/.rvm/rubies/ruby-1.8.7-p371/bin/ruby
/home/username/.rvm/bin/gem
Output of "env | grep -iE 'ruby|rvm|gem' | sort":
GEM_HOME=/home/username/.rvm/gems/ruby-1.8.7-p371#global
GEM_PATH=/home/username/.rvm/gems/ruby-1.8.7-p371#global
IRBRC=/home/username/.rvm/rubies/ruby-1.8.7-p371/.irbrc
MY_RUBY_HOME=/home/username/.rvm/rubies/ruby-1.8.7-p371
PATH=/home/username/.rvm/gems/ruby-1.8.7-p371#global/bin:/home/username/.rvm/rubies/ruby-1.8.7-p371/bin:/home/username/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
RUBY_VERSION=ruby-1.8.7-p371
rvm_bin_path=/home/username/.rvm/bin
rvm_delete_flag=0
rvm_path=/home/username/.rvm
rvm_prefix=/home/username
rvm_ruby_string=ruby-1.8.7-p371
rvm_sticky_flag=1
rvm_use_flag=1
rvm_version=1.17.7 (stable)
Unistalled and installed 1.8.7 via RVM
ran:
rvm install 1.8.7 --verify-downloads 1
and it worked.
It looks like you're probably running the wrong version of gem. In my RVM setup, using the shell command overrides recommended with RVM (source "$HOME/.rvm/scripts/rvm" in your .bashrc or .zshrc or another suitable startup file), gem is normally a shell function. It does some RVM magic under the covers and then runs the real gem command. In my case, both ruby and gem run out of the same version directory:
/home/jim/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/home/jim/.rvm/rubies/ruby-1.9.3-p327/bin/gem
Make sure you're sourcing the RVM startup script.
Your PATH looks ok. Make sure you have a /home/username/.rvm/rubies/ruby-1.8.7-p371/bin/gem command. If not, you may have to reinstall ruby-1.8.7.
Running rvm current will show which Ruby version and gemset are being used. Make sure there's a gem in the path that matches the Ruby version.
rvm install ruby-1.9.2-p320
use this and remember close all terminal
and in edit-> profile preferences--> title and command -->> check (Run command as login shell)