RubyGems is reporting a different ruby version than running ruby --version. Looking for suggestions on diagnosing and fixing this. OS is OS X 10.5.
lando-macbook:rubygems-1.3.7 lando$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-9
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/lkuhn/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
lando-macbook:rubygems-1.3.7 lando$ ruby --version
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin9]
lando-macbook:rubygems-1.3.7 lando$ which ruby
/opt/local/bin/ruby
The problem is that you have a ruby executable in /opt/local/bin that was probably installed by macports at some point. Either deleting this ruby executable or removing /opt/local/bin from your PATH variable should solve your problem. gems is telling you exactly where it expects to find ruby and its associated executables:
RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
Related
Note: This question relates to How can I get bundler to use the Ruby version set by chruby and .ruby-version?.
Using chruby I have Ruby 1.8.7 installed on macOS:
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]
Also, I have used gem update --system 1.8.30 to install a specific version of RubyGems which I am hoping is compatible. This would appear to be installed properly:
$ gem --version
1.8.30
However, my RubyGems environment shows the incorrect version of Ruby (2.5.0):
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.30
- RUBY VERSION: 2.5.0 (2017-12-25 patchlevel 0) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/keithpitty/.gem/ruby/1.8.7
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
How can I fix the RubyGems environment to use the version of Ruby that chruby has set?
My missing step was installing RubyGems 1.6.2 from source. Following advice elsewhere from Dan Cheail, I did the following:
curl -O https://rubygems.org/rubygems/rubygems-1.6.2.tgz
(and then unzipped it)
cd rubygems-1.6.2
chruby ruby-1.8.7-p374
ruby setup.rb
gem update --system 1.8.25
And then my RubyGems environment was fixed:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]
- INSTALLATION DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7
- RUBY EXECUTABLE: /Users/keithpitty/.rubies/ruby-1.8.7-p374/bin/ruby
- EXECUTABLE DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-17
- GEM PATHS:
- /Users/keithpitty/.gem/ruby/1.8.7
- /Users/keithpitty/.rubies/ruby-1.8.7-p374/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I recently installed Ruby 2.0.0 on OS X 10.8.3 by compiling from source code. I checked the version with
$ ruby --version
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]
And I checked my gem version with
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-12
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/ehartsuyker/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :benchmark => false
- :sources => ["http://rubygems.org/", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://rubygems.org/
- http://gemcutter.org
I noticed that the reported version of Ruby here does not match the version I installed. I don't know if this matters or not.
I have a simple piece of code called encrypy.rb that I'm running. After installing the 'rsa' gem with gem install rsa.
require 'rubygems'
require 'rsa'
key = RSA::KeyPair.generate(128)
ciphertext = key.encrypt("message")
puts(ciphertext)
When I run it, it gives an error saying it can't find the gem.
$ ruby encrypt.rb -Idirectory '/Library/Ruby/Gems/1.8'
/usr/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- rsa (LoadError)
from /usr/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from encrypt.rb:2:in `<main>'
So the question is, why isn't Ruby finding the gem despite seeming to know where it is? And how can I fix it?
Ruby 1.8.7 is shipped with OS X. It seems that gem is seeing that version instead of your manually installed 2.0.0. As others already suggested, using RVM or rbenv (which one depends on personal preference) makes handling different ruby environments much easier. You can find those tools and descriptions for them in the following places:
RVM: https://rvm.io/
rbenv: https://github.com/sstephenson/rbenv
I have Ruby installed on my work PC 1.9.3 version and Gem 1.8.24 but when I try to install Rails I get the following error:
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - C:/Users/B"k"nyi Szabolcs
Can I fix this without creating a new Windows User?
Thanks for the help in advance.
My Windows user folder name is : Bökönyi Szabolcs
gem env says:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby193/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby193/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby193/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby193/lib/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
It seems I figured it out and the only problem was with the accent so instead of SET HOME %USERPROFILE% I used SET HOME="C:/Users/Bökönyi Szabolcs" and now the gem install rails works.
I am following this guide to install jekyll on OSX 10.7.3 and came up with the problem
ERROR: could not find gem jekyll locally or in a repository
I have tried:
sudo gem update --system (and get Nothing to update)
this post: How can I install Jekyll on Ubuntu 10.04 Server? , and it's no use.
I am not familiar with ruby and gem but I think this is needed:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-11
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/enzo/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org", "http://gems.github.com"]
- REMOTE SOURCES:
- http://rubygems.org
- http://gems.github.com
I don't know anything specifically about Jekyll, but there might very well be issues when running it with the system Ruby (that is, the one that comes with Mac OS).
Before wasting too much time bothering with the system Ruby (which could arguably be better left untouched), try to get either rbenv or rvm working. They allow you to install as many different versions of Ruby as you want without messing with the system Ruby, with each installation having its own gems.
Since you're not familiar with Ruby, I'll add that using rbenv or rvm is how most Ruby kids get their job done. Yes, it is an additional step that gets in the way, but it really does facilitate a smoother experience.
I recommend removing gems.github.com from your gem sources unless you really need it. GitHub ceased building gems from git repositories back in 2010. If you cannot remove it, then I recommend installing jekyll with the following command:
gem install --source http://rubygems.org jekyll
My rubygems environment for reference, as I'm on OS X 10.7.5.
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-11
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/matt/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I installed Jekyll directly into a new clean install of OSX Mavericks, and then wrote a quick post so I'd remember how to do it after I next reinstall my system. I've had plenty of feedback that others have had success following my guide, and no reports of anyone having any issues:
http://internet-inspired.com/wrote/install-jekyll-in-osx-mavericks/
I had Ruby 1.9.2 install, but I uninstalled it long ago. Today I installed a brand new version of Ruby 1.9.3, downloaded gem and set it up with ruby setup.rb.
I then noticed that installing gems failed, so I checked gem environment and this is what I get:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [i386-mingw32]
- INSTALLATION DIRECTORY: c:/Ruby192/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby193/bin/ruby.exe
- EXECUTABLE DIRECTORY: c:/Ruby192/lib/ruby/gems/1.9.1/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- c:/Ruby192/lib/ruby/gems/1.9.1
- C:/.gem/ruby/1.9.1
- C:/Ruby193/lib/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
It seems messing up the new installation (Ruby193) with the old one (Ruby192).
ruby -v yields, correctly, ruby 1.9.3p0 (2011-10-30) [i386-mingw32].
How to solve the problem?
EDIT: I had GEM_HOME and RUBYLIB environment variables set up to the old directories. Updating them solved the problem.
You shouldn't need to download gem or run ruby setup.rb.
I recommend removing all references to old rubies from your path environment variable and then downloading 1.9.3 from rubyinstaller.org install it and then download, install and run the devkit