DEV Community

wusher
wusher

Posted on • Originally published at wusher.github.io on

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

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay