3

Given a Gemfile containing:

source 'https://rubygems.org'

gem 'pry'

And a ruby file containing:

require 'bundler/setup'

# NOT using this line:
# require 'pry'

binding.pry

I am getting this error:

enter code hereundefined method pry' for #<Binding:0x00007f846f053bb0> (NoMethodError)

I know I can easily add require 'pry' in my file, but I really dont want to do that whenever I debug a file.

Also, I would intuitively believe that bundler/setup would autorequire my rubygems defined in the Gemfile.

Can you explain how I can autorequire the file in my Gemfile?

1 Answer 1

2

The trick is to use Bundler.require(:default) after require 'bundler/setup' - since the latter just sets up the load path. See http://bundler.io/v1.16/guides/bundler_setup.html.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for precise, simple answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.