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 <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [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

If you have a question, put $5 at patreon and message me.

  1. Ruby Basics
  2. Doc Lookup
  3. Print Version String
  4. What's RVM, Gem, Rake, Bundler, RDoc, ri, irb?

  1. Unicode 💎
  2. Quote String
  3. Quote Long String
  4. Format String
  5. String Operations
  6. True, False
  7. “if then else”
  8. for, while, Loop
  9. List
  10. Loop Thru List
  11. Hash Table
  12. Function Optional Parameter
  13. Map f to List
  14. Complex Numbers
  1. Intro to Reading Ruby Doc: What's M, C, ::, # ?
  2. Predefined Global Variables