bundle uses wrong ruby version - ruby-on-rails

I'm trying to run
env RAILS_ENV=test bundle exec rake db:migrate
and get the following error
Your Ruby version is 2.1.7, but your Gemfile specified 2.2.3
ruby -v
gives me
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
I'm using rbenv, if that matters. rbenv versions gives the following:
system
* 2.2.3 (set by /Users/thatsme/Projects/demoproject/.ruby-version)
So I have no ruby 2.1.7 installed. Spring is not running and I've run rbenv rehash. Then bundler gem is installed.
I'm going nuts on this. Can somebody please tell me why the wrong ruby version is being used? Thanks!

Running the command below helped me somehow:
rbenv exec gem install bundler

Assumption: You are using RVM.
This means there's a ruby version installed outside of RVM.
Clear your rvm rubies by running
rvm uninstall <ruby version>
once you have uninstalled all rvm rubies do ruby -v, if this returns an output specifying a ruby version then thats the root of the problem. Uninstall it with
sudo apt-get remove ruby
Now install your rvm rubies with rvm install <ruby version> and set it as default rvm use <ruby version>
Now install bundler
gem install bundler
And do bundle install

TLDR;
Check really carefully the content of your .bash_profile or .bashrc file.
None of the answers actually solve my problem. So here's my solution.
This is the error that I got:
$ bundle install
Your Ruby version is 3.0.1, but your Gemfile specified 2.7.1
I checked my rbenv setup:
$ rbenv versions
system
2.4.1
2.5.0
2.7.0
* 2.7.1 (set by /Users/setoelka/awesome-project/.ruby-version)
3.0.1
I uninstall the wrong version to probably reveal a new error. I can just install it again later, I was thinking.
$ rbenv uninstall 3.0.1
It does reveal a new error:
$ bundle install
-bash: /Users/setoelka/.gem/ruby/3.0.0/bin/bundle: /Users/setoelka/.rbenv/versions/3.0.1/bin/ruby: bad interpreter: No such file or directory
Ok, that's strange. I can just remove the .gem directory there.
$ rm -rf ~/.gem/
Now another new error:
$ bundle install
-bash: /Users/setoelka/.gem/ruby/3.0.0/bin/bundle: No such file or directory
It seems like my PATH variable is messed up. So I do:
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 3.2.27
- RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-darwin20]
- INSTALLATION DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/setoelka/.local/share/gem/ruby/2.7.0
- RUBY EXECUTABLE: /Users/setoelka/.rbenv/versions/2.7.1/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/bin
- SPEC CACHE DIRECTORY: /Users/setoelka/.local/share/gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-20
- GEM PATHS:
- /Users/setoelka/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
- /Users/setoelka/.local/share/gem/ruby/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/setoelka/.rbenv/versions/2.7.1/bin
- /usr/local/Cellar/rbenv/1.1.2/libexec
- /Users/setoelka/opt/anaconda3/bin
- /Users/setoelka/opt/anaconda3/condabin
- /Users/setoelka/.cargo/bin
- /Users/setoelka/.gem/ruby/3.0.0/bin
- /Users/setoelka/.nvm/versions/node/v16.5.0/bin
- /Users/setoelka/.rbenv/shims
- /Users/setoelka/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/Apple/usr/bin
So, it's clear I missed something when checking out my .bash_profile file. That's the problem there:
- /Users/setoelka/.gem/ruby/3.0.0/bin
That line was somehow buried under a plethora of settings inside my .bash_profile.

I had the same problem
I needed to run
bundle
to reinstall all my gems. then
bundle exec rails c

Related

I can't execute $ bundle exec rake secret, because I don't know how to get rid of /usr/local/bin/bundle. And should I reinstall the Xcode?

