GithubHelp home page GithubHelp logo

pry-rails's Introduction

Pry

Pry Build Status Code Climate Gem Version Documentation Status Downloads

Pry logo

© John Mair (banisterfiend) 2018
(Creator)

© Kyrylo Silin (kyrylosilin) 2018
(Maintainer)

Alumni:

  • Conrad Irwin
  • Ryan Fitzgerald
  • Robert Gleeson

Links:

Table of Contents

Introduction

Pry is a runtime developer console and IRB alternative with powerful introspection capabilities. Pry aims to be more than an IRB replacement. It is an attempt to bring REPL driven programming to the Ruby language.

Key features

  • Source code browsing (including core C source with the pry-doc gem)
  • Documentation browsing
  • Live help system
  • Open methods in editors (edit Class#method)
  • Syntax highlighting
  • Command shell integration (start editors, run git, and rake from within Pry)
  • Gist integration
  • Navigation around state (cd, ls and friends)
  • Runtime invocation (use Pry as a developer console or debugger)
  • Exotic object support (BasicObject instances, IClasses, ...)
  • A powerful and flexible command system
  • Ability to view and replay history
  • Many convenience commands inspired by IPython, Smalltalk and other advanced REPLs
  • A wide-range number of plugins that provide remote sessions, full debugging functionality, and more.

Installation

Bundler

gem 'pry', '~> 0.14.2'

Manual

gem install pry

Overview

Pry is fairly flexible and allows significant user customization. It is trivial to read from any object that has a readline method and write to any object that has a puts method. Many other aspects of Pry are also configurable, making it a good choice for implementing custom shells.

Pry comes with an executable so it can be invoked at the command line. Just enter pry to start. A pryrc file in $XDG_CONFIG_HOME/pry/ or the user's home directory will be loaded if it exists. Type pry --help at the command line for more information.

Commands

Nearly every piece of functionality in a Pry session is implemented as a command. Commands are not methods and must start at the beginning of a line, with no whitespace in between. Commands support a flexible syntax and allow 'options' in the same way as shell commands, for example the following Pry command will show a list of all private instance methods (in scope) that begin with 'pa'

pry(YARD::Parser::SourceParser):5> ls -Mp --grep ^pa
YARD::Parser::SourceParser#methods: parse  parser_class  parser_type  parser_type=  parser_type_for_filename

Navigating around state

Pry allows us to pop in and out of different scopes (objects) using the cd command. This enables us to explore the run-time view of a program or library. To view which variables and methods are available within a particular scope we use the versatile ls command.

Here we will begin Pry at top-level, then Pry on a class and then on an instance variable inside that class:

pry(main)> class Hello
pry(main)*   @x = 20
pry(main)* end
=> 20
pry(main)> cd Hello
pry(Hello):1> ls -i
instance variables: @x
pry(Hello):1> cd @x
pry(20):2> self + 10
=> 30
pry(20):2> cd ..
pry(Hello):1> cd ..
pry(main)> cd ..

The number after the : in the pry prompt indicates the nesting level. To display more information about nesting, use the nesting command. E.g

pry("friend"):3> nesting
Nesting status:
0. main (Pry top level)
1. Hello
2. 100
3. "friend"
=> nil

We can then jump back to any of the previous nesting levels by using the jump-to command:

pry("friend"):3> jump-to 1
=> 100
pry(Hello):1>

Runtime invocation

Pry can be invoked in the middle of a running program. It opens a Pry session at the point it's called and makes all program state at that point available. It can be invoked on any object using the my_object.pry syntax or on the current binding (or any binding) using binding.pry. The Pry session will then begin within the scope of the object (or binding). When the session ends the program continues with any modifications you made to it.

This functionality can be used for such things as: debugging, implementing developer consoles and applying hot patches.

code:

# test.rb
require 'pry'

class A
  def hello() puts "hello world!" end
end

a = A.new

# start a REPL session
binding.pry

# program resumes here (after pry session)
puts "program resumes here."

Pry session:

pry(main)> a.hello
hello world!
=> nil
pry(main)> def a.goodbye
pry(main)*   puts "goodbye cruel world!"
pry(main)* end
=> :goodbye
pry(main)> a.goodbye
goodbye cruel world!
=> nil
pry(main)> exit

program resumes here.

Command Shell Integration

A line of input that begins with a '.' will be forwarded to the command shell. This enables us to navigate the file system, spawn editors, and run git and rake directly from within Pry.

Further, we can use the shell-mode command to incorporate the present working directory into the Pry prompt and bring in (limited at this stage, sorry) file name completion. We can also interpolate Ruby code directly into the shell by using the normal #{} string interpolation syntax.

In the code below we're going to switch to shell-mode and edit the pryrc file. We'll then cat its contents and reload the file.

pry(main)> shell-mode
pry main:/home/john/ruby/projects/pry $ .cd ~
pry main:/home/john $ .emacsclient .pryrc
pry main:/home/john $ .cat .pryrc
def hello_world
  puts "hello world!"
end
pry main:/home/john $ load ".pryrc"
=> true
pry main:/home/john $ hello_world
hello world!

We can also interpolate Ruby code into the shell. In the example below we use the shell command cat on a random file from the current directory and count the number of lines in that file with wc:

pry main:/home/john $ .cat #{Dir['*.*'].sample} | wc -l
44

Code Browsing

You can browse method source code with the show-source command. Nearly all Ruby methods (and some C methods, with the pry-doc gem) can have their source viewed. Code that is longer than a page is sent through a pager (such as less), and all code is properly syntax highlighted (even C code).

The show-source command accepts two syntaxes, the typical ri Class#method syntax and also simply the name of a method that's in scope. You can optionally pass the -l option to show-source to include line numbers in the output.

In the following example we will enter the Pry class, list the instance methods beginning with 'se' and display the source code for the set_last_result method:

pry(main)> cd Pry
pry(Pry):1> ls -M --grep se
Pry#methods: raise_up  raise_up!  raise_up_common  reset_eval_string  select_prompt  set_last_result
pry(Pry):1> show-source set_last_result -l

From: /home/john/ruby/projects/pry/lib/pry/pry_instance.rb:405:
Owner: Pry
Visibility: public
Signature: set_last_result(result, code=?)
Number of lines: 6

405: def set_last_result(result, code = "")
406:   @last_result_is_exception = false
407:   @output_ring << result
408:
409:   self.last_result = result unless code =~ /\A\s*\z/
410: end

Note that we can also view C methods (from Ruby Core) using the pry-doc plugin; we also show off the alternate syntax for show-source:

pry(main)> show-source Array#select

From: array.c in Ruby Core (C Method):
Number of lines: 15

static VALUE
rb_ary_select(VALUE ary)
{
    VALUE result;
    long i;

    RETURN_ENUMERATOR(ary, 0, 0);
    result = rb_ary_new2(RARRAY_LEN(ary));
    for (i = 0; i < RARRAY_LEN(ary); i++) {
        if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
            rb_ary_push(result, rb_ary_elt(ary, i));
        }
    }
    return result;
}

