Inline Bundler Without Gemfile

wusher

wusher

Posted on September 1, 2022

Inline Bundler Without Gemfile

For quick throwaway ruby scripts, you can add your gemfile inline. When you run the file, ruby will install your dependencies and then execute the script.

Inline bundler

# BEGIN inline bundler 
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'httparty'
  gem 'pry'
end
# END inline bundler 

resp = HTTParty.get "https://rubygems.org"
binding.pry 

Enter fullscreen mode Exit fullscreen mode

Running

> ruby tmp.rb 

From: /Users/user/code/tmp.rb:11 :

     6: gem 'httparty'
     7: gem 'pry'
     8: end
     9: 
    10: resp = HTTParty.get "https://rubygems.org"
 => 11: binding.pry 

[1] pry(main)> 

Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
wusher
wusher

Posted on September 1, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related