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

How to Bundler (ROSSConf 2015)

André Arko
September 26, 2015

How to Bundler (ROSSConf 2015)

ROSSConf brings developers together to learn about open source projects, and then work on them together with help from project team members. This talk explains how Bundler works and highlights some upcoming plans that could use help from contributors, and was given at ROSSConf 2015 in Berlin, Germany.

André Arko

September 26, 2015

More Decks by André Arko

Other Decks in Programming


  1. how to Bundler

  2. André Arko @indirect

  3. None
  4. None
  5. None
  6. let’s share ruby code

  7. Gemfile gem “foo”

  8. Terminal $ bundle install

  9. Terminal $ bundle exec foo

  10. done! pretty cool, right?

  11. but… what just happened?

  12. iiiiit’s History ⚔ Time

  13. 1994 2000 2003 2009 dependency timeline require setup.rb RubyGems Bundler

  14. require it loads the codes

  15. def require(filename) eval File.read(filename) end

  16. i’m sure it’s fine run code twice?

  17. $LOADED_FEATURES = [] def require(filename) if $LOADED_FEATURES.include?(filename) return true end

    eval File.read(filename) $LOADED_FEATURES << filename end
  18. probably fine too only absolute paths?

  19. $LOAD_PATH = [] def require(filename) full_path = $LOAD_PATH.first do |path|

    File.exist?(File.join(path, filename)) end eval File.read(full_path) end
  20. load paths are ⛄ pretty ❄ cool

  21. but now we need… setup.rb

  22. how do setup.rb? ruby setup.rb setup ruby setup.rb config ruby

    setup.rb install
  23. use ruby libraries 1. Find a cool library 2. Download

    the library 3. Untar the library 4. Run `ruby setup.rb all`
  24. no versions no uninstall but it’s fine, I’m sure

  25. maybe a little bit incredibly tedious

  26. what if you could… gem install gem uninstall gem list

  27. bonus round! gem install rails -v 4.1 gem install rails

    -v 4.2 gem install rails -v 5.0
  28. gem "rack", "1.0" require "rack"

  29. $ rackup _1.2.2_ -p 3000

  30. so many gems! 100,000 gems 1,000,000 versions

  31. but gem apps don’t play well with others

  32. welcome to the team here’s your machine we expect setting

    up to take a week
  33. # config/application.rb […] config.gem “rack” config.gem “rails” config.gem “what?” […]

  34. “why is this broken in production?” “dunno, it works on

    every developer machine” 3 days of debugging later… “oh, look, one production server has frobnitz 1.1.3, but the others have 1.1.4” “welp. that explains those exceptions ”
  35. version conflicts gem install rails rails s cd ../other-project rails

  36. activation errors how common can they be, really?

  37. $ rails s Gem::LoadError: can't activate rack (~> 1.0.0., runtime)

    for ["actionpack-2.3.5"], already activated rack-1.1.0 for ["thin-1.2.7"] activation errors
  38. the moral runtime resolution install-time resolution

  39. wait… how do we resolve at install-time?

  40. None
  41. addressable (2.3.7) arel (6.0.0) bcrypt (3.1.10) binding_of_caller (0.7.2) debug_inspector (>=

    0.0.1) builder (3.2.2) byebug (3.5.1) columnize (~> 0.8) debugger-linecache (~> 1.2) slop (~> 3.6) celluloid (0.16.0) Gemfile.lock
  42. bundle install my old friend 1. Read the Gemfile (and

    lock, if it's there) 2. Ask RubyGems.org for a list of every gem we need 2. Find gems allowed by the Gemfile that work together 3. Write down those versions in the lock for future installs 4. Install gems until every locked gem is installed
  43. bundle exec everyone’s nemesis 1. Read the Gemfile (and lock,

    if it's there) 2a. Use locked gems if possible OR 2b. Find versions that work to put in the lock 3. Remove any existing gems the $LOAD_PATH 4. Add each gem in the lock to the $LOAD_PATH
  44. pro tip no more bundle exec! $ bundle binstubs rspec-core

    $ bin/rspec repeat as needed for other gems
  45. was that the end? in a word, no.

  46. I want YOU to contribute 2 @bundlerio team@bundler.io

  47. we have many plans • gathering gemfiles for a bundler

    benchmark • triaging github issues • add failing tests for bugs • improving our code! (check PullReview or
 Code Climate for ideas) • create a FAQ for bundler.io • build more librato graphs using our data • track how many projects a gem is used in • update the command docs on bundler.io • local gem server
  48. We have a see you there! we have a guide