Documentation Browsing

One use-case for Pry is to explore a program at run-time by cd-ing in and out of objects and viewing and invoking methods. In the course of exploring it may be useful to read the documentation for a specific method that you come across. show-source command supports two syntaxes - the normal ri syntax as well as accepting the name of any method that is currently in scope.

The Pry documentation system does not rely on pre-generated rdoc or ri, instead it grabs the comments directly above the method on demand. This results in speedier documentation retrieval and allows the Pry system to retrieve documentation for methods that would not be picked up by rdoc. Pry also has a basic understanding of both the rdoc and yard formats and will attempt to syntax highlight the documentation appropriately.

Nonetheless, the ri functionality is very good and has an advantage over Pry's system in that it allows documentation lookup for classes as well as methods. Pry therefore has good integration with ri through the ri command. The syntax for the command is exactly as it would be in command-line - so it is not necessary to quote strings.

In our example we will enter the Gem class and view the documentation for the try_activate method:

pry(main)> cd Gem
pry(Gem):1> show-source try_activate -d

From: /Users/john/rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems.rb:194:
Owner: #<Class:Gem>
Visibility: public
Signature: try_activate(path)
Number of lines: 28

Try to activate a gem containing path. Returns true if
activation succeeded or wasn't needed because it was already
activated. Returns false if it can't find the path in a gem.

def self.try_activate(path)
  # finds the _latest_ version... regardless of loaded specs and their deps
  # if another gem had a requirement that would mean we shouldn't
  # activate the latest version, then either it would already be activated
  # or if it was ambiguous (and thus unresolved) the code in our custom
  # require will try to activate the more specific version.

  spec = Gem::Specification.find_by_path path
pry(Gem):1>

We can also use ri in the normal way:

pry(main) ri Array#each
----------------------------------------------------------- Array#each
     array.each {|item| block }   ->   array
------------------------------------------------------------------------
     Calls _block_ once for each element in _self_, passing that element
     as a parameter.

        a = [ "a", "b", "c" ]
        a.each {|x| print x, " -- " }

     produces:

        a -- b -- c --

Edit methods

You can use edit Class#method or edit my_method (if the method is in scope) to open a method for editing directly in your favorite editor. Pry has knowledge of a few different editors and will attempt to open the file at the line the method is defined.

You can set the editor to use by assigning to the Pry.editor accessor. Pry.editor will default to $EDITOR or failing that will use nano as the backup default. The file that is edited will be automatically reloaded after exiting the editor - reloading can be suppressed by passing the --no-reload option to edit

In the example below we will set our default editor to "emacsclient" and open the Pry#repl method for editing:

pry(main)> Pry.editor = "emacsclient"
pry(main)> edit Pry#repl

Live Help System

Many other commands are available in Pry; to see the full list type help at the prompt. A short description of each command is provided with basic instructions for use; some commands have a more extensive help that can be accessed via typing command_name --help. A command will typically say in its description if the --help option is available.

Use Pry as your Rails Console

You can run a Pry console in your app's environment using Pry's -r flag:

pry -r ./config/environment

Or start the rails console (bin/rails console) and then type pry.

It's also possible to use Pry as your Rails console by adding the pry-rails gem to your Gemfile. This replaces the default console with Pry, in addition to loading the Rails console helpers and adding some useful Rails-specific commands.

Note that pry-rails is not currently maintained.

