ruby on rails error rake db:create - ruby-on-rails

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

Related

rake routes command is not working

I have run this rake routes command in terminal but not working, But it's working few days back. Please check it
jaskaran#jaskaran-Vostro-1550:~/rails_project$ rake routes
rake aborted!
Gem::LoadError: You have already activated rake 10.3.2, but your Gemfile requires rake 10.2.2. Prepending `bundle exec` to your command may solve this.
/home/jaskaran/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.6.1/lib/bundler/runtime.rb:34:in `block in setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.6.1/lib/bundler/runtime.rb:19:in `setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.6.1/lib/bundler.rb:120:in `setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.6.1/lib/bundler/setup.rb:7:in `<top (required)>'
/home/jaskaran/rails_project/config/boot.rb:4:in `<top (required)>'
/home/jaskaran/rails_project/config/application.rb:1:in `<top (required)>'
/home/jaskaran/rails_project/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/jaskaran/rails_project/config/boot.rb:4:in `<top (required)>'
/home/jaskaran/rails_project/config/application.rb:1:in `<top (required)>'
/home/jaskaran/rails_project/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Try running bundle exec rake routes to ensure the proper version of Rake gets loaded.
You need to update your gems to the latest available versions: bundle update
Rake versions seems to be different. So, run it as bundle exec rake routes. It should be working.
The correct solution to your problem is to use bundle exec, as suggested by others, to load the version of Rake which your app expects. You may also wish to avoid needing to always run Rake commands with bundle exec. You can either
1) [Recommended] Update your app to use the same version of rake as you have running globally (10.3.2, which is the latest version)
or
2) [Not really recommended] Uninstall version 10.3.2 (actually, any version greater than the one you want) from your global gems and install version 10.2.2 (which your app is currently using)
rvm #global do gem uninstall rake
rvm #global do gem install rake --version 10.2.2
See RVM documentation for global gemsets

Dropping the database in Rails

~/Rails Projects/QA-app$ rake db:drop
rake aborted!
Gem::LoadError: You have already activated rake 10.3.2, but your Gemfile requires rake 10.1.1. Using bundle exec may solve this.
/home/salmanalam/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup'
/home/salmanalam/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
/home/salmanalam/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/home/salmanalam/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.3.5/lib/bundler/setup.rb:7:in `<top (required)>'
/home/salmanalam/Rails Projects/QA-app/config/boot.rb:4:in `<top (required)>'
/home/salmanalam/Rails Projects/QA-app/config/application.rb:1:in `<top (required)>'
/home/salmanalam/Rails Projects/QA-app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Run the command using bundle exec(bundle exec rake db:drop) to force the version of rake that is used by your application.
Just run `bundle update and update your app. The version of Rake that it is looking for is 10.1.1 but your version of Rake has already been updated to 10.3.2
You can't just go updating all gems willy nilly on a larger project without running into problems. If you don't want to have to prefix bundle exec, then just run bundle update rake.
This is what worked for me:
rm -rf Gemfile.lock
Then run bundle install if needed, and rake db:(whatever) goes without error.

Rails 3.2: rake 10.0.3 required

When executing any rake operation, I get the following:
rake aborted!
You have already activated rake 10.1.0, but your Gemfile requires rake 10.0.3. Using bundle exec may solve this.
/home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/runtime.rb:33:in `block in setup'
/home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/runtime.rb:19:in `setup'
/home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler.rb:120:in `setup'
/home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/setup.rb:7:in `<top (required)>'
/home/cristi/code/kodion/config/boot.rb:6:in `<top (required)>'
/home/cristi/code/kodion/config/application.rb:1:in `<top (required)>'
/home/cristi/code/kodion/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
I am not sure what I can do to solve this. bundle exec doesn't solve anything.
You either need to run the command in the context of the bundle (recommended):
> bundle exec rake db:version
Or you need to uninstall the offending rake gem version.
> gem uninstall rake
> # pick version 10.1.0 from the offered choices.
I ran into this same type of error. Try this:
bundle exec rake db:migrate

redmine upgrade

