Rake test fails with LoadError, looking in home directory - ruby-on-rails

When I try to run "rake test" on my newly generated rails application I receive the following error
Computer:heroku user$ rake test:units
/Users/user
file doesnt exist
/Users/user/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require': cannot load such file -- /Users/user/test/unit/helpers/things_helper_test.rb (LoadError)
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
from /Users/user/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [/Users/user/.rvm/rubies/ruby-1.9.3-p0/b...]
Tasks: TOP => test:units
(See full trace by running task with --trace)
I am guessing that this is related to my setup somehow, as it seems as if rake is looking for the generated files in my home directory instead of the rails application directory. Could you help direct me to what I am doing wrong?
I am using Mac OS X Lion, have two installed ruby versions (1.8.7 come with lion, 1.9.3 which I am using for the application has been installed using rvm).
The application works if I run "rails s".
Update: If I create a new rails application from scratch, adding only a generated scaffold, the rake test command works. Ergo, it might be a incompatibility issue as the failing rails application was created on another computer, uploaded to heroku and then cloned from there to a new computer.

Funny story. I'd accidentally put some test code in one of the files, among other containing:
Dir.chdir("../..")
I'm guessing that when I run rake test the file got executed to load the class contained in the file, and caused problems when looking for the next file, when the current directory had suddenly changed.

Related

LoadError: cannot load such file --rails on 'rake db:setup'

I'm having an issue trying to switch the database in my rails app from the out of box sqlite3 to using postgres.
I've run 'gem install pg' and switched the database.yml file to new settings. Also, I've run 'bundle install' in the directory.
Now, when I run 'rake db:setup', I'm receiving this error:
$ rake db:setup
rake aborted!
LoadError: cannot load such file -- rails
/Users/aaa/Documents/Projects/sample_app/config/application.rb:3:in `require'
/Users/aaa/Documents/Projects/sample_app/config/application.rb:3:in `<top (required)>'
/Users/aaa/Documents/Projects/sample_app/Rakefile:4:in `<top (required)>'
/Users/aaa/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/Users/aaa/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
Any thoughts? Thank you in advance.
Oy, had the wrong version of rails in my gemfile.
If anyone else finds this, make sure running rails -v has your intended result! I was receiving an error when trying to see my rails version, and then changing my gemfile solved the issue.

rails rspec error generating controller

Soo the problem occured after i got rspec installed when i do rails g controller name i get the following error:
/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
require': cannot load such file -- bundler/setup (LoadError) from
/home/ev0lution/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
require' from /home/ev0lution/RailsP/ticketee/config/boot.rb:3:in
<top (required)>' from bin/rails:7:inrequire_relative' from
bin/rails:7:in `'
i havent even done anything with it yet only created 1 single test file and i need a controller for it.
Try run bundle install in your application. seems like some gem is missing. And if command still give similar error try run command with bundle exec.

Unable to run Rake tasks, ci_reporter dependency missing

I am unable to any rake tasks within my Rails project. Any attempt to do so results in the following error, stating that it cannot locate an rspec file for ci_reporter:
rake aborted!
LoadError: cannot load such file -- ci/reporter/rake/rspec
/Users/blake/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Users/blake/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
/Users/blake/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/blake/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Users/blake/workspaces/ruby/minestatus/Rakefile:6:in `<top (required)>'
/Users/blake/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
I have made the following attempts to reset my environment to a working state:
Installing the newest ci_reporter gem from github
Deleting Gemfile.lock and re-running bundle install
Reinstalling Ruby 2.0.0 using rvm
Unfortunately none of the above things have helped me solve this issue. I am able to run rake tasks in other Rails projects, but not in this one. Rake tasks used to run just fine, and I'm not sure what changes I could've made to break things. Does anyone have an idea of what I can do to get rake tasks to run properly again?

Error when generating Ruby on Rails scaffold

I am new to Ruby on Rails and I'm trying to go through a beginner's tutorial on how to produce a basic rails application. When trying to generate a scaffold, I get the following error:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:466:in routes': no >such file to load -- action_dispatch/routing/route_set (LoadError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:519:in >block in '
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/initializable.rb:30:in instance_exec'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/initializable.rb:30:inrun'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/initializable.rb:55:in block in run_initializers'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/initializable.rb:54:ineach'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/initializable.rb:54:in run_initializers'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/application.rb:96:ininitialize!'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/railtie/configurable.rb:30:in method_missing'
from C:/Users/Spi/Documents/Komodo Projects/movielib/config/environment.rb:5:in >'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/application.rb:83:in require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties->3.1.1/lib/rails/application.rb:83:inrequire_environment!'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands.rb:22:in ><top (required)>'
from script/rails:6:inrequire'
from script/rails:6:in `'
I have the Ruby 1.9.2 and Rails 3.1.1 versions installed on a PC running windows 7 64bit. The command I'm running is the following:
rails generate scaffold Scaff_test string:title
I am running this from the command prompt while being at the directory of the rails application that I have previously created. Any help would be greatly appreciated!
The error is related to routing. As part of generating required files, it will try to update the routes.rb ( which is under config/routes.rb ).
Please check it out if the file exists and if so check the file permission of the routes.rb

ruby on rails error rake db:create

I have been using ruby on rails fine no problem, now suddenly every time I run rake db:create I get the following errors:
C:\>cd xampp
C:\xampp>cd htdocs
C:\xampp\htdocs>cd what
C:\xampp\htdocs\what>rake db:create
rake aborted!
undefined method `task' for #<What::Application:0x20eb1e0>
(See full trace by running task with --trace)
C:\xampp\htdocs\what>
Any help please???
Here is all my cmd
C:\xampp\htdocs\comeon>rake db:create --trace
rake aborted!
undefined method `task' for #<Comeon::Application:0x211fb30>
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:215:
in `initialize_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:
in `load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:i
n `method_missing'
C:/xampp/htdocs/comeon/Rakefile:7:in `<top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `lo
ad'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `lo
ad_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:495:in `r
aw_load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:78:in `bl
ock in load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:129:in `s
tandard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:77:in `lo
ad_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:61:in `bl
ock in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:129:in `s
tandard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:59:in `ru
n'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'
C:/Ruby192/bin/rake:19:in `load'
C:/Ruby192/bin/rake:19:in `<main>'
This will help you.
gem uninstall rake
gem install rake -v 0.8.7
If Still the problem exists, uninstall rake and install using
gem uninstall rake
gem install rake
for more info
Undefined method 'task' using Rake 0.9.0
I was having the same problem, found a post by Jim Weirich in git hub that solved my problem
https://github.com/jimweirich/rake/issues/33#issuecomment-1213705
Two issues here: (1) dimitko's issue is that the built in rake command is being mixed with the new gem's library files. Arranging your $PATH environment list so that the gem version of rake has precendence over the built-in version should fix that. If you are using bundler, you might also want to try 'bundle exec rake'.
The second issue (mjansen401 and r00k above) is that the new version of rake does not put its DSL commands (task, file, desc, import, etc) in the root of the Object namespace anymore (placing them in Object meant every object has a task command, not very nice . The DSL commands are available by mixing in the Rake::DSL module into any module needing the commands.
Until rails is updated to work with Rake 0.9.x, put the following in your project Rakefile before the call to Application.load_tasks:
class Rails::Application
include Rake::DSL if defined?(Rake::DSL)
end
Let me know if these work for you.
Hope it helps

Resources