Error on running unity test: "no such file to load -- 'active_record/version'"

Hi folks!

I’ve been experimenting an error messagem when I try to run unity test
in any model of my project.

Here it is:

/home/fabricio/shopcell/config/environment.rb:1:in require': no such file to load -- active_record/version (LoadError) from /home/fabricio/shopcell/config/environment.rb:1 from ./test/test_helper.rb:2:inrequire’
from ./test/test_helper.rb:2
from test/unit/client_test.rb:1:in `require’
from test/unit/client_test.rb:1

My application runs smoothly, but I get stuck on this only when trying
running tests.
I know that the statement “require ‘active_record’” works when I run
the applications because if I remove this statement fom
‘environment.rb’ my server (Mongrel) doesn’t even run.

Have anybody an idea of what’s going on?

My system:
UBUNTU 10.04
RUBY 1.87
RUBYGEMS 1.3.7
RAILS 2.2.2

Thanks in advance!

Fabrício

On Oct 6, 2:48 am, Fabrício Dias [email protected] wrote:

My application runs smoothly, but I get stuck on this only when trying
running tests.
I know that the statement “require ‘active_record’” works when I run
the applications because if I remove this statement fom
‘environment.rb’ my server (Mongrel) doesn’t even run.

Have anybody an idea of what’s going on?

So what’s in config/environment.rb then?

Fred

Hi, Fred!

Thanks for your resonse.

My config/environment.rb has that exact line:

“require ‘active_record/version’”

Fabrício

On Oct 6, 12:49 pm, Fabrício Dias [email protected] wrote:

Hi, Fred!

Thanks for your resonse.

My config/environment.rb has that exact line:

“require ‘active_record/version’”

I should rephrase that - what else is in your environment.rb ? None of
mine have that line and it shouldn’t be needed since activerecord will
get loaded as part of the rails initialisation process (and that line
could in fact screw things up if it is run before rubygems has been
loaded)

Fred

Here it goes, Fred:

require ‘active_record/version’

Be sure to restart your server when you modify this file

Uncomment below to force Rails into production mode when

you don’t control web/app server and can’t set it the proper way

ENV[‘RAILS_ENV’] ||= ‘production’

Specifies gem version of Rails to use when vendor/rails is not

present
RAILS_GEM_VERSION = ‘2.2.2’ unless defined? RAILS_GEM_VERSION

Bootstrap the Rails environment, frameworks, and default

configuration
require File.join(File.dirname(FILE), ‘boot’)

Rails::Initializer.run do |config|

Settings in config/environments/* take precedence over those

specified here.

Application configuration should go into files in config/

initializers

– all .rb files in that directory are automatically loaded.

See Rails::Configuration for more options.

Skip frameworks you’re not going to use. To use Rails without a

database

you must remove the Active Record framework.

config.frameworks -=

[ :active_record, :active_resource, :action_mailer ]

Specify gems that this application depends on.

They can then be installed with “rake gems:install” on new

installations.

You have to specify the :lib option for libraries, where the Gem

name (sqlite3-ruby) differs from the file itself (sqlite3)

config.gem “bj”

config.gem “hpricot”, :version => ‘0.6’, :source => "http://

code.whytheluckystiff.net"

config.gem “sqlite3-ruby”, :lib => “sqlite3”

config.gem “aws-s3”, :lib => “aws/s3”

Only load the plugins named here, in the order given. By default,

all plugins

in vendor/plugins are loaded in alphabetical order.

:all can be used as a placeholder for all plugins not explicitly

named

config.plugins =

[ :exception_notification, :ssl_requirement, :all ]

Add additional load paths for your own custom dirs

config.load_paths += %W( #{RAILS_ROOT}/extras )

Force all environments to use the same logger level

(by default production uses :info, the others :debug)

config.log_level = :debug

Make Time.zone default to the specified zone, and make Active

Record store time values

in the database in UTC, and return them converted to the specified

local zone.

Run “rake -D time” for a list of tasks for finding time zone

names. Comment line to use default local time.
config.time_zone = ‘UTC’

The internationalization framework can be changed to have another

default locale (standard is :en) or more load paths.

All files from config/locales/*.rb,yml are added automatically.

config.i18n.load_path << Dir[File.join(RAILS_ROOT, ‘my’,

‘locales’, ‘*.{rb,yml}’)]

config.i18n.default_locale = :de

Your secret key for verifying cookie session data integrity.

If you change this key, all old sessions will become invalid!

Make sure the secret is at least 30 characters and all random,

no regular words or you’ll be exposed to dictionary attacks.

config.action_controller.session = {
:session_key => ‘_shopcell_session’,
:secret => ‘f914e9b1bbdb829688de8512f…
9b1810a4e238a61dfd922dc9dd62521’
}

Use the database for sessions instead of the cookie-based default,

which shouldn’t be used to store highly confidential information

(create the session table with “rake db:sessions:create”)

config.action_controller.session_store = :active_record_store

Use SQL instead of Active Record’s schema dumper when creating the

test database.

This is necessary if your schema can’t be completely dumped by the

schema dumper,

like if you have constraints or database-specific column types

config.active_record.schema_format = :sql

Activate observers that should always be running

Please note that observers generated using script/generate

observer need to have an _observer suffix

config.active_record.observers

= :cacher, :garbage_collector, :forum_observer

#act_as_tagglable_on
config.gem “acts-as-taggable-on”, :source => “http://
gemcutter.org”, :version => ‘2.0.0.rc1’

#brazilian_rails
require ‘brcpfcnpj’
end
END OF
ENVIRONMENT.RB==================================================================

If I remove the first line (require ‘active_record/version’), I get
this error when running “ruby script/server”:

==================================================================



** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment…
Exiting
/home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:445:in load_missing_constant': uninitialized constant ActiveRecord::VERSION (NameError) from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:77:inconst_missing’
from /var/lib/gems/1.8/gems/acts-as-taggable-on-2.0.0.rc1/lib/acts-as-
taggable-on.rb:6
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:153:in require' from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:521:innew_constants_in’
from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:153:in require' from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/rails/ gem_dependency.rb:94:inload’
from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/initializer.rb:
281:in load_gems' from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/initializer.rb: 281:ineach’
from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/initializer.rb:
281:in load_gems' from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/initializer.rb: 159:inprocess’
from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/initializer.rb:
112:in send' from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/initializer.rb: 112:inrun’
from /home/fabricio/shopcell/config/environment.rb:14
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:153:in require' from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:521:innew_constants_in’
from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:153:in require' from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb: 147:inrails’
from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in
cloaker_' from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb: 149:incall’
from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
149:in listener' from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:incloaker_’
from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
50:in call' from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb: 50:ininitialize’
from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in
new' from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:inrun’
from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:
212:in run' from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:142:inload_without_new_constant_marking’
from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:142:in load' from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:521:innew_constants_in’
from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:142:in load' from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/commands/ servers/mongrel.rb:64 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in require' from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:153:inrequire’
from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:521:in new_constants_in' from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/ active_support/dependencies.rb:153:inrequire’
from /home/fabricio/.gem/ruby/1.8/gems/rails-2.2.2/lib/commands/
server.rb:49
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from script/server:3

==================================================================

On Oct 6, 9:01 am, Frederick C. [email protected]

On Oct 6, 1:32 pm, Fabrício Dias [email protected] wrote:

Here it goes, Fred:

require ‘active_record/version’

Be sure to restart your server when you modify this file

You should probably stick it after the line requires boot.rb - that
way the rails gems should already be on the load path

Fred

FIXED!

I’ve moved the statement to a line right after the boot.rb requirement
and now I’m able to run my tests now with no problems.

Thanks, Fred!

On Oct 6, 1:18 pm, Frederick C. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs