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

before_session hook failed: NoMethodError: undefined method `chomp' for nil:NilClass #111

Open
ctrlaltdylan opened this issue Feb 15, 2019 · 4 comments

Comments

@ctrlaltdylan
Copy link

ctrlaltdylan commented Feb 15, 2019

I'm using rails-pry to create a breakpoint with a binding.pry statement. This has worked just fine for just about ever. However now there's this fun new error message I'm not even sure how to being debugging the debugger:

before_session hook failed: NoMethodError: undefined method `chomp' for nil:NilClass
usr/local/bundle/gems/pry-0.12.2/lib/pry/pager.rb:116:in `block in write'
(see _pry_.hooks.errors to debug)

The result is the binding.pry statement is ignored and the code I intent to inspect continues to run.

@samiggapps
Copy link

I got a similar error message

before_session hook failed: NoMethodError: undefined method each' for nil:NilClass`

@mecampbellsoup
Copy link

+1

From: /concierge-render/app/controllers/api/v1/files_controller.rb @ line 3 API::V1::FilesController#destroy:

     2: def destroy
 =>  3:   binding.pry
     4:   file_name = params[:id]
     5:   type = file_params[:type] || 'uploads'
     6:   if type == 'outputs'
     7:     # Only admins can delete outputs they do not own directly.
     8:     job_id = file_params.require(:job_id)
     9:     job = Job.find(job_id)
    10:     unless current_user == job.owner || current_user.admin?
    11:       return not_found_error(file_name)
    12:     end
    13:     full_path = File.join(job.owner.data_dir, type, file_name)
    14:   else
    15:     full_path = File.join(current_user.data_dir, type, file_name)
    16:   end
    17:
    18:   if File.exists? full_path
    19:     if File.file? full_path
    20:       File.delete full_path

<page break> --- Press enter to continue ( q<enter> to break ) --- <page break>
before_session hook failed: NoMethodError: undefined method `chomp' for nil:NilClass
/usr/local/bundle/gems/pry-0.12.2/lib/pry/pager.rb:116:in `block in write'
(see _pry_.hooks.errors to debug)
[1] pry(#<API::V1::FilesController>)> F

Failures:

  1) API::V1::FilesController DELETE #destroy when the file can be found from the file name param when the file name represents a file removes the file from the user's uploads directory
     Failure/Error: expect { subject }.to change { File.exists?(file_path) }.from(true).to(false)
       expected `File.exists?(file_path)` to have changed from true to false, but did not change
     # ./spec/controllers/api/v1/files_controller_spec.rb:240:in `block (5 levels) in <top (required)>'
     # ./spec/rails_helper.rb:111:in `block (3 levels) in <top (required)>'
     # /usr/local/bundle/gems/database_cleaner-1.8.4/lib/database_cleaner/generic/base.rb:16:in `cleaning'
     # /usr/local/bundle/gems/database_cleaner-1.8.4/lib/database_cleaner/configuration.rb:87:in `block (2 levels) in cleaning'
     # /usr/local/bundle/gems/database_cleaner-1.8.4/lib/database_cleaner/configuration.rb:88:in `cleaning'
     # ./spec/rails_helper.rb:110:in `block (2 levels) in <top (required)>'

Finished in 1.01 seconds (files took 1.98 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/controllers/api/v1/files_controller_spec.rb:239 # API::V1::FilesController DELETE #destroy when the file can be found from the file name param when the file name represents a file removes the file from the user's uploads directory

@as-rikoouu
Copy link

as-rikoouu commented Aug 5, 2021

Still getting the same error and the execution never stops. Any lead on this?

<page break> --- Press enter to continue ( q<enter> to break ) --- <page break> before_session hook failed: NoMethodError: undefined method 'chomp' for nil:NilClass /usr/local/bundle/gems/pry-0.12.2/lib/pry/pager.rb:116:in 'block in write' (see _pry_.hooks.errors to debug)

Additional info: I'm using it with docker

@SparkusK
Copy link

Hey folks - sorry for necro'ing a 2 year old thing here, but the fix for this issue is to allow a psuedo-tty and to keep stdin open on Docker when running your containers. If you're running via docker-compose, make sure to add these lines to your Ruby/Rails service:

stdin_open: true
tty: true

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

No branches or pull requests

5 participants