Precompiling assets with capistrano gives error during deployment - ruby-on-rails

I am trying to deploy my rails app to a digital ocean server using the capistrano gem, and I'm getting the error :
The deploy has failed with an error: #<SSHKit::Command::Failed: RAILS_ENV= bundle exec rake assets:precompile exit status: 256
RAILS_ENV= bundle exec rake assets:precompile stdout: Nothing written
RAILS_ENV= bundle exec rake assets:precompile stderr: rake aborted!
ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter
Even though the local config/database.yml and shared/config/database.yml file on the server are both configured, and have production databases set.
In case I run the rake db:create command on the server, it does create the database successfully. So, can't really find the issue.
Using rails 4.0.2, ruby 2.1.0, capsitrano 3.1.0

Sorry - I don't have the rep to comment.
It's a bit short on detail about your deploy configuration, you probably need to share.
RAILS_ENV= bundle exec rake assets:precompile stdout: Nothing written
Would suggest to me that there is no RAILS_ENV set. I don't think there is an issue with the database .yml
Infact - this post might be relevant: Capistrano 3, Rails 4, database configuration does not specify adapter

Related

rails4 rake assets precompile in production environment generate wrong javascript file

I'm working on deploy my rails application and I found that error always exists in my javascript file when I run RAILS_ENV=production bundle exec rails assets:precompile.But when I run rails assets:precompile to generate js file, it works well.Is there any differences between production and development in precompile phase? How can I solve this problem?
I think you don't have permission to generate compiled javascript file, to trace your error, run the following command:
RAILS_ENV=production bundle exec rails assets:precompile --trace
Solution of permission issue:
Try to run the command as sudo as the following:
sudo RAILS_ENV=production bundle exec rails assets:precompile --trace

Delayed Job in Rails 4 with Capistrano

I cant figure how to start Delayed Jobs on a dedicated Ubuntu server.
It works fine on my localhost but when I run on my server
sudo RAILS_ENV=production bin/delayed_job restart
I get
sudo: bin/delayed_job: command not found
On top of that, if I run the "rake jobs:work RAILS_ENV=production" command Im getting the following error:
PG::FeatureNotSupported: ERROR: SELECT FOR UPDATE/SHARE is not allowed in subqueries
Apparently theres an issue with my psql version.
Is there any way I can get the script to work? Any effective Capistrano recipes available? All ive found on the web are old recipes for Rails 3 and older versions of capistrano.
Thanks in advance.
EDIT:
I have already bundled install the daemons gem and generated "delayed_job:active_record" on my local machine, then proceded to cap deploy which bundle installed and migrated in the production server.
The bin/delayed_job file exists in the server yet it fails with command not found.
And add this to config/environment.rb:
ENV['RAILS_ENV'] ||= 'production'
Then at your production server:
RAILS_ENV=production rake db:migrate
RAILS_ENV=test production generate delayed_job:active_record && RAILS_ENV=production rake db:migrate
Now after you do that:
RAILS_ENV=production script/delayed_job start
As for Capistrano error you are facing, please try to add the command like:
run "cd #{current_path}; #{sudo} RACK_ENV=production bundle exec #{current_path}/bin/delayed_job start"
You must run this on target server:
bundle exec rails generate delayed_job

Rake aborted! uninitialized constant knowit

I am standing up a new Ubuntu server running MySQL. I have Capistrano set up on my development server and am trying to deploy:cold after running deploy:setup. After the deploy script tries to run
executing "cd /home/adm1n/www/knowit/releases/20121112152400 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
I keep getting this message:
Rake Aborted!
uninitialized constant knowit
Tasks: TOP => environment
Any idea where this constant would be defined? This project is almost entirely new (rails new app Blah). Any suggestions on how I should attempt to troubleshoot this? Thx.
I'm running:
Rake 0.9.2.2
Ruby 1.9.3p194
Capistrano 2.13.5
Bundler 1.1.5
Rails 3.2.8
rvm 1.15.7
UPDATE: knowit is the name of my app. So there apparently there is something not initializing. Not sure where how to troubleshoot this.
UPDATE: Here is my routes.rb file (very basic)
Knowit::Application.routes.draw do
match ':controller(/:action(/:id))(.:format)'
end

Rails 3.1 to 3.2.6 upgrade - asset_sync error

Making lots of progress in a rails 3.1 to 3.2.6 upgrade for a Heroku app.
I use asset_sync and precompile assets onto S3. I use the asset_sync.rb initialiser to config my S3 connection details.
Getting an error when I attempt to run
RAILS_ENV=production bundle exec rake assets:precompile
AssetSync: using /Users/bob/work/myapp/config/initializers/asset_sync.rb
rake aborted!
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/Users/bob/.rvm/rubies/ruby-1.9.3-p...]
That's very strange. I checked that it is listening as per Postgres permission denied on MAC OS X that question and related comments.
this isn't an error with asset_sync, but the asset precompile process itself (specifically on heroku) try config.assets.initialize_on_precompile = false in your production or application.rb
What this will do is make sure your application code does not get initialized unnecessarily, which at precompile time, your heroku database my not be available.
Also it's not an issue with just Rails 3.2.6 but 3.2.x I believe.

heroku rake db:migrate aborting

heroku rake db:migrate
rake aborted!
no such file to load -- acts_as_ferret
(See full trace by running task with --trace)
(in /disk1/home/slugs/310513_b4b7e61_4c01/mnt)
It show this message issue. how do I fixes this?
add gem in your gem file "acts_as_ferret"
bundle install
run heroku run rake db:migrate
Add the gem act_as_ferret gem.
But seems complicated in heroku environement without ferret.

Resources