Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Pry(a feature rich console) default rails console #6549

Closed
wants to merge 1 commit into from
Closed

Make Pry(a feature rich console) default rails console #6549

wants to merge 1 commit into from

Conversation

homakov
Copy link
Contributor

@homakov homakov commented May 30, 2012

Pry allows developer to go deep inside of ruby and rails class infrastructure - https://github.com/pry/pry
The console becomes very powerful, cd and ls make class/method navigation extremely comfortable.
Bonuses: highlighting, nice inspects, shell shortcuts and other - check the manual.

Huge thanks to @drogus for dd655d8 and 951b582

To discuss:
How to handle if user has no pry installed? Probably just downgrade to IRB and show a message "Pry is not found, using IRB"?
What about moving requirement process inside of rails? I mean config.console = :pry looks more neat.

@dmathieu
Copy link
Contributor

I don't think there really is a problem about "if pry is not installed".
Add it to the Gemfile, it will be installed. Don't, the user will have to do it anyway.

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@dmathieu I'm kinda agree with @wycats https://twitter.com/wycats/status/207673557021491200 we do not even need to add it to gem file. Pry is a 'standalone' gem and rails should not depend on it.
But requiring inside of application.rb as in this PR doesnt seem nice too. In my opinion
config.console = :pry config.console = :irb
Is the best option. @drogus your thoughts?

@wycats
Copy link
Member

wycats commented May 30, 2012

The easiest thing would be for pry to add a Railtie that added the console directive. Then, a simple gem "pry" would do the trick :)

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@wycats genious :) I'm going to ask them for this feature! pry/pry#582

@dmathieu
Copy link
Contributor

You can already do something like this with pry-rails.

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@wycats it's not about the subject though. :) Currently adding gem 'pry-rails' works like a charm - we don't have issues with using it.
The thing is I propose to have pry as default. As you said(and it's reasonable) we should not add it to generated Gemfile(tons of dependencies..) so I added it to application.rb. Any other way to make it default? I don't see it

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@dmathieu yes, it's not a big deal. pry-rails works fine and adding railtie directly to pry would be cool too, as wycats proposed.

But what I want in this PR is pry as default rails console. No matter which way :)

@drogus
Copy link
Member

drogus commented May 30, 2012

@homakov I agree with @dmathieu that pry-rails is the best option, there is no need to add support for rails in pry itself. I would just fix the implementation to use 951b582 rather than IRB = Pry with silence_warnings

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@drogus fine, accepted. what about to make pry default
either add gem 'pry-rails' to Gemfile
or require it in config, as in this PR
I like the latter.

P.S. why to make it default?
Rails is a "standard" and should promote good stuff - it has sass, coffee and jquery "built in". Pry is not that popular as it should be. Thus, for me, making it default is as good as adding coffee years ago :) Agreed or no?

@goshacmd
Copy link
Contributor

👍

But, I do not see any trouble adding pry-rails to the Gemfile.

@dmathieu
Copy link
Contributor

@homakov: if you add pry-rails to the Gemfile, it'll make it a default.

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@dmathieu haha yes. but I want it to be in generated template to be real default

@goshakkk Where are troubles? Everything is fine! Just want to tell about pry all the people :)

@spastorino
Copy link
Contributor

Agree with @wycats, anyway I'd add commented out to the Gemfile gem 'pry' or gem 'pry-rails' if they don't add the railtie.
Then we can also support rails c pry and move the environment option to -e so we have the same setup as we have in rails s.
Currently if you want to use thin you have to add thin to the Gemfile and run rails s thin would be cool to support the same thing for rails c /cc @josevalim

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@spastorino I like rails s thin. rails c pry nice

pry-rails is dirty https://github.com/rweng/pry-rails/blob/master/lib/pry-rails.rb#L10
were efforts of @drogus futile? - we should use config.console

@rf-
Copy link
Contributor

rf- commented May 30, 2012

We'll add the config.console thing to pry-rails sometime between now and the release of Rails 4. The old code will still have to be there for older versions of Rails though.

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@rwfitzge I just wanted to PR you using config.console :) Glad to hear that.

One more time: my proposal was to make pry default rails console. Out of box rails c would run pry. Yes, I can use either config.console and pry-rails gem, but there are other developers who don't use it. I want to notify them how awesome pry is.

Probably it's too soon to discuss it. Just think about it and I hope someday we will get rails w/ default pry. Thanks

@homakov homakov closed this May 30, 2012
@dmathieu
Copy link
Contributor

@rwfitzge could you not just keep the 0.x.x for rails 3 and release 1.x.x with rails 4 compatibility ?

@goshacmd
Copy link
Contributor

@homakov No troubles. I just meant I think having gem 'pry-rails' in Gemfile is OK.

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@goshakkk it's wycats' thought. It's OK: we should keep Gemfile template as short and concise as possible..

@goshacmd
Copy link
Contributor

@homakov Look, I have gem 'pry-rails' in each of my Rails projects. And so many other developers have.

If you just propose to require 'pry' in Rails internals ... I don't know, it feels wrong without adding Pry as an additional development dependency. No?

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

No?

of course no

And so many other developers have

I dont have statistics. Probably big part. I wanted to make the rest to use pry too! :)

@rafaelfranca
Copy link
Member

I disagree with the addition of pry as the default console. I strongly prefer irb and I don't like the idea to not use the default interactive ruby in the Rails.

I'm ok with a commented entry in the Gemfile

@arunagw
Copy link
Member

arunagw commented May 30, 2012