Also check out the wiki for more information about integrating Pry with Rails.

Syntax Highlighting

Syntax highlighting is on by default in Pry. If you want to change the colors, check out the pry-theme gem.

You can toggle the syntax highlighting on and off in a session by using the toggle-color command. Alternatively, you can turn it off permanently by putting the line Pry.color = false in your pryrc file.

Supported Rubies

  • CRuby >= 2.0.0
  • JRuby >= 9.0

Contact

In case you have a problem, question or a bug report, feel free to:

License

The project uses the MIT License. See LICENSE.md for details.

Contributors

Pry is primarily the work of John Mair (banisterfiend), for full list of contributors see the contributors graph.

pry-rails's People

Contributors

2called-chaos avatar amatsuda avatar banister avatar chtjonas avatar cjlarose avatar crackedmind avatar crazymykl avatar djpowers avatar duggiefresh avatar edgibbs avatar gabetax avatar greysteil avatar hbd225 avatar kyrylo avatar matthiaswinkelmann avatar melopilosyan avatar mkempe avatar mobilutz avatar mykecameron avatar petergoldstein avatar phansch avatar ream88 avatar rf- avatar rking avatar rweng avatar sarenji avatar scottwater avatar siong1987 avatar toqoz avatar treylawrence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pry-rails's Issues

Pry-doc dependency

On Ruby 1.9.3, pry-doc causes segfaults in yard. Having pry-rails depend on pry-doc is not so convenient on 1.9.3 for this reason. Perhaps the dependency should be removed?

plugin should do checks for rails environment

Hi,

thanks for the Pry plugin. However as you will see from that plugin guide plugins are automatically loaded by pry when pry is started. So i'm just concerned that outside of rails contexts your plugin might generate errors as some of the classes/methods you rely on will not exist.

Could you adjust your plugin to only do it's thing if rails is loaded? maybe with const_defined? or so on :P

thanks!

link directly to pry in the readme

Nice little plugin - thanks! I tweeted a link and thought it would be nice to have a link to pry in the README. I'm not sure where it would go; perhaps the README should have a short description of what the plugin does at the top, that could naturally mention and link to pry.

Encoding::UndefinedConversionError

When I paste "ñ" (with quotes) in to the console with pry-rails (0.3.3) enabled I will get an Encoding::UndefinedConversionError error.

$ bundle exec rails console
main:0>"��"
/Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:106:in `write': "\xC3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:106:in `puts'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:106:in `save_to_file'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:50:in `call'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:50:in `push'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:267:in `handle_line'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:242:in `catch'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:242:in `block in eval'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:241:in `catch'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:241:in `eval'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:77:in `block in repl'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:67:in `loop'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:67:in `repl'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:38:in `block in start'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `call'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `__with_ownership'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/input_lock.rb:79:in `with_ownership'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:38:in `start'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:15:in `start'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_class.rb:169:in `start'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/commands/console.rb:47:in `start'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/commands/console.rb:8:in `start'
    from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'

If I disable pry-rails in my Gemfile I get the expected output.

$ bundle exec rails console
Loading development environment (Rails 3.2.21)
irb(main):001:0> "ñ"
=> "ñ"

I'd love to get to the bottom of this, so please let me know if there's any additional information I can provide.

undefined method `create_command' in pry-rails 0.2.0

Hello!

pry-rails 0.1.6 works like a charm, but 0.2.0 won't load the console:

[master][~/dev/journalclub/engine] ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]

[master][~/dev/journalclub/engine] bundle show rails
/Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/rails-3.2.7

[master][~/dev/journalclub/engine] bundle show pry  
/Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-0.9.7.4

[master][~/dev/journalclub/engine] bundle show pry-rails
/Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-rails-0.2.0
# Gemfile
source 'https://rubygems.org'

gem 'rails', '3.2.7'
gem 'pg'
gem 'nokogiri', '~> 1.5.5'
gem 'curb', '~> 0.8.1'
gem 'feedzirra', '0.2.0.rc2'
# gem 'debugger'

group 'development' do
  gem 'pry'
  gem 'pry-rails'
end

group 'test' do
  gem 'vcr', '~> 2.2.4'
  gem 'webmock', '~> 1.8.8'
  gem 'm', '~> 1.1'
  gem 'factory_girl_rails'
end
[master][~/dev/journalclub/engine] rails c
/Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-rails-0.2.0/lib/pry-rails/commands.rb:3:in `block in <module:PryRails>': undefined method `create_command' for #<Pry::CommandSet:0x007fc9cbfc2230> (NoMethodError)
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-0.9.7.4/lib/pry/command_set.rb:62:in `instance_eval'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-0.9.7.4/lib/pry/command_set.rb:62:in `initialize'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-rails-0.2.0/lib/pry-rails/commands.rb:2:in `new'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-rails-0.2.0/lib/pry-rails/commands.rb:2:in `<module:PryRails>'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-rails-0.2.0/lib/pry-rails/commands.rb:1:in `<top (required)>'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-rails-0.2.0/lib/pry-rails.rb:8:in `require'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/pry-rails-0.2.0/lib/pry-rails.rb:8:in `<top (required)>'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `require'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `each'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `each'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in `require'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler.rb:119:in `require'
    from /Users/jason/dev/journalclub/engine/config/application.rb:13:in `<top (required)>'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.7/lib/rails/commands.rb:39:in `require'
    from /Users/jason/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.7/lib/rails/commands.rb:39:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Pry supports readline, Pry-rails does not (OS X)

