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

Can't use IRB when FakeFS is activated #484

Closed
mrzasa opened this issue Feb 8, 2023 · 1 comment · Fixed by #488
Closed

Can't use IRB when FakeFS is activated #484

mrzasa opened this issue Feb 8, 2023 · 1 comment · Fixed by #488

Comments

@mrzasa
Copy link
Contributor

mrzasa commented Feb 8, 2023

IRB can't start when FakeFS is activated, because it can't open the history file.

See the minimal example below:

require 'fakefs'

RSpec.describe 'IRB inside FakeFS' do
  it 'works' do
    binding.irb
  end
end

it ends up with an error:

    Failure/Error: Unable to find pry-fakefs/irb_spec.rb to read failed line
     
     Errno::ENOENT:
       No such file or directory - /home/mrzasa/.irb-history
     # ruby-3.0.4/gems/fakefs-1.8.0/lib/fakefs/file.rb:876:in `check_file_existence!'
     # ruby-3.0.4/gems/fakefs-1.8.0/lib/fakefs/file.rb:503:in `initialize'
     # ruby-3.0.4/gems/fakefs-1.8.0/lib/fakefs/kernel.rb:40:in `open'
     # ruby-3.0.4/gems/fakefs-1.8.0/lib/fakefs/kernel.rb:40:in `block in <module:Kernel>'
     # pry-fakefs/irb_spec.rb:5:in `block (2 levels) in <top (required)>'

This I believe is an effect of hijacking the Kernel#open method. To fix it we need to unhijack it in the IRB context.

Related to #290

Similar issue with pry is addressed in this PR: #485 (the pry problem is simpler though - it's enough to assign correctly mocked classes).

@grosser
Copy link
Collaborator

grosser commented Feb 8, 2023

PR welcome

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 a pull request may close this issue.

2 participants