at the moment I want to upgrade redmine 1.4.0 to the latest version 2.0.2.
So I followed the howto on this page:
http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade
In short I downloaded the redmine-source and extracted it in a separate folder
"/var/www/redmine-2.0.2"
(whereas my working installation is in /var/www/redmine).
up to Step 3.5 everything went fine but in 3.6
the following happens:
root(at)information:/var/www/redmine-2.0.2# rake config/initializers/session_store.rb
rake aborted!
Don't know how to build task 'config/initializers/session_store.rb'
(See full trace by running task with --trace)
root(at)information:/var/www/redmine-2.0.2# rake --trace
config/initializers/session_store.rb
rake aborted!
Don't know how to build task 'config/initializers/session_store.rb'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/task_manager.rb:49:in `[]'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:115:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake -
0.9.2.2/lib/rake/application.rb:94:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:88:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:66:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top
(required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake --trace generate_session_store
Invoke generate_session_store (first_time)
Invoke generate_secret_token (first_time)
Invoke config/initializers/secret_token.rb (first_time)
Execute config/initializers/secret_token.rb
Execute generate_secret_token
Execute generate_session_store
Note: The rake task generate_session_store has been deprecated, please use the
replacement version generate_secret_token
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake generate_session_store
Note: The rake task generate_session_store has been deprecated, please use the
replacement version generate_secret_token
root(at)information:/var/www/redmine-2.0.2# rake --trace generate_secret_token
Invoke generate_secret_token (first_time)
Invoke config/initializers/secret_token.rb (first_time, not_needed)
Execute generate_secret_token
this last step seems to generate "/var/www/redmine-2.0.2/config/initializers/secret_token.rb"
and according to the how to it is a sufficient substitute to the "rake-commands" before.
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake db:migrate RAILS_ENV=production
root(at)information:/var/www/redmine-2.0.2# rake tmp:cache:clear
root(at)information:/var/www/redmine-2.0.2# rake tmp:sessions:clear
My first prob is how to start the application. I can still go to my old installation "/var/www/redmine"
and start with
ruby ./script/server -e production &
which still works, the output is:
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-
2.3.14/lib/active_support/inflector.rb:3:in `<top (required)>': iconv will be deprecated
in the future, use String#encode instead.
=> Booting Mongrel
=> Rails 2.3.14 application starting on http://0.0.0.0:3000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after
2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-
2.3.14/lib/rails/gem_dependency.rb:21.
=> Call with -d to detach
=> Ctrl-C to shutdown server
But I can't start the application by going to the new folder "/var/www/redmine-2.0.2/"
and calling
ruby ./script/server -e production &
because there is no file
"/var/www/redmine-2.0.2/script/server".
How can I start the updated version of redmine or is not possible yet ?
I think redmine 2.0.2 needs rails 3.2.5 and I thought I installed
it because:
root(at)information:/var/www/redmine-2.0.2/script# rails -v
Rails 3.2.5
root(at)information:/var/www/redmine-2.0.2/script#
According to the boot protocol above Rails 2.3.14 is used. Wrong ?
Whats my mistake here ? Can somebody give advice howto
succesfully upgrade ?
thanks for your help in advance!
Cheers,
Ansgar
Solve it by using bundle exec rails s -d -e production to start the application in background using the default port (i.e. 3000).
Update
It seems to be an RVM issue, if you open a new shell and running:
$ type rvm | head -1
does not show "rvm is a function", RVM isn't being sourced correctly.
Ensure that RVM is sourced after any path settings as RVM and manipulates the path. If you don't do this, RVM may not work as expected.

RVM setup, rake::doc, and "rake aborted! no such file to load -- initializer"

So I've wanted to install RVM for a while on OSX. I finally got it working after figuring out I had to download the latest XCode. I installed ruby 1.9.2 and used these commands to create a new gemset in rvm:
rvm gemset create rails235
rvm 1.9.2#rails235
gem install rails -v 2.3.5
Then I went into one of my old apps that used rails 2.3.5 and tried to run some rakes and any rake I run I seem to get this error:
rake aborted!
no such file to load -- initializer
Also, semi related, right now I'm trying to get rdoc setup. I've never used before and I'm typing in "rake doc::app" and I'm getting that same error.
The full rake with --trace is this:
$ rake doc::app
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
Don't know how to build task 'doc::app'
(See full trace by running task with --trace)
brenton-wejrowskis-macbook-pro-2:bizzark wejrowski$ rake doc::app --trace
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
Don't know how to build task 'doc::app'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/task_manager.rb:49:in `[]'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:111:in `invoke_task'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/bin/rake:19:in `load'
/Users/wejrowski/.rvm/gems/ruby-1.9.2-p180#global/bin/rake:19:in `<main>'
No idea what to do next!
Your rake doc::app error is most probably due to the fact that rake tasks only use a single colon (":") to separate namespaces and task names. Try running rake doc:app instead.

Resources