Hi. I've gotten my build of ruby working with GNU readline as opposed to OS X's editline lib. My .inputrc looks like this:

"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on

When I use pry outside of my rails project, I can type a partial match for the history line I want, and use up and down arrows to find matches. This isn't working when I use the rails console (using pry-rails). I've tried to debug this, but have only found that Pry.config.input is Readline.

Any suggestions on how I can debug why this isn't working / fix the issue?

Thanks.

Reload!

Hi,

I'm using ruby 1.9.3 and rails 3.2.3, I just can't reload when using the console, and I can't figure out a workaround, could you please help?

Missing git tags

There are no git tags seen at https://github.com/rweng/pry-rails/tags

I checked git log and find commits which should associate with tags.

v0.3.0 6bdc27d5b8bc1da051cb01760c8e749f33f6c6e6
v0.2.2 46e10bd921739ceb2ea76047a2defd873629e430
v0.2.1 b410f123a5fe81accd46a1dd9c11fd6ff89c8d75
v0.2.0 0e234c06b733b3618abe5ccb30c01e32296b2a62
v0.1.6 3700581c24264e1141ebfe0814ad28116f61ac05
v0.1.5 11d41eaaa76055279bafb570c252a90ccaac6b53
v0.1.4 86beea6fdbf4fe05b26a20a38fc3048d2378d753
v0.1.3 27abb479de46fae319dfe1c4d034a1dd65c238a2
v0.1.2 c028ebdafdc054c74da04a4f006c63d2a925fd2b
v0.1.1 64aaf0bec385ae589752ade0fd2a3a9ea6814691
v0.0.5 fc50ff4089f468c87191ee7adacef46ae6532ca4
v0.0.4 1fd88d3cf76d237a006a51db7e96ac17c52769c5
v0.0.3 a9b6d198c2f184669f69b7cd2fc3ef91d4a0d387
v0.0.2 3700654cc3e8bcca0288b0cc3b8bba8d1a8f0305
v0.0.1 61fd6842f1ed5069d418d045bdc49c02a463f867

Could you create and push these tags?

P.S. rake release task will automatically do these boring things, so I strongly recommend to use this task for releasing new version to rubygems.org.

uninitialized constant Pry::ExtendCommandBundle (NameError)

When starting the console of a freshly created rails 3.2.0.rc1 app, what I've got is a NameError

/Users/delba/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.0.rc1/lib/rails/commands/console.rb:46:in `start': uninitialized constant Pry::ExtendCommandBundle (NameError)
    from /Users/delba/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.0.rc1/lib/rails/commands/console.rb:8:in `start'
    from /Users/delba/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.0.rc1/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

pry-rails Doesn't seem to work with Rails 4

I also found a question about it on stackoverflow:
http://stackoverflow.com/questions/19151801/pry-rails-not-rails-console-working-with-rails-4-0

This is the error I get using Rails 4 on Ruby 2:

/homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/pry-rails-0.2.0/lib/pry-rails/commands.rb:3:in `block in <module:PryRails>': undefined method `create_command' for #<Pry::CommandSet:0x007f8d73fdd4e8> (NoMethodError)
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/pry-0.9.6/lib/pry/command_set.rb:60:in `instance_eval'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/pry-0.9.6/lib/pry/command_set.rb:60:in `initialize'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/pry-rails-0.2.0/lib/pry-rails/commands.rb:2:in `new'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/pry-rails-0.2.0/lib/pry-rails/commands.rb:2:in `<module:PryRails>'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/pry-rails-0.2.0/lib/pry-rails/commands.rb:1:in `<top (required)>'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/pry-rails-0.2.0/lib/pry-rails.rb:8:in `<top (required)>'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /homedir/project/path/config/application.rb:12:in `<top (required)>'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/railties-4.0.0/lib/rails/commands.rb:62:in `require'
    from /homedir/.rvm/gems/ruby-2.0.0-p247@project/gems/railties-4.0.0/lib/rails/commands.rb:62:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

using bundler :console group

I use the method described here in the "Console Extensions" section to only load pry and pry rails when i'm firing up the console (so I can have it on production without loading it into memory for my app).

http://iain.nl/getting-the-most-out-of-bundler-groups#toc_5

This worked with 0.1.6, but now with 0.2.1 pry no longer loads in any environment. If i take it out of the :console group it does load as expected.

I poked around in the pry-rails railtie and other code and couldn't really see what might be happening, figured I'd raise it here before spending an hour learning pry-rails :-)

Thanks for a great project!

No Rails-specific commands

I am using Rials 3.1.6, rake 0.9.2.2, and pry-rails 0.1.6. I get the following erorrs:

> rake init_test_app