My ruby ​​version is 2.3.0, my mysql version is 8.0.23, my mysql2 version is 0.5.3, my rails version is 5.0.7.2, and my Xcode version is 12.5.
I use macOS Big Sur(version 11.4) and the text editor "Atom".
I'm planning to release my Rails application with the URL of HEROKU(example. https://[My APP Name].herokuapp.com).
I ran the following command.
$ bundle exec rake secret
bash: /usr/local/bin/bundle: /System/Library/Frameworks/Ruby.framework/Versions/2.3/
usr/bin/ruby: bad interpreter: No such file or directory
I installed the ruby version "2.3.0" as below ,because bundle seems to call "2.3".
$ rbenv install 2.3.0
Downloading openssl-1.0.2u.tar.gz...
-> https://****
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/****/.rbenv/versions/2.3.0
Downloading ruby-2.3.0.tar.bz2...
-> https://****
Installing ruby-2.3.0...
WARNING: ruby-2.3.0 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
Installed ruby-2.3.0 to /Users/****/.rbenv/versions/2.3.0
I verified that the ruby version "2.3.0" is installed and the current ruby version is "2.3.0".
$ rbenv local 2.3.0
$ rbenv rehash
$ rbenv versions
system
* 2.3.0
$ rbenv global 2.3.0
$ rbenv rehash
$ rbenv versions
system
* 2.3.0
But the ruby current version is "2.6.3" when used the below command.
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [universal.x86_64-darwin20]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.6.0
- USER INSTALLATION DIRECTORY: /Users/****/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/****/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-20
- GEM PATHS:
- /Library/Ruby/Gems/2.6.0
- /Users/****/.gem/ruby/2.6.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/****/.rbenv/shims
I ran the following command.
$ bundle exec rake secret
bash: /usr/local/bin/bundle: /System/Library/Frameworks/Ruby.framework/Versions/2.3/
usr/bin/ruby: bad interpreter: No such file or directory
Would you like to tell me how to get rid of /usr/local/bin/bundle?
Because my bundle exec should work if I can get rid of /usr/local/bin/bundle.
And should I reinstall the Xcode ,that is command line tools? The 1st answer of the below URL recommends to try running xcode-select --install to (re)install the Xcode command line tools.
Cannot install Jekyll after updating to Catalina - An error occurred while installing ffi (1.9.18)
Looks like your /usr/local/bin/bundle precedes the bundle executable from rbenv in your PATH.
Could it be that you installed ruby with some other tools than rbenv (additionally to rbenv installation)?
In my macOS setup i do not have a file /usr/local/bin/bundle
$ ls /usr/local/bin/bundle
ls: /usr/local/bin/bundle: No such file or directory
and the bundle executable is loaded from my rbenv installation:
$ which bundle
/Users/***/.rbenv/shims/bundle
I think, if you can get rid of /usr/local/bin/bundle your bundle exec could work.
(you could try this with renaming the /usr/local/bin/bundle temporary, if you do not know how this bundle file was installed on your system)

Cannot run rails server locally wrong ruby version

