"irb: warn: can't alias context from irb_context." when console loads

When I

ruby script/console

I get

Loading development environment (Rails 2.1.0) irb: warn: can't alias context from irb_context.

exit

Finished in 0.039212 seconds

0 examples, 0 failures

weird, right? And it doesn't happen w/ script/server.

I'm on Ubuntu hardy.

ruby -v ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]

This problem has been around since before I can remember, and it's only a problem with _one_ rails application. I have stepped through the code and used Unroller to no avail, b/c the "irb:warn" occurs within irb itself.

I'm guessing I haven't given enough information, so please tell me what (if anything) you guys need to help.

Thanks!

Loading development environment (Rails 2.1.0) irb: warn: can't alias context from irb_context.

exit

Finished in 0.039212 seconds

0 examples, 0 failures

weird, right? And it doesn't happen w/ script/server.

The test runs are generally caused by requiring test/unit outside of your tests. It adds code to run at exit. The warning is something I've never seen before.

I'm guessing I haven't given enough information, so please tell me what (if anything) you guys need to help.

Odds are it's caused by one of your plugins. Try disabling them one by one until you find which one is causing these messages.

Thx so far, koz!

Odds are it's caused by one of your plugins. Try disabling them one by one until you find which one is causing these messages.

I tried ditching my whole /vendor directory, and got the same two problems. But, I have another idea: I don't get 'the test problem' when I boot the rails server (both mongrel and WEBrick). Presumably the code that loads test/unit i loaded for the app's console, but not the app's server. Also, presumably not much code can meet this criteria.

Anybody know what said code is?

and oh yea:

egrep -R "^require.+test\/unit" *

from RAILS_ROOT doesn't give me anything outside of /vendor.

grr.....

are you requiring rspec in yr environment.rb? i've seen someone do this and get similar errors. [if you are... just remove that line, rspec will load itself in test environment.]

RSL

SWEETNESSSSSS!!!!!11

Although I'm too smart to require rspec at boot, I'm too stupid to realize that's exactly what's happening when I pull a

config.gem 'rspec' , :lib => 'spec'

:frowning: I took rspec, rcov, syntax and all my testing stuff out of that list, and needless to say, BOTH problems were solved.

The only part that sucks is that apparently I can't use Rails 2.1 to manage my apps' gem dependencies (automated installation/freezing) if they're not supposed to be loaded at boot.

Any ideas on how to do that? Does gems on rails do it?

thx all!!!

rspec shouldn't be a dependency at all since it's only used in test environment. is there another gem yr trying to do this with that is a problem?

RSL

Any ideas on how to do that? Does gems on rails do it?

Can't you just put the config.gem call in config/environments/test.rb

RSL,

I was obviously using gem dependency management for the wrong thing part of the time. I froze all gems needed by a developer into /vendor/ gems so that everything needed would be available out-of-box, and so everybody's using the same gems/rails versions (rspec in particular can be quite finicky about versions).

So yea, ideas on how to do that? It's not a super-huge problem, since as long as I don't reference rspec & company in environment.rb, I get no problems, even if they exist in /vendor/gems and /vendor/plugins (which they still do).

Or use GemInstaller (http://geminstaller.rubyforge.org/) via preinitializer.rb, if you still cannot get things loaded in the order you need. preinitializer.rb happens before boot or any of the env files are parsed...

i use vendor/plugins/rspec and rspec-rails [cause i use edge a decent amount] so it's never been an issue. i've had a few vendor/gems before but they all just worked with config.gem out of the box. [thank you rails team!] what's the specifics on the gem that's not loading right?

RSL

holy crap, I am about to give you guys a headache, I think (thanks for all the help so far).

so, my gem list (after our fix):

  config.gem 'haml',:source => "http://gems.github.com"   config.gem 'mime-types' , :lib => 'mime/types'   config.gem 'json'

removed rspec, and no more "alias" or test/unit problems for script/ console. but check this out:

$ rake db:migrate (in /XXX/XX/XXX) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump Loaded suite /usr/bin/rake Started

Finished in 0.000228 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

yea, that's right. now i'm getting it for all my rake tasks. add rspec back to environment.rb and they go away for rake and come back for console.

frustration...

btw, i haven't added rspec to /environments/test.rb or anything like that yet, so that doesn't play a role here.

need more info? please ask.

let's figure this out!

anybody have any ideas about this? i still haven't got it.

I had a similar problem and I finally traced it down to the way I named and loaded my models. I don't know if this applies to your situation it might give you a clue.

I had a model Spec::AppComponent which is used in a platform system we were building. When that model was referenced in the initialzers it would cause the errors described above to occur. When I renamed the model to AppComponent the issue disappeared. My guess, is that because I have rspec as a plugin, that the reference to the Spec module is somehow causing rspec to load. Hope this helps.