Ruby: Random Misc Learning Notes

By Xah Lee. Date:

Misc learning notes.

Ruby on Rails

Misc


Where is ruby gem installed by gem??

Type echo $GEM_HOME

Get Info Using gem

β—† gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [i686-linux]
  - INSTALLATION DIRECTORY: /home/xah/.rvm/gems/ruby-1.9.3-p327
  - RUBY EXECUTABLE: /home/xah/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
  - EXECUTABLE DIRECTORY: /home/xah/.rvm/gems/ruby-1.9.3-p327/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/xah/.rvm/gems/ruby-1.9.3-p327
     - /home/xah/.rvm/gems/ruby-1.9.3-p327@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Get Info Using RVM

type rvm info to get all ruby info.

β—† rvm info

ruby-1.9.3-p327:

  system:
    uname:       "Linux xah-VB3 3.2.0-34-generic-pae #53-Ubuntu SMP Thu Nov 15 11:11:12 UTC 2012 i686 athlon i386 GNU/Linux"
    system:      "ubuntu/12.04/i386"
    bash:        "/bin/bash => GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.17.2 (stable) by Wayne E. Seguin <<a href="mailto:wayneeseguin&#64;gmail.com">wayneeseguin&#64;gmail.com</a>>, Michal Papis <<a href="mailto:mpapis&#64;gmail.com">mpapis&#64;gmail.com</a>> [https://rvm.io/]"
    updated:      "5 days 4 hours 10 minutes 49 seconds ago"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p327"
    date:         "2012-11-10"
    platform:     "i686-linux"
    patchlevel:   "2012-11-10 revision 37606"
    full_version: "ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]"

  homes:
    gem:          "/home/xah/.rvm/gems/ruby-1.9.3-p327"
    ruby:         "/home/xah/.rvm/rubies/ruby-1.9.3-p327"

  binaries:
    ruby:         "/home/xah/.rvm/rubies/ruby-1.9.3-p327/bin/ruby"
    irb:          "/home/xah/.rvm/rubies/ruby-1.9.3-p327/bin/irb"
    gem:          "/home/xah/.rvm/rubies/ruby-1.9.3-p327/bin/gem"
    rake:         "/home/xah/.rvm/gems/ruby-1.9.3-p327@global/bin/rake"

  environment:
    PATH:         "/home/xah/.rvm/gems/ruby-1.9.3-p327/bin:/home/xah/.rvm/gems/ruby-1.9.3-p327@global/bin:/home/xah/.rvm/rubies/ruby-1.9.3-p327/bin:/home/xah/.rvm/bin:/home/xah/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
    GEM_HOME:     "/home/xah/.rvm/gems/ruby-1.9.3-p327"
    GEM_PATH:     "/home/xah/.rvm/gems/ruby-1.9.3-p327:/home/xah/.rvm/gems/ruby-1.9.3-p327@global"
    MY_RUBY_HOME: "/home/xah/.rvm/rubies/ruby-1.9.3-p327"
    IRBRC:        "/home/xah/.rvm/rubies/ruby-1.9.3-p327/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

Ruby's β€œri” shows empty. What to do?

If you are using RVM, do rvm docs generate-ri.

Or, you might try rdoc --all --ri or gem rdoc --all (but this didn't help me). That will generate all RDoc files. See gem help rdoc.

with Ruby 2.0.x, when installing rails, i get this error.

ERROR:  Loading command: install (LoadError)
    cannot load such file -- openssl
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

You need to install OpenSSL first and recompile ruby again.

rvm pkg install openssl

then

rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr

or

rvm reinstall all --force

thx to http://stackoverflow.com/questions/15129355/ruby-2-0-rails-gem-install-error-cannot-load-such-file-openssl