This project is archived and is in readonly mode.
bundle group for addition of custom irb helpers to rails console
-
José Valim
- State changed from new to wontfix
Rails internals does not know anything about bundler. Just your application.
-
codesnik
It seems to me they actually do, railties/lib/rails/backtrace_cleaner.rb for example.
We can use the same trick here, patch attached.Rails console is not a debug tool only, it's an invaluable ready-to-use admin interface for small projects, and it deserves some sugar, no?
-
José Valim
- Milestone cleared.
- State changed from wontfix to open
- Assigned user set to Jeremy Kemper
My concern is, if we do a patch for Bundler, later we would have to make the same for RIP and other packages. For me, it's still a no go, but you definitely have a point if we already have bundler specifics in Rails code, so I'm handling it to Jeremy.
-
codesnik
I understand your concern. There's nothing binding to Bundler or rubygems in the rails code now, apart default generated boot.rb (which could be rewritten for a specific app) and that single bit of bundler in backtrace cleaner is there just because most users would like have that functionality, and adding it by youself is, while possible, not a nobrainer..
..while this patch is essentially equivalent to putting that
Bundler.require(:console)right into your projects irbrc, if you really need it. But I think it would encourage people to create self-contained rails specific irb extensions as gems.And this patch isn't useful without documentation, and I'm not sure where's a place for it, maybe in a default generated Gemfile, commented out, as in the first my patch, would work. or maybe not.
-
Jeremy Kemper
- State changed from open to wontfix
You can use normal requires in your .irbrc rather than explicit runtime gem dependencies. Not a fan of adding internal Bundler.require(:group) hooks for every case like this.
-
codesnik
actually I can't use "normal requires". If I'm running non customized rails3 generated app, it uses Bundler, and if app uses Bundler, it is initialized before rails console, any .irbrc evaluation, too.
And Bundler empties gem load path, so I can't just
requireany system gem not explicitly listed in app's Gemfile, even in development. I have to create some nondefault group in Gemfile just for that. Thoose gems would be bundled, but won't be loaded while running server.Do you know any other way?
question is, should default group be there for such things, and should I have to create irb.rc in Rails.root even if thoose gems do not require any additional initialization?
(and don't forget that if there's ~/.irbrc, then Rails.root/irb.rc won't load at all. and there's no equivalent for ~/.Gemfile. that sucks)
-
Jeremy Kemper
Put the gems in some group in your Gemfile so they aren't required by default.
Then require them in .irbrc.
-
codesnik
exactly the same solution I've started that ticket with.
Point was, there's is still a great inconvenience ( have to use local project's Gemfile for my "global" ~/.irbrc, and and if i want to use local irb.rc I have to delete global, and whatever ), and I thought some rails-style convenient default for console extensions would compensate for this, though not overcome it.
I'll try to find some another solution, current state is unacceptable for me.
-
Dave Myron
- Importance changed from to Low
@codesnik: Did you ever figure out a solution for this. I'm getting this same problem with Ruby 1.9.2-head and Rails 3.0.0.beta4
-
codesnik
I wrapped all the gem dependent functionality in my global .irbrc in begin; require 'blabla' .... rescue LoadError; puts "gem blabla not installed"; end blocks.
then if I really need something from that list in my rails console, I add "group :console { gem 'blabla' }" into my project Gemfile.
It's not autorequired, but is available for require anytime.
works for me.
-
Evgeniy Dolzhenko
Probably better place to discuss the issue: http://github.com/carlhuda/bundler/issues#issue/183/comment/225440
-
Jeff Kreeftmeijer
Automatic cleanup of spam.