rake aborted!
Don't know how to build task 'init_test_app'
/home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/task_manager.rb:49:in []' /home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:115:ininvoke_task'
/home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in block (2 levels) in top_level' /home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:ineach'
/home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in block in top_level' /home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling'
/home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in top_level' /home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:inblock in run'
/home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' /home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:inrun'
/home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/gems/rake-0.9.2.2/bin/rake:33:in <top (required)>' /home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/bin/rake:19:inload'
/home/sam/.rvm/gems/ruby-1.9.3-p194-fast@global/bin/rake:19:in <main>' /home/sam/.rvm/gems/ruby-1.9.3-p194-fast/bin/ruby_noexec_wrapper:14:ineval'
/home/sam/.rvm/gems/ruby-1.9.3-p194-fast/bin/ruby_noexec_wrapper:14:in `

'

> rails c

[DEVISE] We have detected that you are using devise_for inside engine routes. In this case, you probably want to set Devise.router_name = MOUNT_POINT, where MOUNT_POINT is a symbol representing where this engine will be mounted at. For now Devise will default the mount point to :main_app. You can explicitly set it to :main_app as well in case you want to keep the current behavior.
Loading development environment (Rails 3.1.6)
[1] pry(main)> show-routes
NameError: undefined local variable or method show' for main:Object from (pry):1:inpry'
[2] pry(main)> show-
show-command show-doc show-input show-method show-source

I do not believe there are any of this gem's documented features being exposed to the pry console.

illegal hardware instruction

Just today, I am seeing tons of illegal hardware instruction rails console errors while using pry-rails

Everything was working yesterday. I am unable to use the console at all. If I remove pry-rails from my gemset, the issue goes away.

OS X, 10.8.2 (12C60), 13" Macbook Air, 1.8ghz i7, 4GB ram.

Even more details here.

I don't even know where to begin troubleshooting this problem!

I've reinstalled homebrew, rvm, and all rubies, and recreated my gemsets. I am seeing this issue with both ruby 1.9.3-p194 and 1.9.3-p286.

Next step will probably be to wipe & reinstall OS.

Using pry-rails for non "development" environment

Hi, I am using environments like "flavor1_development", "flavor2_development", "flavor1_production","flavor2_production".
Is there any way to make pry-rails load also in /development/ environments? Not just "development" environment.

pry-rails doesn't pretty print devise models

After using these two gems together successfully for the last year, suddenly the console won't pretty print either of my devise models. All other models print in the console as expected, but User and Admin print in the traditional rails/irb fashion.

Curiously this manifests in a dev branch but not in my master branch, so I suppose that gives me hope for tracking down the problem. Gemfiles are identical - both contain pry-rails 0.3.4 and pry 0.10.4. Precisely nothing was changed in user.rb or admin.rb prior to this problem appearing.

Any tips for debugging?

dependency conflict (slop) with pry-remote

Bundler could not find compatible versions for gem "slop":
  In Gemfile:
    pry-remote (~> 0.1.6) ruby depends on
      slop (~> 3.0) ruby

    pry-rails (~> 0.1.6) ruby depends on
      slop (2.4.4)

Thanks!

reload! - undefined method

Using pry-rails (0.1.2) causes reload! to no longer work in Rails 3.2. with Ruby 1.9.3.

If I remove the pry-rails gem and use irb, it works as expected.

Exact Message:

Loading development environment (Rails 3.2.0)
[1] pry(main)> reload!
NoMethodError: undefined method `reload!' for main:Object

Thanks,
Scott

P.S. I also noticed the app variable is no longer available.

Add an option to the `rails c` command, to launch the console without pry

When using the pry-rails gem, the rails console is always launch with pry.

I think it would be great to have an option to the rails c command, or an command with an other name, that launch the default rails console (ie: without pry).

It is useful sometimes, because pry is sometimes not the best option in the console. For example, when you work with long arrays/hashes. It also hide the ruby backtrace.

What do you think of this ?

Autoload classes on start to have TAB autocompletion

When I launch rails console (which defaults to pry) at start there is no class tab autocompletion, for example (assuming that I have a model named User):

rails c
=> pry(main)> U[TAB] //nothing, but when I launch show-model
=> pry(main)> show-model //this loads all classes including models
=> pry(main)> U[TAB] 
=> pry(main)> User

Is there a way to autoload classes the way show-model does?

Uninitialized constant

Using pry-rails v0.1.5, I get the following error when trying to start the server:

