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

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.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 9
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

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.

Happened via guard-rspec for me. See https://github.com/guard/guard-rspec/issues/396.

gem 'guard-rspec', require: false fixed this.

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.