Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From Whence Rubygems

Tim Uruski
February 20, 2014

From Whence Rubygems

A talk about where Rubygems come from? How they make their way from the internet (and other places) and into our programs.

Tim Uruski

February 20, 2014
Tweet

More Decks by Tim Uruski

Other Decks in Programming

Transcript

  1. + Where do gems come from? + Where are gems

    installed to? + How do gems get onto the load path?
  2. $ gem env home > /home/timuruski/.gem/ruby/2.0 > /usr/lib/ruby/gems/2.0 ! $

    ruby -e "puts Gem.dir" > /home/timuruski/.gem/ruby/2.0 > /usr/lib/ruby/gems/2.0
  3. gems ├── build_info ├── cache │ └── hola-0.1.3.gem ├── doc

    ├── extensions ├── gems │ └── hola-0.1.3 │ └── lib │ └── hola.rb └── specifications └── hola-0.1.3.gemspec
  4. $ ruby -e "puts $:" > /usr/lib/ruby/2.0 ! $ ruby

    -e "require 'hola'; puts $:" > /usr/lib/ruby/gems/2.0/gems/hola-0.1.3/lib > /usr/lib/ruby/2.0
  5. $ gem env path > /usr/lib/ruby/gems/2.0 > /home/timuruski/.gem/ruby/2.0 ! $

    ruby -e "puts Gem.path" > /usr/lib/ruby/gems/2.0 > /home/timuruski/.gem/ruby/2.0
  6. .rvm ├── bin ├── ... ├── gemsets └── scripts ├──

    ... ├── selector ├── selector_gemset └── ...
  7. # .rvm/scripts/selector_gemset if [[ "$rvm_gemset_name" == "global" ]] then rvm_ruby_gem_path="${rvm_ruby_gem_home}"

    else rvm_ruby_gem_path="${rvm_ruby_gem_home}:¶ ${rvm_ruby_global_gems_path}" fi
  8. echo " -->> ENVIRONMENT: $*" export PATH="/home/timuruski/.rvm/gems/ruby-2.0.0-p353@demo/bin:/home/timuruski/.rvm/gems/ ruby-2.0.0-p353@global/bin:/home/vagrant/.rvm/rubies/ruby-2.0.0-p353/bin:$PATH" export GEM_HOME='/home/timuruski/.rvm/gems/ruby-2.0.0-p353@demo'

    export GEM_PATH='/home/timuruski/.rvm/gems/ruby-2.0.0-p353@demo:/home/vagrant/.rvm/gems/ ruby-2.0.0-p353@global' export MY_RUBY_HOME='/home/timuruski/.rvm/rubies/ruby-2.0.0-p353' export IRBRC='/home/timuruski/.rvm/rubies/ruby-2.0.0-p353/.irbrc' unset MAGLEV_HOME unset RBXOPT
  9. rbenv-gemset ├── bin ├── etc │ └── rbenv.d │ ├──

    exec │ │ └── gemset.bash │ ├── rehash │ │ └── gemset.bash │ └── which │ └── gemset.bash └── libexec
  10. # rbenv-gemset/etc/rbenv.d/exec/gemset.bash unset GEM_HOME for gemset in $(rbenv-gemset active); do

    path="${RBENV_GEMSET_ROOT}/$gemset" if [ -z "$GEM_HOME" ]; then GEM_HOME="$path" fi done
  11. $ echo $GEM_HOME > ! $ gem env home >

    ~/.rbenv/versions/2.0.0/gemsets/example ! $ ruby -e "puts ENV['GEM_HOME']" > ~/.rbenv/versions/2.0.0/gemsets/example
  12. # rbenv-gemset/etc/rbenv.d/exec/gemset.bash unset GEM_PATH for gemset in $(rbenv-gemset active); do

    path="${RBENV_GEMSET_ROOT}/$gemset" GEM_PATH="$GEM_PATH:$path" done
  13. $ echo $GEM_PATH > ! $ gem env path >

    ~/.rbenv/versions/2.0.0/gemsets/example > ~/.rbenv/versions/2.0.0/gemsets/default ! $ ruby -e "puts ENV['GEM_PATH']" > ~/.rbenv/versions/2.0.0/gemsets/example > ~/.rbenv/versions/2.0.0/gemsets/default
  14. lib ├── bundler │ ├── capistrano.rb │ ├── cli.rb │

    └── ... ├── ... └── bundler.rb
  15. # lib/bundler/rubygems_integration.rb if RubygemsIntegration.provides?(">= 1.99.99") @rubygems = RubygemsIntegration::Future.new elsif RubygemsIntegration.provides?('>=

    1.8.20') @rubygems = RubygemsIntegration::MoreModern.new elsif RubygemsIntegration.provides?('>= 1.8.5') @rubygems = RubygemsIntegration::Modern.new elsif RubygemsIntegration.provides?('>= 1.8.0') @rubygems = RubygemsIntegration::AlmostModern.new elsif ...