rails and rake commands freeze/hang - ruby-on-rails

I've recently updated an old application to from 3.2.13 to 4.2.10. I've got the application running in development mode but any rake or rails commands I try to run just hang/freeze. The terminal window will hang for a second and then nothing, I'm unable to even stop the process with ctrl-c. I've read a lot about running 'spring stop' to fix this but I don't have spring installed on this app.
Running the commands with --trace aren't particularly helpful.
rails generate model Foo --trace gives me nothing and rake db:migrate --trace gives me:
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
before freezing. Any pointers in the right direction would be appreciated.

Related

Starting resque workers while started development server

I want to start my workers when I start my development server to test the a new cron job I have in my resque scheduler, so I run this command when starting dev server-
QUEUE=* rake environment resque:work rails s
it has worked for me before and if I'm reading their documentation correctly should still work.
But I'm getting the following error after I interrupt it after it gets hung up-
^Crake aborted!
Don't know how to build task 'rails'
here is what I get after keyboard interrupt and running it with --trace
** Invoke environment (first_time)
** Execute environment
** Invoke resque:work (first_time)
** Invoke resque:preload (first_time)
** Invoke resque:setup (first_time)
** Invoke environment
** Execute resque:setup
** Execute resque:preload
** Invoke resque:setup
** Execute resque:work
^Crake aborted!
Don't know how to build task 'rails'
I don't understand why I would be getting the error and additionally why it previously loaded and worked but not anymore. What am I missing here?
Are you sure that you manage to run this command sometime back successfully
QUEUE=* rake environment resque:work rails s
because the way I know rails s is a list of rails command not a rake task
you can run consecutive rake separating spaces like
QUEUE=* rake environment rake1 rake2 rake3
but you cant run a rake and rails command they way you mention above
what I see from your trace above that rake(resque rake) is running now instead of passing a second rake you specified a rails command to start the server rake is considering that as rake task (which is not true)
I believe you are looking for this
QUEUE=* rake environment resque:work && rails s
But I dont believe that what you have mention would ever work please let me know if something conflict over here
Hope It make sense
This is better:
BACKGROUND=yes QUEUE=* PIDFILE=./tmp/resque.pid bundle exec rake environment resque:work
Then:
rails s
If you need stop resque worker:
kill -QUIT $(cat ./tmp/resque.pid)

stack level too deep - when using Rake

When i try and preform a rake I get the following. I've tried a few fixed like imploding and reinstalling my rvm - ruby (v1.9.3-p125) but nothing seems to be working. Any ideas?
rake db:seed --trace
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
rake aborted!
stack level too deep
/Users/rm/.rvm/gems/ruby-1.9.3-p125#global/gems/rake-0.9.2.2/lib/rake/task.rb:162
Tasks: TOP => db:seed
if I try and run a rake db:reset --trace
-- initialize_schema_migrations_table()
-> 0.0025s
-- assume_migrated_upto_version(20120803181844, ["/Users/rossmcnairn/rails/search/db/migrate"])
-> 0.0218s
** Invoke db:structure:load_if_sql (first_time)
** Invoke db:create
** Execute db:structure:load_if_sql
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
rake aborted!
stack level too deep
/Users/rossmcnairn/.rvm/gems/ruby-1.9.3-p125#global/gems/rake-0.9.2.2/lib/rake/task.rb:162
Tasks: TOP => db:setup => db:seed
Ive checked that my bundle exec version and my regular rake versions match.
rake --version
rake, version 0.9.2.2
bundle exec rake --version
rake, version 0.9.2.2
Any help would be greatly appreciated!
Updating OSX is known to give issues in rubies, you should recompile all your rubies:
chown -R $USER: $rvm_path
rvm get head
rvm reinstall 1.9.3-p125
rvm all-gesmsets do rvm gemset pristine
Also note that any other compiled stuff like libraries needs recompilation, this includes homebrew, macports, rvm pkg and any packages you have compiled manually.
** Execute db:abort_if_pending_migrations
rake aborted!
Did you try to run your migrations?
This may be obvious but it took me a few hours. I unwittingly created a class method for the model called create, which is the same as ActiveRecord create. So my seed file has circular reference.
I just kept staring at the seed file and wonder why I get the error while I was able to run it twice before (before adding the class method). Moral of the story: naming is important.

rake:db migrate isn't working

I'm trying to run a migration on my Rails app, by using rake:db migrate --trace and I get the following output:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
It then doesn't do anything after this. If I Ctrl + C I get some errors, but I'm not sure I understand them. Is there any way I can step through and debug the migration process so I can see when it hits the problem migration?
its (space between rake and db).
rake db:migrate
try for a overview of rake db tasks:
rake -T db
Try
bundle exec rake db:migrate --trace
I realized the reason this was not firing was it was initializing a sleep command waiting on something that wouldn't be initialized via rake (the app had to be running). So, rake was not the culprit this time!

Rake tasks on Rails 3.1.3 - Application already initialized

I'm unable to get rake precompile tasks running with Rails 3.1.3. I get the following error:
$ rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/tristankromer/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/tristankromer/.rvm/gems/ruby-1.9.2-p290#toomanyninjas/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
rake aborted!
Application has been already initialized.
/Users/tristankromer/.rvm/gems/ruby-1.9.2-p290#toomanyninjas/gems/railties-3.1.3/lib/rails/application.rb:95:in `initialize!'
Same thing happens when I used bundle exec or when I deploy to heroku cedar stack.
Not quite sure where to start on this one. Any ideas?
UPDATE: I'm having issues with every rake task:
rake aborted!
Application has been already initialized.
/Users/tristankromer/.rvm/gems/ruby-1.8.7-p249#joke-off/gems/railties-3.1.3/lib/rails/application.rb:95:in `initialize!'
Upgrading rake to 0.9.2.2 and using ruby 1.9.2-p290 seems to have fixed the issue.
I had this issue, I didn't want to upgrade ruby, and what ended up working for me was the renaming config.ru in RAILS_ROOT to config.ru.bak
http://code.google.com/p/phusion-passenger/issues/detail?id=109
I came across this after realizing I was having an issue getting Passenger to recognize the "RailsEnv" setting my my virtual hosts conf
I had this problem on Rails 3.2.6
The reason it was happening had to do with a path linked gem having a bundle folder. in my gemfile
like so:
gem 'some-gem', :path => "vendor/some-gem"
In order to fix the issue I just moved the bundle folder out of the path linked gem.
mv vendor/some-gem/bundle ~
Once the bundle file was gone it worked perfectly

Running two thinking sphinx

Ok so i have two rails application on my server and both apps use thinking sphinx and all seems good with one app. when i do
rake ts:start RAILS_ENV=production
Started successfully (pid 9943).
but when i do it on the other app i get
rake ts:start RAILS_ENV=production --trace
** Invoke ts:start (first_time)
** Invoke thinking_sphinx:start (first_time)
** Invoke thinking_sphinx:app_env (first_time)
** Execute thinking_sphinx:app_env
** Invoke environment (first_time)
** Execute environment
Jammit Warning: Asset compression disabled -- Java unavailable.
Jammit Warning: No assets match 'public/stylesheets/public.css'
** Execute thinking_sphinx:start
Failed to start searchd daemon. Check /var/www/projects/log/searchd.log.
Failed to start searchd daemon. Check /var/www/projects/log/searchd.log
** Execute ts:start
they are both using different ports....any idea...also i checked the log file here /var/www/projects/log/searchd.log and its blank ...any idea what to do...i have tried almost everything
rake ts:start starts your sphinx daemon. If you want your apps to share the same search engine, you should only do ts:start once. and both apps should work.

Resources