👍 Agree with commented entry in the Gemfile

@drogus
Copy link
Member

drogus commented May 30, 2012

@spastorino rails c pry feels weird. It's common to use different servers, but I can't imagine why would you use pry one time and irb another time

@homakov
Copy link
Contributor Author

homakov commented May 30, 2012

@rafaelfranca old school ? :) why to use irb when pry is available. anyway seems most of you are OK to have it in generated Gemfile..

@drogus example - I use pry on my local machine but sometimes I need to fire up console on the production server. I'm unable to install pry there(right away) so I'd like to downgrade to irb

@goshacmd
Copy link
Contributor

Agree. I like pry but not everybody does, a commented line in Gemfile would be ok.

Gosha Arinich
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Wednesday, May 30, 2012 at 7:57 PM, Rafael Mendonça França wrote:

I disagree with the addition of pry as the default console. I strongly prefer irb and I don't like the idea to not use the default interactive ruby in the Rails.

I'm ok with a commented entry in the Gemfile


Reply to this email directly or view it on GitHub:
#6549 (comment)

@rafaelfranca
Copy link
Member

@homakov hahah. Yes old school ;).

Actually I don't use much the console, so I'm 👎 to add another dependency to a thing that I don't often use.

@spastorino
Copy link
Contributor

Commented out doesn't hurt anybody ;)

@rafaelfranca
Copy link
Member

I'm fine with the Gemfile entry. Commented or not ;)

@homakov
Copy link
Contributor Author

homakov commented May 31, 2012

by adding 'pry-rails' we avoid using special tools: dd655d8 and 951b582
and it becomes a dependency in bundler even if you are not using console as @rafaelfranca does.

it's PR for rails 4 so we definitely have config.console working. http://en.wikipedia.org/wiki/Occam%27s_razor
config.console = Pry - 1 gem, gem 'pry-rails' = 2 gems

@banister
Copy link

@ arunagw how do i do the 'thumbs up' icon? it's pretty impressive and i'd like to use it

@shime
Copy link
Contributor

shime commented May 31, 2012

@banister they are called Emoji emoticons. you can look at this cheat sheet for details: http://www.emoji-cheat-sheet.com/

@homakov homakov reopened this Aug 24, 2012
@homakov
Copy link
Contributor Author

homakov commented Aug 24, 2012

Probably it's too soon to discuss it. Just think about it and I hope someday we will get rails w/ default pry. Thanks

someday!

@drogus
Copy link
Member

drogus commented Aug 24, 2012

I'm still 👎 on it - pry is yet another dependency and since we can set the console easily now, using pry is a matter of adding gem 'rails-pry' to your Gemfile

@homakov
Copy link
Contributor Author

homakov commented Aug 24, 2012

@drogus this point is reasonable, but look at the coffeescript case: It was convenient, useful, not so popular while it also was a 'yet another dependency'. Now when years passed everybody is happy to have it by default In Gemfile. Same here

@drogus
Copy link
Member

drogus commented Aug 24, 2012

@homakov yup, that's true, but there is no coffeescript equivalent in stdlib. Anyway, it doesn't matter to me so much as it will be just another entry in Gemfile - I can just remove it - so if others are ok with this, I won't argue.

@rafaelfranca
Copy link
Member

Actually with our last discussion about what we put in the default stack of Rails I prefer to not add it wither as a commented entry in the Gemfile.

There is a lot of great alternatives in the Ruby world. rspec as an alternative to test_unit/minitest. less as an alternative to sass. datamapper as a alternative to activerecord.

If we put all the alternatives in the Gemfile so, one day we will generate a Gemfile with many commented lines.

👎 for this one

@steveklabnik
Copy link
Member

I love Pry, but yeah, we should be keeping stuff out of core rails as much as possible. 👎

@justinko
Copy link
Contributor

As part of the puts crowd, I vote 💩

@lexmag
Copy link
Contributor

lexmag commented Aug 26, 2012

If you use pry, you use it in all of yours projects.
Why do not simple create global ~/.pryrc?

#!env ruby
if File.exist?(rails = File.join(Dir.getwd, 'config', 'environment.rb'))
  require rails

  require 'rails/console/app'
  require 'rails/console/helpers'

  if Rails.version =~ /^3.2/
    extend Rails::ConsoleMethods
  end
end

And you’ll have access to application models and console helpers.

~/myapp% pry

No extra gems in Gemfile. You still can use rails c

@homakov
Copy link
Contributor Author

homakov commented Aug 26, 2012

@lexmag main point of this PR - make pry more popular. I can use pry in different ways. But I also want other users to use it.

@robin850
Copy link
Member

Maybe we can pass a --pry option when we call rails new ? I allow myself to create a pull request for this suggestion.

@rafaelfranca
Copy link
Member

I really don't think that this is a good idea. We don't add a --rspec option when we call rails new I don't see why we should add a --pry. I'm closing this one since I think we should not change the suggested Rails stack.

@homakov
Copy link
Contributor Author

homakov commented Aug 26, 2012

@rafaelfranca no problem. that day wasn't "someday" :)

@rodrigoalvesvieira
Copy link

Issue is closed now, but anyway, disagree with the addition of Pry. Besides, vanilla IRB + the Rails stack doesn't load very fast already, imagine it with Pry.

@homakov
Copy link
Contributor Author

homakov commented Aug 26, 2012

@rodrigoalvesvieira it's not in Gemfile since not every one uses console. but if u run console you will get an exception if it's not installed.
Oh, you exaggerate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet