Forum: Ruby on Rails rake gems not working in test environment

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lee (Guest)
on 2009-04-23 19:22
(Received via mailing list)
I am unable to get 'rake gems' to run in my test environment. I am
using the following command:

rake gems RAILS_ENV=test

and getting the error below. rake gems RAILS_ENV=development works ok.

Any thoughts appreciated.

Trace output:

** Invoke gems (first_time)
** Invoke gems:base (first_time)
** Execute gems:base
** Invoke environment (first_time)
** Execute environment
rake aborted!
no such file to load -- list
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:155:in `require'
/Users/leelon/work/cbox/app/models/filter.rb:10
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:155:in `require'
/Users/leelon/work/cbox/app/models/event_subscription.rb:6
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:155:in `require'
/Users/leelon/work/cbox/app/models/subscription.rb:8
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:155:in `require'
/Users/leelon/work/cbox/app/models/property.rb:7
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:155:in `require'
/Users/leelon/work/cbox/app/models/member_entity.rb:6
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:155:in `require'
/Users/leelon/work/cbox/app/models/accessibility.rb:6
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:155:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:262:in `require_or_load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:221:in `depend_on'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:133:in `require_dependency'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:368:in
`load_application_classes'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:in
`each'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:367:in
`load_application_classes'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:in
`each'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:365:in
`load_application_classes'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:185:in
`process'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in
`send'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in
`run'
/Users/leelon/work/cbox/config/environment.rb:13
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/tasks/misc.rake:3
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/tasks/gems.rake:21
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:588:in
`invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:585:in
`invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:577:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in
`invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in
`standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in
`standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.4/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Lee (Guest)
on 2009-04-23 20:17
(Received via mailing list)
I've now discovered this problem is being caused by a require
statement in my models:

require 'list'

where 'list' is list.rb in the acts_as_list plugin.

I am unable to remove this as it is needed by a standalone Ruby
program that uses the same models as the Rails environment (and
ActiveRecord).

I still don't understand why 'rake gems' works in development but not
in test - that is, rake gems only complains about the "require 'list'"
statement when run in test. Any thoughts appreciated.
Lee (Guest)
on 2009-04-24 08:27
(Received via mailing list)
I have solved this problem by extending the load path in
environment.rb:

config.load_paths += %W( #{RAILS_ROOT}/vendor/plugins/acts_as_list/lib/
active_record/acts )

rake gems RAILS_ENV=test is now able to resolve my "require 'list'"
statements in my models.
Matt J. (Guest)
on 2009-04-25 03:42
(Received via mailing list)
The problem you ran into was the same one as this thread:

http://groups.google.com/group/rubyonrails-talk/br...

and both are caused by load_application_classes trying to load all
your models at startup. That routine does nothing when
config.cache_classes is false (the default in development mode).

However, I'm surprised that "require 'list'" *ever* worked. Even with
the Rails environment loaded, it gives me an error. The correct
require would be 'active_record/acts/list'.

On a somewhat related note, I've found that Rake tasks work a lot
better than standalone Ruby programs, and save a lot of headaches with
loading the environment...

--Matt J.
This topic is locked and can not be replied to.