uninitialized constant Rails::Console (NameError)
/Users/mdi/.rvm/gems/ruby-1.9.3-p0-punch/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing'
/Users/mdi/.rvm/gems/ruby-1.9.3-p0-punch/gems/pry-rails-0.1.5/lib/pry-rails.rb:9:in `block in <class:Railtie>'

Gem inclusion is working differently. (Not an issue)

I am using pry-rails (including some other gems) in my local development only by creating local (non-project) Gemfile.

Steps to reproduce this,

  1. Create a new local Gemfile under project root, Gemfile.local with below snippets.
eval File.read('Gemfile') # Project's Gemfile
gem 'pry-rails'
  1. Do bundle install --gemfile=Gemfile.local on project root.

  2. rails console - Expected; console should be as pry. But it's not.

  3. But, when you do bundle exec rails console it's working as expected.

  4. After moving the pry-rails to Project's Gemfile, it's working as expected without bundle exec.

Can anyone explain this, why bundle exec required even though all the gems are downloaded in the same place (RVM Gemset)?

History File Error

I am using pry-rails with Ruby on Rails, and whenever I enter the pry console through rails c or binding.pry I get the error "History file not loaded: invalid byte sequence in UTF-8" and no key strokes history is given me.

Ex. If I type Company.new, hit enter, and hit the up arrow I expect Company.new to be re-entered according to the history. But nothing happens and the above error on startup of the console is all I get.

System configuration

Rails version: 4.2.1

Ruby version: 2.2.3

Pry-Rails version: 0.3.4

Console hooks are broken

Hi,

I'm trying to add default methods to the console like this:

# config/application.rb
# Source http://opensoul.org/2012/11/08/add-helper-methods-to-your-rails-console/
console do
  require 'console_foo'
  Rails::ConsoleMethods.include(ConsoleFoo)
end

Rails includes Rails::ConsoleMethods into the console::ExtendCommandBundle module, in this case that'd be Pry::ExtendCommandBundle which is an empty module so nothing is happening.

I could get this working by doing TOPLEVEL_BINDING.eval('self').extend ConsoleFoo but that seems a lot like a hack, is there a way we could have ExtendCommandBundle work?

The console block gets called before console.start (Pry.start) so maybe there's something to be done there?

Thanks

Some dazzling graph thing

Imagine this:

You have a completely-trusted part of the site that was is a web page with:

  • a pry-backed Rails console like better_errors
  • A graph above, like using gnuplot on the server-side or D3 on the client-side.
  • A generic output console (for showing errors, intermediate queries, and JSON)

Domain experts could hammer at it, with a .png/.svg rendering as the main output. When they like it, they click a thing that says, "Put this on my dashboard of things I like."

Boom, power for the business folk.

This could open up Rails to a whole set of use cases, for almost no expense to the dev.

Also it would make for a shiny demo at RailsConf

Rails.cache when running pry console

After adding pry-rails to my project, Rails.cache no longer works in the console. Is this intentional?

This is what I get when using pry as my console:

(pry) main: 0> Rails.cache.write('foo', 'bar')
true
(pry) main: 0> Rails.cache.read('foo')
nil

Rails 4 and pry-rails

Hi guys,

I've got a problem with the combination of Rails, Ruby, Pry and Pry-Rails where when starting the console with rails console there still is only the irb prompt instead of the pry prompt.
All the tests with pry-rails did run without an error.

Ruby 2.0.0p247
Rails 4.0.0
Pry 0.9.12.2
Pry-Rails 0.3.1

Is there anybody who has the same problem?

Cheers,

Govinda

show-model and ActiveSupport::Concern don't play well together...

There's an issue when you try to run show-model on models that have Concerns which use the included helper.

Example model:

module Concerned
  extend ActiveSupport::Concern

  included do
    scope :omg, -> { where scary: true }
  end
end

class User < ActiveRecord::Base
  include Concerned
end

Pry result:

> show-model User
Exception: ActiveSupport::Concern::MultipleIncludedBlocks: Cannot define multiple 'included' blocks for a Concern

The source of the error is: pry-rails-0.3.4/lib/pry-rails/commands/show_model.rb:17, where it calls Rails.application.eager_load!

It seems like eager_load! is doing something that's including the Concern twice. Here's some more info:

http://stackoverflow.com/questions/24244519/cannot-define-multiple-included-blocks-for-a-concern-activesupportconcern

undefined method `source_index' for Gem:Module

$  rbenv which ruby
/users/dlweber/.rbenv/versions/2.4.1/bin/ruby
$  rbenv which gem
/users/dlweber/.rbenv/versions/2.4.1/bin/gem
$  gem --version
2.6.11
$  rbenv which bundle
/users/dlweber/.rbenv/versions/2.4.1/bin/bundle
$  bundle --version
Bundler version 1.14.6

$  rbenv which rails
/data/src/dlss/hydra/hyrax/.internal_test_app/.bundle/bin/rails
$  rails --version
Rails 5.0.3

$  bundle exec rails c
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'pry-rails'. (Bundler::GemRequireError)
Gem Load Error is: undefined method `source_index' for Gem:Module
Backtrace for gem load error is:
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/command_base_helpers.rb:9:in `gem_installed?'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/command_base_helpers.rb:15:in `block in command_dependencies_met?'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/command_base_helpers.rb:14:in `each'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/command_base_helpers.rb:14:in `all?'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/command_base_helpers.rb:14:in `command_dependencies_met?'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/command_base.rb:53:in `command'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/commands.rb:195:in `<class:Commands>'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/commands.rb:12:in `<class:Pry>'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry/commands.rb:9:in `<top (required)>'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `block in require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:259:in `load_dependency'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-0.8.3/lib/pry.rb:23:in `<top (required)>'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `block in require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:259:in `load_dependency'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pry-rails-0.2.0/lib/pry-rails.rb:3:in `<top (required)>'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `each'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `block in require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `each'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `require'
/users/dlweber/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler.rb:107:in `require'

Class object differs after executing `reload!`

My Environment:

  • Rails 3.2.12
  • pry 0.9.12.2
  • pry-rails 0.3.2

Given some class in app/models/some_class.rb :

class SomeClass
end

Then in the console,

$ bundle exec rails c
> a = SomeClass.new
=> #<SomeClass:0x000000043e2200>
> a.is_a? SomeClass
=> true
> reload!
Reloading...
=> true
> a.is_a? SomeClass
=> false

