All notes


RubyGems is a package management framework for Ruby.


Ruby 1.9 and newer ships with RubyGems built-in but you may need to upgrade for bug fixes or new features.


# Install a gem into the local repository
gem install GEMNAME --source

gem install spring --development

# Use this when a gem dependencies file (gem.deps.rb, Gemfile or Isolate) is present. If no explicit file is given RubyGems attempts to find one in the current directory.
gem install -g

# For gems with executables ruby installs a wrapper file into the executable directory by default. This can be overridden with the –no-wrappers option.

# Q: How to create a Gemfile?
# A: You can run `bundle init` to create a new, empty Gemfile.

# Q: Where is Gems installed?
# A: Use `gem env` to have a look.


rubygems guides.

# Check source.
gem sources

# Rebuild index for affected sources, e.g.
gem generate_index

# -d: detail
gem search ^rails [-d]

#---------- list

# Display local gems whose name matches REGEXP
gem list

# Read doc for installed GEMNAME:
# Read doc on http server:
gem server

# Fetch and read without installation. If you doubt about security of GEMNAME:
gem fetch $GEMNAME
gem unpack $GEMNAME

gem build GEMNAME.gemspec
gem install gemname-version.gem

# Specify that a gem should come from a git repository with a .gemspec at its root
# Because Rubygems lacks the ability to handle gems from git, any gems installed from a git repository will not show up in gem list.
# They will, however, be available after running Bundler.setup.
gem 'nokogiri', :git => ''

# What if
# /usr/bin/ruby extconf.rb 
# mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
sudo yum -y install ruby-devel

# See environment.
gem env
# Notice the two sections for:

# gem sources should at least contain If not
gem sources -a

SO provides a brief introduction to: gems, RubyGems, bundler, rvm, gemsets.


Can't install passenger

Ref. Put passenger gem to Gemfile.


Newer gem installed but old ones are required

gem uninstall then install the old version again

Establish googleapis mirror

git clone
cd googleapis-mirror
sudo yum install rubygem-rake
gem install bundler
gem install io-console
bundle install

rake sync
# The following step could be replaced by Apache/Nginx.
# sudo rake serve

Then let Apache server these files as a mirror:

<VirtualHost *:80>
  DocumentRoot "/path/to/googleapis-mirror"
  <Directory "/path/to/googleapis-mirror">
    Options Indexes
    Require all granted

Then add in your hosts:


Mirrors for ruby gems

# If there is SSL certificate problem, change https to http:
gem sources --add --remove
gem sources -l

gem update --system
gem -v