I recently install ruby 2.7.1 using rbenv. I have made sure that .ruby-version and Gemfile file both have 2.7.1 as ruby version.
Now i cannot run rails s locally, doing so returns the following output in console:
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running gem install bundler:2.1.4.
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.1
I have been searching and trying different things for hours but cannot figure out the problem and would be thankful for help.
Following output may help figure out the problem:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for rbenv' in PATH: /usr/bin/rbenv Checking for rbenv shims in PATH: OK Checking rbenv install' support: /home/imran/.rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20200819)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
bundle env
Environment
Bundler 2.1.4
Platforms ruby, x86_64-linux
Ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9cec0d0ffcba012279cd652d28ad5bf3) [x86_64-linux]
Full Path /home/imran/.rbenv/versions/2.7.1/bin/ruby
Config Dir /home/imran/.rbenv/versions/2.7.1/etc
RubyGems 3.1.2
Gem Home /home/imran/.gem/ruby/2.7.0
Gem Path /home/imran/.gem/ruby/2.7.0:/home/imran/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
User Home /home/imran
User Path /home/imran/.gem/ruby/2.7.0
Bin Dir /home/imran/.gem/ruby/2.7.0/bin
Tools
Git 2.25.1
RVM not installed
rbenv rbenv 1.1.1
chruby not installed
Bundler Build Metadata
Built At 2020-01-05
Git SHA 32a4159325
Released Version true
gem env
RubyGems Environment:
RUBYGEMS VERSION: 3.1.2
RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-linux]
INSTALLATION DIRECTORY: /home/imran/.gem/ruby/2.7.0
USER INSTALLATION DIRECTORY: /home/imran/.gem/ruby/2.7.0
RUBY EXECUTABLE: /home/imran/.rbenv/versions/2.7.1/bin/ruby
GIT EXECUTABLE: /usr/bin/git
EXECUTABLE DIRECTORY: /home/imran/.gem/ruby/2.7.0/bin
SPEC CACHE DIRECTORY: /home/imran/.gem/specs
SYSTEM CONFIGURATION DIRECTORY: /home/imran/.rbenv/versions/2.7.1/etc
RUBYGEMS PLATFORMS:
ruby
x86_64-linux
GEM PATHS:
/home/imran/.gem/ruby/2.7.0
/home/imran/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:backtrace => false
:bulk_threshold => 1000
REMOTE SOURCES:
https://rubygems.org/
SHELL PATH:
/home/imran/.rbenv/versions/2.7.1/bin
/usr/lib/rbenv/libexec
/home/imran/.rbenv/plugins/ruby-build/bin
/home/imran/.rbenv/bin
/home/imran/.rbenv/shims
/home/imran/.rbenv/plugins/ruby-build/bin
/home/imran/.rbenv/bin
/home/imran/.local/bin
/home/imran/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
/usr/local/texlive/2018/bin/x86_64-linux
my ~/.profile contains following statements:
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$HOME/.rbenv/bin:$PATH"
Did You try to just update bundler as output said:
gem install bundler:2.1.4
or
gem install bundler
bundle update
rbenv creates shims based on version of ruby you install. Each time you change ruby version via rbenv global X.Y.Z or rbenv local A.B.C, rbenv will intercept the ruby command and redirect it to the appropriate ruby installation version which will look at its associated gems.
Therefore, if you set your local version to 2.7.1, and the error message you receive is telling you that your bundle version is different, you probably have not installed the bundler gem in the 2.7.1 Ruby shim.
To fix this, you can change your ruby version and install the gem:
rbenv local 2.7.1
ruby -v
# 2.7.1
gem install bundler
Now, ensure that in your Gemfile.lock you are using the same bundler version of the bundler gem you installed. If it is not, it means that the Gemfile.lock file was generated and bundled with a previous version. You can force update the Gemfile.lock by deleting and rebuilding, however, if you are collaborating with other developers you may want to speak with them before you do (and commit to source control)
#Gemfile.lock
BUNDLED_WITH 2.1.5