The result of a.is_a? SomeClass differs after reloading!
It seems that the a.class and SomeClass object after reloading are NOT identical.

> a.class.object_id
=> 37056620
> SomeClass.object_id
=> 37282940

I'd like you to fix this.

no ability to show the sql that is being executed for a process

I am adding a known dead scope to my queries in order to see what sql is being executed.

Mostly due to the fact that I am getting back something that I did not expected and wanted to verify the sql / scope

[8] pry(main)> Schedule.active.with_room.for_course(71).sql
Schedule Load (1.1ms) SELECT schedules.* FROM schedules WHERE schedules.state = 'live' AND schedules.course_id = 71 AND (room_id IS NOT NULL)
NoMethodError: undefined method sql' for #<#<Class:0x00000006751ba0>:0x00000006f41ba8> from /home/thief/.rvm/gems/ruby-1.9.2-p318@relaunch/gems/activerecord-3.2.6/lib/active_record/relation/delegation.rb:45:inmethod_missing'
[9] pry(main)>

Possibly something like this?

http://hi.baidu.com/rainchen/item/fa5c0414acdcd7721109b533

rails c with turn gem ⇒ odd, empty test runs.

If you start with Rails 3.2.9 and do a rails new foo && cd foo

Then edit the Gemfile to have:

group :development do
  gem 'turn'
  gem 'pry-rails'
end

Then run: bundle exec rails c

Then hit ^D to exit the console, you'll get funky output like this:

Loaded Suite test,test/functional,test/unit,test/unit/helpers,test/performance
Started at 2012-12-03 05:56:45 +0000 w/ seed 23441.
Finished in 0.839736 seconds.
0 tests, 0 passed, 0 failures, 0 errors, 0 skips, 0 assertions

This doesn't happen:

  • without the turn gem
  • without the pry-rails gem (not even if you Pry.start from ~/.irbrc)

We haven't had time to look into it beyond seeing that:

  • It comes from the test autorun stuff
  • railties-3.2.9/lib/rails/console/app.rb has a funky hack:
# work around the at_exit hook in test/unit, which kills IRB
Test::Unit.run = true if Test::Unit.respond_to?(:run=)

Any clues about this one?

pry-rails needs a license

Can you please add a LICENSE file (or edit the README) indicating under what terms pry-rails is available?

Collision with rails_admin

When adding rails_admin on top of a project which has pry-rails , I get an error trying to access the localhost:3000/admin where RailsAdmin is mounted:

TypeError in RailsAdmin::MainController#dashboard

wrong argument type ApplicationController (expected Proc)
Rails.root: /Users/alon/git/blog-app

