f



require 'active_support' or 'i18n' first ?

Hi all,

I discovered recently a strange behavior. If I require 'i18n' gem then
'active_support' then everything is ok, if I change order - irb  raises
an exception:

 $ irb
ruby-1.9.2-p0 > require 'i18n'
 => true
ruby-1.9.2-p0 > require 'active_support'
 => true
ruby-1.9.2-p0 > exit
eugen@eugen-hp:~$  $ irb
ruby-1.9.2-p0 > require 'active_support'
 => true
ruby-1.9.2-p0 > require 'i18n'
NameError: uninitialized constant Object::I18n
  from
/home/eugen/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/i18n.rb:8:in
`<top (required)>'
  from
/home/eugen/.rvm/gems/ruby-1.9.2-p0/gems/i18n-0.5.0/lib/i18n/version.rb:1:in
`<top (required)>'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from
/home/eugen/.rvm/gems/ruby-1.9.2-p0/gems/i18n-0.5.0/lib/i18n.rb:1:in
`<top (required)>'
  from <internal:lib/rubygems/custom_require>:33:in `require'
  from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from (irb):2
  from /home/eugen/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'

It is a bug? Any idea ?


----
http://blog.eugen.co

-- 
Posted via http://www.ruby-forum.com/.

0
ciur.eugen (28)
5/4/2011 8:49:39 PM
comp.lang.ruby 48886 articles. 0 followers. Post Follow

1 Replies
277 Views

Similar Articles

[PageSpeed] 15

On Wed, May 4, 2011 at 1:49 PM, Eugen Ciur <ciur.eugen@gmail.com> wrote:
> Hi all,
>
> I discovered recently a strange behavior. If I require 'i18n' gem then
> 'active_support' then everything is ok, if I change order - irb =C2=A0rai=
ses
> an exception:
>
> =C2=A0$ irb
> ruby-1.9.2-p0 > require 'i18n'
> =C2=A0=3D> true
> ruby-1.9.2-p0 > require 'active_support'
> =C2=A0=3D> true
> ruby-1.9.2-p0 > exit
> eugen@eugen-hp:~$ =C2=A0$ irb
> ruby-1.9.2-p0 > require 'active_support'
> =C2=A0=3D> true
> ruby-1.9.2-p0 > require 'i18n'
> NameError: uninitialized constant Object::I18n
> =C2=A0from
> /home/eugen/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_s=
upport/i18n.rb:8:in
> `<top (required)>'
> =C2=A0from
> /home/eugen/.rvm/gems/ruby-1.9.2-p0/gems/i18n-0.5.0/lib/i18n/version.rb:1=
:in
> `<top (required)>'
> =C2=A0from <internal:lib/rubygems/custom_require>:29:in `require'
> =C2=A0from <internal:lib/rubygems/custom_require>:29:in `require'
> =C2=A0from
> /home/eugen/.rvm/gems/ruby-1.9.2-p0/gems/i18n-0.5.0/lib/i18n.rb:1:in
> `<top (required)>'
> =C2=A0from <internal:lib/rubygems/custom_require>:33:in `require'
> =C2=A0from <internal:lib/rubygems/custom_require>:33:in `rescue in requir=
e'
> =C2=A0from <internal:lib/rubygems/custom_require>:29:in `require'
> =C2=A0from (irb):2
> =C2=A0from /home/eugen/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
>
> It is a bug? Any idea ?

It seems like it might be a side-effect of a bug in the version of
Active Support you are using; I get the same thing when using that
version (3.0.1), but using the current version of Active Support
(3.0.7), I just get a false back on the require 'i18n' done after
require 'active_support', which is expected because Active Support
does a require 'i18n', so requiring both is redundant.

Updating Active Support (if using Rails, you probably want to do the
whole Rails stack) to the current release should stop this behavior
from manifesting, but you probably don't need to require both of these
gems anyway, given the redundancy.

0
cmdicely (196)
5/5/2011 1:44:08 AM
Reply: