This question already has an answer here:
Why is Ruby 1.9.2 on Windows 7 using a 1.9.1 path for gems? it is using c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb
(1 answer)
Closed 4 years ago.
I've been struggling with this for a while now. I want to use ruby-2.4.1 in my application and installed rbenv and also installed 2.4.1 with it.
I can confirm that ruby -v prints out 2.4.1 is being used.
gem env leads to the following:
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.11
- RUBY VERSION: 2.4.1 (2017-03-22 patchlevel 111) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: /Users/thementoria/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/thementoria/.rbenv/versions/2.4.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/bin
- SPEC CACHE DIRECTORY: /Users/thementoria/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/thementoria/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
- /Users/thementoria/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/thementoria/.rbenv/versions/2.4.1/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- /Users/thementoria/.rbenv/bin
- /Users/thementoria/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/MacGPG2/bin
Note that my USER INSTALLATION DIRECTORY, INSTALLATION DIRECTORY and GEM PATHS have 2.4.0 in it.
What causes this to happen?
In my .bashrc I have:
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
Any help would be appreciated.
All is fine. Ruby assumes that all gems within a minor version are fully compatible.
This is probably based on a 20 year old decision which would allow you to transfer installed gems within patch versions of Rubies, by simply copying or symlinking them, without downloading them again. I doubt that the same decision would be made today.
Related
I think I've got a simple problem but I've spent hours searching for the answer. It's taken me a while to get the correct version of ruby installed and recognized when running ruby -v (it had previously been v2.5.1, but for some reason I still can't use the command bundle install. It tells me I've got the wrong version of ruby... but this doesn't appear to be true???
I am trying to deploy a Ruby on Rails repository to an EC2 instance.
Any help would be much appreciated! Thanks in advance.
I have ran these commands from within my repository directory:
ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
bundle install
Your Ruby version is 2.5.1, but your Gemfile specified 2.5.3
.bashrc and .bash_profile have the following commands in them:
export PATH="$HOME/.rbenv/bin:~/.rbenv/shims:$PATH"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Available versions:
~/.rbenv/versions$ ls
2.5.3
irb
irb(main):001:0> RUBY_VERSION
=> "2.5.3"
rbenv version
2.5.3 (set by /home/ubuntu/.rbenv/version)
whereis ruby
ruby: /usr/bin/ruby
/usr/bin/ruby2.5
/usr/lib/x86_64-linux-gnu/ruby
/usr/lib/ruby
/home/ubuntu/.rbenv/shims/ruby
/snap/bin/ruby.rake /snap/bin/ruby.bundle
/snap/bin/ruby.gem
/snap/bin/ruby.env
/snap/bin/ruby.rdoc
/snap/bin/ruby
/snap/bin/ruby.irb
/snap/bin/ruby.ri
/usr/share/man/man1/ruby.1.gz
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/ubuntu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /home/ubuntu/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /home/ubuntu/.rbenv/versions/2.5.3/bin/ruby
- EXECUTABLE DIRECTORY: /home/ubuntu/.rbenv/versions/2.5.3/bin
- SPEC CACHE DIRECTORY: /home/ubuntu/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/ubuntu/.rbenv/versions/2.5.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/ubuntu/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
- /home/ubuntu/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "“gem" => "--no-document”"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/ubuntu/.rbenv/versions/2.5.3/bin
- /home/ubuntu/.rbenv/libexec
- /home/ubuntu/.rbenv/plugins/ruby-build/bin
- /home/ubuntu/.rbenv/shims
- /home/ubuntu/.rbenv/bin
- ~/.rbenv/shims
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local
You can try to force an update to your Ruby version in the Gemfile.lock:
bundle update --ruby in the same folder as the Gemfile.
If that didn't work you could also try a:
gem install bundler
Making sure you're in a directory/project that is using ruby 2.5.3 (i.e double check with ruby -v).
Finally you can do a manual rbenv rehash to check it's up-to-date:
rbenv rehash
I'm using asdf as a ruby package manager, I had a bunch of issues with the PATH environments and was able to install everything correctly. However, I'm running into issues with the rails gem.
I think I might still have ownership errors with it.
This is my path:
/Users/carlos.grijalva/.asdf/shims:/Users/carlos.grijalva/.asdf/bin:/Users/carlos.grijalva/.rbenv/bin:/Users/carlos.grijalva/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
This is which ruby:
/Users/carlos.grijalva/.asdf/shims/ruby
And this is ruby -v:
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
And this is my GEM environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/carlos.grijalva/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/carlos.grijalva/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /Users/carlos.grijalva/.asdf/installs/ruby/2.5.3/bin/ruby
- EXECUTABLE DIRECTORY: /Users/carlos.grijalva/.asdf/installs/ruby/2.5.3/bin
- SPEC CACHE DIRECTORY: /Users/carlos.grijalva/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/carlos.grijalva/.asdf/installs/ruby/2.5.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/carlos.grijalva/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0
- /Users/carlos.grijalva/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/carlos.grijalva/.asdf/installs/ruby/2.5.3/bin
-
- /Users/carlos.grijalva/.asdf/shims
- /Users/carlos.grijalva/.asdf/bin
- /Users/carlos.grijalva/.rbenv/bin
- /Users/carlos.grijalva/bin
- /usr/local/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
You only want to use one ruby version manager. Make sure you remove anything related to RBEN if you're not using it as your version manager.
Have a look here for things you may need to do.
You should also check your shell for any PATH definitions you don't need regarding RBENV.
I'm setting up a new Mac and trying to get dev environemnt set up. Using Homebrew & RVM as package managers. I have bundler installed when i run bundler -v from root it get Bundler version 1.13.6 no problem.
However I've just cloned one of my app projects locally and when in that app's directory bundler returns command not found. Surley I shouldn't need to install Bundler when in each directory?!? Is this some user permisisons issue? Can you help me understand this situation and why bundler doesn't work in the newly pulled app directory? Ultimately I'm just trying to bundle install the gemfile for this newly cloned application.
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin16]
- INSTALLATION DIRECTORY: /Users/usr/.rvm/gems/ruby-2.2.2
- RUBY EXECUTABLE: /Users/usr/.rvm/rubies/ruby-2.2.2/bin/ruby
- EXECUTABLE DIRECTORY: /Users/usr/rvm/gems/ruby-2.2.2/bin
- SPEC CACHE DIRECTORY: /Users/usr/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/usr/.rvm/rubies/ruby-2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-16
- GEM PATHS:
- /Users/usr/.rvm/gems/ruby-2.2.2
- /Users/usr/.rvm/gems/ruby-2.2.2#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/usr/.rvm/gems/ruby-2.2.2/bin
- /Users/usr/.rvm/gems/ruby-2.2.2#global/bin
- /Users/jusr/.rvm/rubies/ruby-2.2.2/bin
- /Users/usr/.rvm/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
echo $PATH
/Users/usr/.rvm/gems/ruby-2.2.2/bin:/Users/usr/.rvm/gems/ruby-2.2.2#global/bin:/Users/usr/.rvm/rubies/ruby-2.2.2/bin:/Users/usr/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
which gem
/Users/usr/.rvm/rubies/ruby-2.2.2/bin/gem
You need to issue the following command:
rmv use 2.2.2
I had big troubles with fixing RoR that works on my linux mint. Now when all seems to work fine, it doesn't. I'll describe it by c/p my terminal.
matth#MatijaComp /media/Data/My Documents/Sites $ rails -v
Rails 4.2.3
matth#MatijaComp /media/Data/My Documents/Sites $ cd mynewapp/
matth#MatijaComp /media/Data/My Documents/Sites/mynewapp $ rails -v
Warning: You're using Rubygems 1.8.23 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Rails 4.2.1
Well.. Outside of project folder its 4.2.3 version and inside its 4.2.1 version with warning. I was trying to remove this warning by stopping spring spring stop , but nothing happens..And when I try to update Rubygems it says that I have already the newest version.
Then my question is if someone would like to explain me why those versions aren't synchronized and guide me to fix this problem. Thank you!
Update
I fixed rails version, but problem still appears on this warning. when I type gem env it says:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/matth/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: /home/matth/.rbenv/versions/2.2.2/bin/ruby
- EXECUTABLE DIRECTORY: /home/matth/.rbenv/versions/2.2.2/bin
- SPEC CACHE DIRECTORY: /home/matth/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/matth/.rbenv/versions/2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/matth/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- /home/matth/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/matth/.rbenv/versions/2.2.2/bin
- /home/matth/.rbenv/libexec
- /home/matth/.rbenv/plugins/ruby-build/bin
- /home/matth/.rbenv/bin
- /usr/local/bin
- /usr/local/sbin
- /usr/local/mysql/bin
- /home/matth/.rbenv/shims
- /home/matth/.rbenv/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /home/matth/bin
- /usr/local/java/jdk1.8.0_45/bin
- /home/matth/bin
- /usr/local/java/jdk1.8.0_45/bin
Now, which ever action I do with rails command in my project folder it gives me this warning. IN ADDITION, I figured out that commands even don't work. it just appears this:
matth#MatijaComp /media/Data/My Documents/Sites/myfourthapp $ rails generate controller demo index
Warning: You're using Rubygems 1.8.23 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
matth#MatijaComp /media/Data/My Documents/Sites/myfourthapp $
I have "fixed" problem temporary by commenting gem 'spring' in Gemfile. But it is not the way out of this problem.
Rails is just a gem. Among with other gems in the project, it is managed by bundler on a per-project basis.
If you need to change gem version, just specify it in the Gemfile, and run bundle install.
I'm trying to start a new rails app and for some reason my computer is no longer recognising rails....it's been working fine on every other rails app I've been working on until now.
When I typed;
rails new test_app -d postgresql -T
It threw up this error:
/home/camillavk/.rvm/gems/ruby-2.1.5/bin/rails:23:in `load': cannot load such file -- /home/camillavk/.rvm/gems/ruby-2.1.5/gems/rails-4.2.0/bin/rails (LoadError)
from /home/camillavk/.rvm/gems/ruby-2.1.5/bin/rails:23:in `<main>'
from /home/camillavk/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
from /home/camillavk/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
The same error is being thrown when I type rails -v. But when I type which rails I get
/home/camillavk/.rvm/gems/ruby-2.1.5/bin/rails
I then tried to run gem install rails and all it says is 1 gem installed
Any ideas on why rails is doing this on my computer and how to fix it?
*EDIT
gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/camillavk/.rvm/gems/ruby-2.1.5
- RUBY EXECUTABLE: /home/camillavk/.rvm/rubies/ruby-2.1.5/bin/ruby
- EXECUTABLE DIRECTORY: /home/camillavk/.rvm/gems/ruby-2.1.5/bin
- SPEC CACHE DIRECTORY: /home/camillavk/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/camillavk/.rvm/rubies/ruby-2.1.5/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/camillavk/.rvm/gems/ruby-2.1.5
- /home/camillavk/.rvm/gems/ruby-2.1.5#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/camillavk/.rvm/gems/ruby-2.1.5/bin
- /home/camillavk/.rvm/gems/ruby-2.1.5#global/bin
- /home/camillavk/.rvm/rubies/ruby-2.1.5/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /home/camillavk/bin
- /usr/local/java/jdk1.8.0_25/bin
- /home/camillavk/.rvm/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /home/camillavk/.rvm/bin
In case anyone else runs into this issue, I figured that rvm was just getting confused so I told it to use an older version of ruby
$ rvm use 1.9.3
THEN I ran rails new again. This time it worked so I changed into the new app, opened up the gemfile and in there told it to use the newer version of ruby again.
#camillavk,
Please see if the following rvm website link helps (make sure the info. included in these files mentioned in the article is accurate when you check them).
When I first started to use rvm, I used to have such issues as well so I am very careful to define all the rvm setup files for my rails projects.
RVM Projects
I just figured out a exactly the same problem and just used the following command:
gem uninstall -a
Which deletes all unnecessary gems. After that my environment worked well.