Application Trace | Framework Trace | Full Trace
(eval):8:in `dashboard'
/Users/alon/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails_admin-6a888ed3a5ba/app/controllers/rails_admin/application_controller.rb:71:in `block in '
activesupport (3.2.1) lib/active_support/rescuable.rb:80:in `call'
activesupport (3.2.1) lib/active_support/rescuable.rb:80:in `rescue_with_handler'
actionpack (3.2.1) lib/action_controller/metal/rescue.rb:15:in `rescue_with_handler'
actionpack (3.2.1) lib/action_controller/metal/rescue.rb:32:in `rescue in process_action'
actionpack (3.2.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.1) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
mongo-rails-instrumentation (0.2.4) lib/mongo/rails/instrumentation/controller_runtime.rb:13:in `process_action'
actionpack (3.2.1) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.1) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.1) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.1) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `call'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `dispatch'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.1) lib/journey/router.rb:68:in `block in call'
journey (1.0.1) lib/journey/router.rb:56:in `each'
journey (1.0.1) lib/journey/router.rb:56:in `call'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:589:in `call'
railties (3.2.1) lib/rails/engine.rb:479:in `call'
railties (3.2.1) lib/rails/railtie/configurable.rb:30:in `method_missing'
journey (1.0.1) lib/journey/router.rb:68:in `block in call'
journey (1.0.1) lib/journey/router.rb:56:in `each'
journey (1.0.1) lib/journey/router.rb:56:in `call'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:589:in `call'
rack-pjax (0.5.9) lib/rack/pjax.rb:12:in `call'
omniauth (1.0.3) lib/omniauth/strategy.rb:168:in `call!'
omniauth (1.0.3) lib/omniauth/strategy.rb:148:in `call'
/Users/alon/.rvm/gems/ruby-1.9.3-p0/bundler/gems/mongoid-b4cce4179ace/lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
/Users/alon/.rvm/gems/ruby-1.9.3-p0/bundler/gems/mongoid-b4cce4179ace/lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
/Users/alon/.rvm/gems/ruby-1.9.3-p0/bundler/gems/mongoid-b4cce4179ace/lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
warden (1.1.1) lib/warden/manager.rb:34:in `catch'
warden (1.1.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/head.rb:14:in `call'
remotipart (1.0.2) lib/remotipart/middleware.rb:30:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/cookies.rb:338:in `call'
dragonfly (0.9.11) lib/dragonfly/cookie_monster.rb:9:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `_run__1175696337329485518__call__2101614619010324596__callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'
dragonfly (0.9.11) lib/dragonfly/middleware.rb:13:in `call'
rack-cache (1.1) lib/rack/cache/context.rb:132:in `forward'
rack-cache (1.1) lib/rack/cache/context.rb:241:in `fetch'
rack-cache (1.1) lib/rack/cache/context.rb:181:in `lookup'
rack-cache (1.1) lib/rack/cache/context.rb:65:in `call!'
rack-cache (1.1) lib/rack/cache/context.rb:50:in `call'
railties (3.2.1) lib/rails/engine.rb:479:in `call'
railties (3.2.1) lib/rails/application.rb:220:in `call'
railties (3.2.1) lib/rails/railtie/configurable.rb:30:in `method_missing'
raindrops (0.8.0) lib/raindrops/middleware.rb:118:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/alon/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/alon/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/alon/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Request

Parameters:

{"model_name"=>"admin",
 "id"=>"v_file"}
Show session dump

Show env dump

Response

Headers:

None

Using Pry inside a Rails engine.

It looks like pry-rails does not work within a Rails engine. The following commands were run in a "gemified" Rails 3.2.6 engine, with RSpec 2.11.0, and where the spec/dummy directory contains the dummy application to run tests against:

$ grep ^gemspec Gemfile
gemspec

$ grep pry ${engine_name}.gemspec 
  s.add_development_dependency 'pry-rails', '~> 0.1.6'

$ (cd spec/dummy; rails console)
Loading development environment (Rails 3.2.6)
irb(main):001:0>

does not work with osx10.10/macports ruby2.1

I have installed:

  • osx10.10 (yosemite)
  • macports ruby2.1
  • rails 4.1.6

when I gem install pry-rails
Successfully installed pry-rails-0.3.2

pry startup takes very long

require 'pry-rails' # Failed, saying: Permission denied @ rb_sysopen - /opt/local/lib/ruby2.1/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0/debugger-1.6.5/gem_make.out

gem install debugger

(hangs)

OK, may debugger is the culprit
But you should not try to install gems under the hood.
Better just fail on missing dependencies.

Load error when ruby-debug is enabled

When ruby-debug19 is enabled in my Gemfile I experience the following problem:

rails c

/Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug/commands/irb.rb:3:in `<top (required)>': IRB is not a module (TypeError)
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `block in load_dependency'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug/command.rb:51:in `block in load_commands'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug/command.rb:50:in `each'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug/command.rb:50:in `load_commands'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug/command.rb:210:in `<module:Debugger>'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug/command.rb:5:in `<top (required)>'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug/processor.rb:2:in `require_relative'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug/processor.rb:2:in `<top (required)>'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:6:in `require_relative'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:6:in `<top (required)>'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /Users/bozhidar/work/empower-united/config/application.rb:7:in `<top (required)>'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands.rb:38:in `require'
    from /Users/bozhidar/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands.rb:38:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

rails console throws "uninitialized constant Pry::Prompt (NameError)"

Hi,
I'm getting this error when launching the Rails console in a Rails 4.2.6 project that's using:
pry 0.9.12.6
pry-byebug 1.3.2
pry-rails 0.3.5
pry-rescue 1.4.5

Bundle complete! 78 Gemfile dependencies, 162 gems now installed.
Use bundle show [gemname] to see where a bundled gem is installed.

~/Sites/crs  (rails_4_2 *) % bundle exec rails c
/me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/pry-rails-0.3.5/lib/pry-rails/prompt.rb:36:in <module:PryRails>: uninitialized constant Pry::Prompt (NameError)
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/pry-rails-0.3.5/lib/pry-rails/prompt.rb:1:in <top (required)>
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/pry-rails-0.3.5/lib/pry-rails.rb:10:in <top (required)>
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:76:in require
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:76:in block (2 levels) in require
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:72:in each
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:72:in block in require
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:61:in each
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/runtime.rb:61:in require
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler.rb:134:in require
  from /me/Sites/crs/config/application.rb:21:in <top (required)>
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:141:in require
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:141:in require_application_and_environment!
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:67:in console
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in run_command!
  from /me/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in <top (required)>
  from bin/rails:4:in require
  from bin/rails:4:in <main>

If I remove pry-rails, I have no trouble launching the console:

Bundle complete! 77 Gemfile dependencies, 161 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
~/Sites/crs  (rails_4_2 *) % bundle exec rails c
Loading development environment (Rails 4.2.6)
[1] pry(main)> 

Any ideas?

Gemfile:

gem 'pry'
gem 'pry-byebug'
gem 'pry-rails'

getting unexpected shell command behaviour after installing pry-rails.

I installed pry-rails gem (0.3.4) in rails 4.1.0 and ruby 2.1.3 app. when i switch to rails console the pry works fine in rails console but when i exit rails console with pry, then the console commands behave like below:-

  1. when hit 'cd' it enters pry console.
  2. when hit 'cd ..' no-command found error.
  3. when hit 'clear' lists the directory in current folder.
    I don't know why this sort of behaviour. Is this issue with gem or some kind of malware in my Ubuntu pc.
    This behaviour is only seen in rails app directory(in which pry-rails is installed), if i move to other directory with command cd ../another-dir (which works) the terminal command works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.