RubyGems environment variables messed up :(

Please see below the print out from gem env. It appears as the INSTALLATION DIRECTORY, USER INSTALLATION DIRECTORY and GEM PATHS are screwed up. I attempted to install ruby version 2.3.0 for another project and switch over to that. I uninstalled ruby version 2.3.0 and switch back to ruby version 2.3.1. I noticed these RubyGems environment variables got screwed up some how :( Everywhere you see '2.3.0', I think it's wrong.
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/matthewsmith/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /Users/matthewsmith/.rbenv/versions/2.3.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/bin
- SPEC CACHE DIRECTORY: /Users/matthewsmith/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/matthewsmith/.rbenv/versions/2.3.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
- /Users/matthewsmith/.gem/ruby/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/matthewsmith/.rbenv/versions/2.3.1/bin
- /Users/matthewsmith/.rbenv/libexec
- /Users/matthewsmith/.rbenv/plugins/ruby-build/bin
- /Users/matthewsmith/.nvm/versions/node/v4.5.0/bin
- /Users/matthewsmith/.rbenv/shims
- /Users/matthewsmith/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
if there are multiple versions installed, project dependent version must be set as default.
To handle multiple projects with different dependencies, gemset can be used. RVM support gemset. Alternatives are available for rbenv also.
Nothing is wrong. I can see that you are using rbenv, and that your global ruby version is 2.3.1
If you run in your terminal:
gem env home
It will return something like:
/Users/matthewsmith/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
Apparently this line of code above tells that you have global rbenv version 2.3.1, and within li/ruby/gems folder you also have installed ruby version 2.3.0
In this folder .rbenv/versions/ will be all ruby versions you will about to install, or they are already installed.
When I install different ruby version let's say 2.3.0 I would do like this:
rbenv install 2.3.0 # install ruby version 2.3.0 using rbenv
rbenv local 2.3.0 # set ruby 2.3.0 to local project. It writes that version to a .ruby-version in your current directory
ruby -v # check your version to confirm that is 2.3.0 for a local project
gem install bundler
bundle install
Other options for installing ruby version are: SHELL and GLOBAL
rbenv shell 2.3.0 # Will temporarily change your Ruby version on your current shell. This sets the RBENV_VERSION environment variable in your terminal session.
rbenv global 2.3.1 # This will also change your Ruby version, but only the one you are using whenever no other version is specified, e.g. via a .ruby-version file or RBENV_VERSION variable.
NOTE! You don't need sudo to install gems. Typically, the Ruby versions will be installed and writeable by your user. No extra privileges are required to install gems.
reference
I hope it helps

OSX bundler install command not found

I'm getting this error:
Could not find i18n-0.6.1 in any of the sources
Run bundle install to install missing gems.
When i try to run bundle install, i get this:
-bash: bundle: command not found
I have googled and tried to solve this for a while now with no hope. Please help.
Don't mess with your PATH.
Just use rbenv and ruby-build to manage and install your ruby version(s).
And then install the bundler gem and rehash.
Install rbenv (if you haven't already) as follows:
$ brew update
$ brew install rbenv ruby-build
Initialize rbenv as follows:
$ rbenv init
Install ruby-build to compile and install different versions of Ruby on UNIX-like systems:
brew install ruby-build
Install a specific ruby version, e.g., 1.9.3-p551:
$ RUBY_VERSION=1.9.3-p551
$ ruby-build $RUBY_VERSION $HOME/.rbenv/versions/$RUBY_VERSION
Verify it worked:
$ ruby --version
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin14.0.0]
Set that version to be the global/default Ruby version:
$ rbenv global 1.9.3-p551
Install bundler:
$ gem install bundler
Fetching: bundler-1.7.11.gem (100%)
Successfully installed bundler-1.7.11
1 gem installed
Update rbenv:
$ rbenv rehash
Now, bundler will be available in the version of Ruby (1.9.3-p551) that you just installed.
Verify RubyGems Environment:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23.2
- RUBY VERSION: 1.9.3 (2014-11-13 patchlevel 551) [x86_64-darwin14.0.0]
- INSTALLATION DIRECTORY: /Users/lex/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/lex/.rbenv/versions/1.9.3-p551/bin/ruby
- EXECUTABLE DIRECTORY: /Users/lex/.rbenv/versions/1.9.3-p551/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/lex/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1
- /Users/lex/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- "install" => "--no-ri --no-rdoc"
- "update" => "--no-ri --no-rdoc"
- :sources => ["http://rubygems.org", "http://gems.github.com", "http://gems.rubyforge.org", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://rubygems.org
- http://gems.github.com
- http://gems.rubyforge.org
- http://gemcutter.org
try to run
gem env
and then you will get something like this:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-darwin12.5.0]
- INSTALLATION DIRECTORY: /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/Cellar/ruby193/1.9.3-p448/bin/ruby
**- EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby193/1.9.3-p448/bin**
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1
- /Users/madhava/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Just add the executable directory to your PATH variable like this:
echo PATH=/usr/local/Cellar/ruby193/1.9.3-p448/bin:$PATH >> ~/.bash_profile
Reload your terminal to apply the changes and you will be set!
Seems with Sierra, you need to use this to get bundler installed:
sudo gem install bundler -n /usr/local/bin
Reference here refers to how El Cap introduced "SIP (System Integrity Protection)."
I am on Mac OS X Maverics (10.9.2)
Currently my ~/.profile file reads as follows:
# MacPorts Installer addition on 2014-02-23_at_17:28:39: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
source /usr/local/bin/virtualenvwrapper.sh
. /sw/bin/init.sh
And my PATH variable ($PATH) is set to
/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
This is what worked for me.
First I installed bundler using:
gem install bundler
However I got error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Hence I ran sudo gem install bundler and that installed bundler successfully
After that when I ran gem env I got the Executable Directory set to /usr/bin which is already part of my PATH variable. Hence I didn't make any changes to ~/.profile file.
and now I am successfully able to run bundle install.
If the path listed in Executable Directory is not included in your $PATH variable or ~/.profile file, you will have to include it.
Note that if you're using rbenv, you should probably just rbenv rehash and not mess with your PATH

Could not find rails (>= 0) amongst [] (Gem::LoadError)

After installing rvm, updating .gmrc file, updating rubygems and running gem install rails -v ">=3.1.0rc", I now seem to have a complete mess:
$ rails -v
/usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [] (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1182:in `gem'
from /var/lib/gems/1.8/bin/rails:18
myhome#myhome-mini:~$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
- INSTALLATION DIRECTORY: /home/myhome/gems
- RUBY EXECUTABLE: /home/myhome/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /home/myhome/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/myhome/gems
- /usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gemhome" => "/home/myhome/gems"
- "gempath" => ["/home/myhome/gems", "/usr/lib/ruby/gems/1.8"]
- REMOTE SOURCES:
- http://rubygems.org/
I've had a similiar problem. Not sure if that helps you, but you might try to install gems with rvmsudo gem install [gemname] instead of just doing gem install [gemname] or sudo gem install [gemname].
I try to explain this a bit because of the upvotes:
This basically is a path issue. If you set up gems via gem install, they mostly likely will be in another directory (e.g. /usr/local/) compared to gems set up via bundler (where you can override it with --path). Using sudo may also set them up into another directory since sudo starts a subshell which has a different environment then. This is why you have rvmsudo.
If you want to see the differences, compare $PATH, $GEM_HOME, $GEM_PATH and $BUNDLE_PATH when echoing directly, with sudo and with rvmsudo.
I had to sudo gem install bundler to make it work again.
I got a problem similar to this, there may be a compatible problem of rvm.
I fixed by updating rvm to latest version:
curl -L https://get.rvm.io | bash -s stable --ruby
Then you should reload rvm or just open new terminal window.
Then I reinstalled the bundler 'gem install bundler' and ran 'bundle install' as normal
rvm rubygems current
did the trick for me.
remove ruby first
then
sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
to install all needed lib
then you could install ruby and rails
rvm install 1.9.3
rvm --default use 1.9.3
rvm gem install rails
I had pretty much the same message when trying to generate a controller after installing IntelliJ IDEA and the associated Plugin for Rail Dev. From my app directory I just executed bundle install and was then able to generate controllers again.
I know this is a really old question but I just recently decided to move to RVM on a server I had setup a while ago and was having this same problem where gems were being installed in the wrong place and it was just messing everything up.
After a few hours of crawling through SO, I finally figured out that in my .gemrc file in my root folder, I had previously setup the gemhome: and gempath: variables and they were messing with the whole system.
After removing these lines, all my gems were working property.
Just thought I would post my answer in case someone was in the same position.

Resources