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

1257 views
Skip to first unread message

Jim Cropcho

unread,
Aug 5, 2008, 10:58:47 AM8/5/08
to Ruby on Rails: Core
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!

Michael Koziarski

unread,
Aug 5, 2008, 11:28:06 AM8/5/08
to rubyonra...@googlegroups.com
>>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.

--
Cheers

Koz

Jim Cropcho

unread,
Aug 5, 2008, 12:04:34 PM8/5/08
to Ruby on Rails: Core
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.....

RSL

unread,
Aug 5, 2008, 12:15:47 PM8/5/08
to rubyonra...@googlegroups.com
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

Jim Cropcho

unread,
Aug 5, 2008, 12:27:05 PM8/5/08
to Ruby on Rails: Core
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'

:( 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!!!

On Aug 5, 12:15 pm, RSL <sco...@gmail.com> wrote:
> 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
>

RSL

unread,
Aug 5, 2008, 12:29:50 PM8/5/08
to rubyonra...@googlegroups.com
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

Michael Koziarski

unread,
Aug 5, 2008, 12:35:06 PM8/5/08
to rubyonra...@googlegroups.com
> 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

--
Cheers

Koz

Jim Cropcho

unread,
Aug 5, 2008, 12:35:39 PM8/5/08
to Ruby on Rails: Core
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).

On Aug 5, 12:29 pm, RSL <sco...@gmail.com> wrote:
> 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
>

Chad Woolley

unread,
Aug 5, 2008, 12:54:44 PM8/5/08
to rubyonra...@googlegroups.com
On Tue, Aug 5, 2008 at 9:35 AM, Michael Koziarski <mic...@koziarski.com> wrote:
>
>> 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
>

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...

RSL

unread,
Aug 5, 2008, 3:11:24 PM8/5/08
to rubyonra...@googlegroups.com
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

Jim Cropcho

unread,
Aug 5, 2008, 3:56:02 PM8/5/08
to Ruby on Rails: Core
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!

Jim Cropcho

unread,
Aug 6, 2008, 3:35:10 PM8/6/08
to Ruby on Rails: Core
anybody have any ideas about this? i still haven't got it.

delwaterman

unread,
Aug 27, 2008, 12:39:37 PM8/27/08
to Ruby on Rails: Core
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.
Reply all
Reply to author
Forward
0 new messages