Rails 3.2.13 - application.css isn't precompiled - ruby-on-rails

The error I am getting on the main page is:
We're sorry, but something went wrong.
The error I am getting in the log file (log/production.log):
ActionView::Template::Error (application.css isn't precompiled):
2: <html>
3: <head>
4: <title>Reach</title>
5: <%= stylesheet_link_tag "application", media: "all" %>
6: <%= requirejs_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___2601724748379559821_29475380'
I have looked at this:
rails 3.1.0 ActionView::Template::Error (application.css isn't precompiled)
bundle exec rake assets:precompile
In console it shows:
/usr/local/rvm/rubies/ruby-1.9.3-p429/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p429/bin/rake requirejs:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
/usr/local/rvm/rubies/ruby-1.9.3-p429/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p429/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
I get the same error
Any suggestions?
UPDATE
I traced the precompile, this is the results:
** Invoke assets:precompile (first_time)
** Invoke requirejs:precompile:external (first_time)
** Invoke requirejs:test_node (first_time)
** Execute requirejs:test_node
** Execute requirejs:precompile:external
/usr/local/rvm/rubies/ruby-1.9.3-p429/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p429/bin/rake requirejs:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke requirejs:precompile:all (first_time)
** Invoke requirejs:precompile:prepare_source (first_time)
** Invoke requirejs:setup (first_time)
** Invoke assets:environment (first_time)
** Invoke requirejs:precompile:disable_js_compressor (first_time)
** Execute requirejs:precompile:disable_js_compressor
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute requirejs:setup
** Invoke requirejs:clean (first_time)
** Invoke requirejs:setup
** Execute requirejs:clean
** Execute requirejs:precompile:prepare_source
** Invoke requirejs:precompile:generate_rjs_driver (first_time)
** Invoke requirejs:setup
** Execute requirejs:precompile:generate_rjs_driver
** Invoke requirejs:precompile:run_rjs (first_time)
** Invoke requirejs:setup
** Invoke requirejs:test_node (first_time)
** Execute requirejs:test_node
** Execute requirejs:precompile:run_rjs
** Invoke requirejs:precompile:digestify_and_compress (first_time)
** Invoke requirejs:setup
** Execute requirejs:precompile:digestify_and_compress
** Execute requirejs:precompile:all
** Execute assets:precompile
/usr/local/rvm/rubies/ruby-1.9.3-p429/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p429/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
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
** Invoke assets:precompile:nondigest (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:nondigest
UPDATE 2
Everything was working, I needed to touch tmp/restart.txt to restart Rails after my precompiling.

Try RAILS_ENV=production bundle exec rake assets:precompile
http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

Okay, I realized I didn't mention above, but I am new to RoR. I am adding this here in case anyone runs into the same easy mistake I did.
I had to
touch tmp/restart.txt
After precompiling.

Related

First capistrano deploy does't make any effect

how is it going? I have a Rails 4 app and I'm trying to deploy it with capistrano 3 on my server.
I already installed with bundle install and cap install, generating the files. I already added my info com deploy.rb file and when I run the command for the first deploy, it doesn't print the log on my console and do any effect.
usuario$ cap production deploy
usuario$
I ran this command with the --trace to see more details:
usuario$ cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:hook (first_time)
** Invoke passenger:rvm:hook (first_time)
** Invoke passenger:test_which_passenger (first_time)
** Execute passenger:test_which_passenger
** Execute passenger:rvm:hook
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
** Invoke bundler:map_bins (first_time)
** Invoke passenger:bundler:hook (first_time)
** Execute passenger:bundler:hook
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
** Execute git:check
** Invoke deploy:check:directories (first_time)
** Execute deploy:check:directories
** Invoke deploy:check:linked_dirs (first_time)
** Execute deploy:check:linked_dirs
** Invoke deploy:check:make_linked_dirs (first_time)
** Execute deploy:check:make_linked_dirs
** Invoke deploy:check:linked_files (first_time)
** Execute deploy:check:linked_files
** Invoke deploy:set_previous_revision (first_time)
** Execute deploy:set_previous_revision
** Invoke deploy:started (first_time)
** Execute deploy:started
** Invoke deploy:updating (first_time)
** Invoke deploy:new_release_path (first_time)
** Execute deploy:new_release_path
** Execute deploy:updating
** Invoke git:create_release (first_time)
** Invoke git:update (first_time)
** Invoke git:clone (first_time)
** Invoke git:wrapper
** Execute git:clone
** Execute git:update
** Execute git:create_release
** Invoke deploy:set_current_revision (first_time)
** Execute deploy:set_current_revision
** Invoke git:set_current_revision (first_time)
** Execute git:set_current_revision
** Invoke deploy:symlink:shared (first_time)
** Execute deploy:symlink:shared
** Invoke deploy:symlink:linked_files (first_time)
** Execute deploy:symlink:linked_files
** Invoke deploy:symlink:linked_dirs (first_time)
** Execute deploy:symlink:linked_dirs
** Invoke deploy:updated (first_time)
** Invoke bundler:install (first_time)
** Execute bundler:install
** Execute deploy:updated
** Invoke deploy:compile_assets (first_time)
** Invoke deploy:set_rails_env
** Execute deploy:compile_assets
** Invoke deploy:assets:precompile (first_time)
** Execute deploy:assets:precompile
** Invoke deploy:assets:backup_manifest (first_time)
** Execute deploy:assets:backup_manifest
** Invoke deploy:cleanup_assets (first_time)
** Invoke deploy:set_rails_env
** Execute deploy:cleanup_assets
** Invoke deploy:normalize_assets (first_time)
** Invoke deploy:set_rails_env
** Execute deploy:normalize_assets
** Invoke deploy:migrate (first_time)
** Invoke deploy:set_rails_env
** Execute deploy:migrate
** Invoke deploy:publishing (first_time)
** Execute deploy:publishing
** Invoke deploy:symlink:release (first_time)
** Execute deploy:symlink:release
** Invoke deploy:restart (first_time)
** Execute deploy:restart
** Invoke passenger:restart (first_time)
** Execute passenger:restart
** Invoke deploy:published (first_time)
** Execute deploy:published
** Invoke deploy:finishing (first_time)
** Execute deploy:finishing
** Invoke deploy:cleanup (first_time)
** Execute deploy:cleanup
** Invoke deploy:finished (first_time)
** Execute deploy:finished
** Invoke deploy:log_revision (first_time)
** Execute deploy:log_revision
usuario$
...and anything was created on the server (current and release folder).
Any ideas what I'm doing wrong? I appreciate any clue.
EDIT
That is my deploy.rb
# config valid only for current version of Capistrano
lock '3.5.0'
set :application, 'my_app_name'
set :repo_url, 'my_user#my_server_ip:/my_path_to/app_repo.git'
set :deploy_to, "/var/www/my_app_name"
set :default_stage, "production"
set :linked_files, fetch(:linked_files, []).push('config/database.yml')
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')
set :keep_releases, 3
set :default_env, { rvm_bin_path: '~/.rvm/bin' }

Assets compile failed with out of memory

I try to compile assets on the production server, but when I run rake task with compile - process goes too long and I get error with memory out.There is trace
RAILS_ENV=production rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke bower:before_precompile (first_time)
** Execute bower:before_precompile
** Execute assets:precompile
rake aborted!
ExecJS::RuntimeError: FATAL ERROR: Evacuation Allocation failed - process out of memory
(execjs):1
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:219:in `exec_runtime'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:39:in `exec'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:21:in `eval'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:46:in `call'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/uglifier-2.7.1/lib/uglifier.rb:212:in `run_uglifyjs'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/uglifier-2.7.1/lib/uglifier.rb:179:in `compile'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/uglifier_compressor.rb:52:in `call'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/uglifier_compressor.rb:28:in `call'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/home/ubuntu/staging/releases/21/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
I also try run this with config.assets.compile = false but I get same error, how I can fix it?
sorry for my bad English

Assets precompile fails on EC2: can't find jQuery

I'm configuring a new production deployment setup with a skeleton rails app, which I just generated using rails new with Rails 3.2.8. I have a production setup on my dev machine with apache2 and Phusion Passenger, which all works fine. When I try to push that configuration to EC2, the assets precompile step fails because it can't find jQuery.
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'capistrano'
gem 'jquery-rails'
gem 'haml'
group :assets do
gem 'less-rails'
gem 'uglifier', '>= 1.0.3'
gem 'therubyracer'
gem 'execjs'
end
group :deploy do
gem 'passenger'
end
group :production do
gem 'bigdecimal'
end
Relevant bit of deploy.rb
after "deploy:update_code" do
run "cd #{release_path}; rake assets:precompile RAILS_ENV=production "
end
Output
triggering after callbacks for `deploy:update_code'
* executing "cd /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; rake assets:precompile RAILS_ENV=production"
servers: ["bww-test"]
[bww-test] executing command
** [out :: bww-test] /usr/bin/ruby1.9 /usr/local/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
** [out :: bww-test]
** [out :: bww-test] rake aborted!
** [out :: bww-test]
** [out :: bww-test] couldn't find file 'jquery'
** [out :: bww-test] (in /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008/app/assets/javascripts/application.js:13)
** [out :: bww-test]
** [out :: bww-test]
** [out :: bww-test] Tasks: TOP => assets:precompile:primary
** [out :: bww-test]
** [out :: bww-test] (See full trace by running task with --trace)
** [out :: bww-test]
** [out :: bww-test] rake aborted!
** [out :: bww-test] Command failed with status (1): [/usr/bin/ruby1.9 /usr/local/bin/rake asset...]
** [out :: bww-test]
** [out :: bww-test] Tasks: TOP => assets:precompile
** [out :: bww-test] (See full trace by running task with --trace)
command finished in 1819ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; true"
servers: ["bww-test"]
[bww-test] executing command
command finished in 168ms
failed: "sh -c 'cd /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; rake assets:precompile RAILS_ENV=production'" on bww-test
If I look on the server, the bundle including jQuery has been installed by Capistrano:
[ec2-user#ip-10-226-122-140 bw-widget]$ find . -name jquery\*
./shared/bundle/ruby/1.9.1/specifications/jquery-rails-2.1.3.gemspec
./shared/bundle/ruby/1.9.1/cache/jquery-rails-2.1.3.gem
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/jquery-rails.gemspec
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/generators/jquery
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/jquery
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/jquery-rails.rb
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery_ujs.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery-ui.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery.min.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery-ui.min.js
./shared/bundle/ruby/1.9.1/gems/rdoc-3.12/lib/rdoc/generator/template/darkfish/js/jquery.js
I'm slightly puzzled that the gems are in ruby/1.9.1 when I'm actually using 1.9.3p0 (the yum install version, not the rvm version), but I don't know if that is significant.
Update
Following a comment from Said, I changed the after update task to:
after "deploy:update_code" do
run "cd #{release_path}; bundle exec rake assets:precompile RAILS_ENV=production "
end
However, none of the documents I've read have suggested that bundle exec should be necessary, so I'm still concerned that while I have a work-around, something still isn't quite configured right.

Getting "stack level too deep" error when deploying with Capistrano, Rails 3.1 ruby 1.9.2

Here is the log for the cap deploy script output around where the error occurs. Anny suggestions why this might be happening? Thanks!
[yup.la] executing command
[yup.la] sh -c 'cd /srv/www/portrait/releases/20120406051647 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'
** [out :: yup.la] rake aborted!
** [out :: yup.la]
** [out :: yup.la] stack level too deep
** [out :: yup.la] (in /srv/www/portrait/releases/20120406051647/app/assets/stylesheets/mobile.css.scss)
** [out :: yup.la]
** [out :: yup.la] Tasks: TOP => assets:precompile:primary
** [out :: yup.la] (See full trace by running task with --trace)
** [out :: yup.la]
command finished in 30868ms
*** [deploy:update_code] rolling back
* executing "rm -rf /srv/www/portrait/releases/20120406051647; true"
servers: ["yup.la"]
[yup.la] executing command
[yup.la] sh -c 'rm -rf /srv/www/portrait/releases/20120406051647; true'
command finished in 288ms
failed: "sh -c 'cd /srv/www/portrait/releases/20120406051647 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on yup.la
/Users/victorstan/Sites/portrait ∴
Try to change your sass-rails version from 3.1.5 to 3.1.4 in your Gemfile.

Rakefile not getting deployed with capistrano

I am getting this error when deploying with capistrano:
executing "cd /opt/my_app/dev/releases/20100103021722; rake RAILS_ENV=staging db:migrate"
servers: ["96.30.33.84"]
[96.30.33.84] executing command
** [out :: 96.30.33.84] rake aborted!
** [out :: 96.30.33.84]
** [out :: 96.30.33.84] No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
** [out :: 96.30.33.84]
** [out :: 96.30.33.84] /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2377:in `raw_load_rakefile'
** [out :: 96.30.33.84]
** [out :: 96.30.33.84] (See full trace by running task with --trace)
** [out :: 96.30.33.84]
It randomly just started occurring. I found out the problem was that my new deploys are missing my rake file...however I am deploying from my staging branch and I can confirm that my staging branch has the Rakefile. Somehow it's not getting deployed. Does anyone know how to troubleshoot this?
I assume that you are using some sort of vcs (svn/git/etc.), have the files been ignored by the repo, ie. they aren't getting deployed with the app, thus not showing up on staging?

Resources