Rspec-rails: irb: warn: can't alias context from irb_context. (3.5.0.beta4 and 3.5.0 final)

Created on 28 Jun 2016  Â·  14Comments  Â·  Source: rspec/rspec-rails

Hey,

After upgrading from 3.5.0.beta3 to 3.5.0.beta4 I receive a warning when using the rails console command like:

bundle exec rails console
Loading development environment (Rails 5.0.0.rc2)
irb: warn: can't alias context from irb_context.
irb(main):001:0>

Version beta3 works well, the warning is only visible in beta4.

Has reproduction case

Most helpful comment

I'm still having issues with:

  • ruby 2.3.1p112
  • Rails 4.2.8
  • rspec (3.6.0)
  • rspec-core (3.6.0)
  • rspec-expectations (3.6.0)
  • rspec-mocks (3.6.0)
  • rspec-rails (3.6.0)
  • rspec-support (3.6.0)
$ rails c
Loading development environment (Rails 4.2.8)
irb: warn: can't alias context from irb_context.
2.3.1 :001 > exit

[EDIT] Just learned many other gems could cause this — I will investigate this further.

All 14 comments

That did not help - i know

That warning is coming from IRB here:

https://github.com/ruby/ruby/blob/32674b167bddc0d737c38f84722986b0f228b44b/lib/irb/extend-command.rb#L188

It's apparently happening because rspec-core, when loaded, defines context on the top level unless you disable monkey patching.

Can you provide a repo that repros this? I tried reproing it in isolation and have failed so far.

@myronmarston ah thanks, I'll try to create a repro the next days. Do you mean this line config.disable_monkey_patching! in spec_helper.rb? It seems monkeypatching is disabled in both of my scenarios, but only with rspec-rails-3.5.0.beta4 the warning gets printed.

Do you mean this line config.disable_monkey_patching! in spec_helper.rb? It seems monkeypatching is disabled in both of my scenarios, but only with rspec-rails-3.5.0.beta4 the warning gets printed.

Correct, that's what I meant, but I just realized why that doesn't solve the problem here: because you have to opt-in to disabling monkey patching (instead of opting in to monkey patching), the monkey patches, including context being defined on main still happen up-front, and then the config option disables them. So it still triggers the IRB warning.

hey @marcusg could you provide us with a reproduction case for this issue? Just a repository we can clone that demonstrates the problem. With that we can debug :)

@samphippen yes, of course. I'll add repro steps as soon as possible.

I've created a repro app https://github.com/marcusg/rspec-rails-issue-1645

  • ruby 2.2.3p173 and 2.3.0p0
  • a fresh rails 5.0.0 app
  • only rspec-rails added
  • using rspec-rails-3.5.0.beta3 works fine
  • using rspec-rails-3.5.0 produces warning when running "bundle exec rails"

Repro confirmed.

I've got the same warning after upgrading rspec-rails to 3.5.1

There's an attempted fix in #1678 -- can one of you who has ran into this issue give that a try?

Can you merge this into the 3-5 branch as well?

Sent from my iPhone

On Jul 22, 2016, at 7:01 PM, Jon Rowe [email protected] wrote:

Closed #1645 via #1678.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Done.

Works for me with 3-5-maintenance branch, thank you guys!

I'm still having issues with:

  • ruby 2.3.1p112
  • Rails 4.2.8
  • rspec (3.6.0)
  • rspec-core (3.6.0)
  • rspec-expectations (3.6.0)
  • rspec-mocks (3.6.0)
  • rspec-rails (3.6.0)
  • rspec-support (3.6.0)
$ rails c
Loading development environment (Rails 4.2.8)
irb: warn: can't alias context from irb_context.
2.3.1 :001 > exit

[EDIT] Just learned many other gems could cause this — I will investigate this further.

Was this page helpful?
0 / 5 - 0 ratings