Ruby gem wrong installation directory - ruby

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

Related

New to Ruby and am having trouble with LOAD_PATH

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

unable to install jekyll on OSX

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/

Why is my gem "INSTALLATION DIRECTORY:" ...1.9.1 when the "RUBY VERSION:" is 1.9.3 [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Why are gems installed in a 1.9.1 directory when my Ruby version is different than 1.9.1?
I've installed Ruby 1.9.3-p0 on an RHEL 6 system (Linux 2.6.32-122.el6.x86_64) by downloading the source and compiling. I didn't use any options. Just ./configure, make, and make install.
When I run gem environment I get...
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.17
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Notice the references to "/usr/local/lib/ruby/gems/1.9.1". Shouldn't that be "1.9.3"?
I ran gem update --system, and it output "1.9.1" both before and after I did so.
I don't think so. I have Ruby 1.9.2, and the directory is still 1.9.1. I think this is for backward compatibly with gems from previous minor versions.

Can't install gems with bundler

I can't install gems with bundler, it always fail with a Can't find <inser-gem-name-here> in any of the sources message although I do have rubygems defined as a source in my gemfile.
Also, I can normally install gems with gem install <gem-name>, I used to install the ones that fail manually and then run bundle install so that it sees them as already installed, but that doesn't wrok anymore.
I used to use rvm, got tired of this issue (and thought it caused it) so I switched to rbenv to no avail. I'm running 1.9.2-p290.
I'm running Mac OS Lion. Thanks!
gem env output:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.2.0]
- INSTALLATION DIRECTORY: /Users/X/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/X/.rbenv/versions/1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /Users/X/.rbenv/versions/1.9.2-p290/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/X/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1
- /Users/X/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.github.com", "http://rubygems.org", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://gems.github.com
- http://rubygems.org
- http://gemcutter.org
Also
$which gem
/Users/X/.rbenv/shims/gem
And
$ which ruby
/Users/X/.rbenv/shims/ruby
I had a similar problem, that I managed to resolve by exporting my http_proxy
export http_proxy=http://user:password#host:port
Hope this helps.

Things to do before upgrading Ruby

What should I do before upgrading to the latest version of Ruby? any tips?
Update
sorry for my unclear question.
my condition: I've upgraded my Ruby from 1.8.7 to 1.9.1p243. It makes me can not use all installed gems.
so, what should I do before upgrading Ruby? uninstall all my installed gems? I was looking in other SO posts in here, But there are no answers for my question.
Unless you are using custom GEM environment variables or a .gemrc (or some multi ruby system like rvm) then the locations where rubygems are installed for each ruby installation will be different.
You can manage the locations used by rubygems by managing the GEM_HOME and GEM_PATH environment variables or the .gemrc file. It is possible to set your gems to be shared across ruby installations with these variables or the .gemrc
.gemrc:
http://docs.rubygems.org/read/chapter/11
GEM Environment variables:
http://docs.rubygems.org/read/chapter/12#page52
You can find the environment settings for a rubygems installation by running:
/path/to/gem env
This will output something like the following:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /home/aji/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gemcutter.org
While the number of rubygems that are compatible with ruby 1.9 is constantly growing, you will need to check with the maintainer or homepage of each gem/project to verify if your gems will work or not.
Also check previous questions on SO regarding differences between 1.8 & 1.9:
What is the difference between Ruby 1.8 and Ruby 1.9

Resources