ruby - Use Pry in gems without modifying the Gemfile or using `require` -
i trying debug gem that's used rails app.
i cloned gem locally go prying around (and allows me nice things such git bisect
, etc.)
# gemfile gem "active_admin", path: "~/dev-forks/active_admin"
however, stuck adding pry gemfile somewhere able use it, or calling require "pry"
live in code though don't want in there. example, forget it, fix bug, , commit project pry in gemfile.
should not that, loaderror
arise, cannot load such file -- pry (loaderror)
.
i have admin i'm bit lost between different contexts (rails project, gem, local ruby) , actual gems (gemfile, require, installed).
how can use binding.pry
in gem within rails, without intervention of gemfiles?
jon past! know, have answers (almost) problems.
in case, you're describing 2 problems: (a) can't require 'pry'
when pry not in gemfile, (b) can't use pry if don't require
it.
what bundler does, conrad irwin writes:
bundler awesome gem gives degree of confidence "if works in development, works in production". can being vicious gem dependencies: if it's not in gemfile, it's not getting required. ensures everyone's development environment identical, no more "it works on machine" cut excuse.
there circumstances when dogmatic dedication duty can in way. in particular developers have set development environment personally. obviously, it's not important local tools work in production, , it's positively bad productivity if forced have identicial development setup.
so in doing things bundler ruby developers, comes design caveat: "what's outside bundle/gemfile (eg system gems) doesn't exist anymore." how redefining require
process , changes path
sees what's in bundle.
that means can't use pry @ without polluting gemfile, say, right? not fast. conrad irwin being smart little cookie is, came solution , made pry debundle, gem temporarily reverses patches bundler made our require.
so have require 'pry-debundle'
then, right? oh... wait. yep, debundle not in gemfile.
the monkey fix hard copy source of pry-debundle.rb
~/debundle.rb
, , load
that. (for now, you'll need pry loaded run source file, can run debundle!
method there, require pry, , go prying around. little monkeypatching needed, i'm working on pr.)
Comments
Post a Comment