postmodern / chruby

Changes the current Ruby
MIT License
2.86k stars 190 forks source link

inconsistencies concerning gem locations #306

Closed x-yuri closed 9 years ago

x-yuri commented 9 years ago

I believe this is better demonstrated with shell typescript:

$ chruby
   ruby-2.0.0-p247
 * ruby-2.1.5
$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.4)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.5)
rake (10.1.0)
rdoc (4.1.0)
test-unit (2.1.5.0)
$ for gem in bigdecimal io-console json minitest psych rake rdoc test-unit; do gem which $gem; done
/home/yuri/.rubies/ruby-2.1.5/lib/ruby/2.1.0/x86_64-linux/bigdecimal.so
ERROR:  Can't find ruby library file or shared library io-console
/home/yuri/.rubies/ruby-2.1.5/lib/ruby/2.1.0/json.rb
ERROR:  Can't find ruby library file or shared library minitest
/home/yuri/.rubies/ruby-2.1.5/lib/ruby/2.1.0/psych.rb
/home/yuri/.rubies/ruby-2.1.5/lib/ruby/2.1.0/rake.rb
/home/yuri/.rubies/ruby-2.1.5/lib/ruby/2.1.0/rdoc.rb
ERROR:  Can't find ruby library file or shared library test-unit
$ ls -1 ~/.rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/
rake-10.1.0
rdoc-4.1.0
test-unit-2.1.5.0

Why can't it find all the gems? Why the gems in ~/.rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/ seem to be not used?

postmodern commented 9 years ago

Those are so-called "built-in" gems that MRI installs. You can also install newer versions via rubygems.

x-yuri commented 9 years ago

so, gems in ~/.rubies/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/ aren't supposed to be required? What about those errors?

postmodern commented 9 years ago

gem which searches for files, not gem names. You can require those gems:

require 'bigdecimal'
require 'io/console'
require 'json'
require 'minitest/unit'
require 'psych'
require 'rake'
require 'rdoc'
require 'test/unit'