Rails: how to debug assets:precompile failure on cap deploy - ruby-on-rails

I'm getting a cryptic error on cap deploy
$ cap deploy
. . .
* executing "cd -- /rails/myapp/releases/20130919002235 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile"
servers: ["persephone"]
[persephone] executing command
. . .
** [out :: persephone] rake aborted!
** [out :: persephone] Caught Encoding::CompatibilityError at '["ok","(function() {': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)
** [out :: persephone] (in /rails/myapp/releases/20130919002235/app/assets/javascripts/disk_files.js.coffee)
** [out :: persephone] /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/pure/parser.rb:242:in `rescue in parse_string'
** [out :: persephone] /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/pure/parser.rb:213:in `parse_string'
** [out :: persephone] /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/pure/parser.rb:257:in `parse_value'
** [out :: persephone] /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/pure/parser.rb:121:in `parse'
** [out :: persephone] /rails/myapp/shared/bundle/ruby/2.0.0/gems/json-1.8.0/lib/json/common.rb:155:in `parse'
. . .
In trying to debug the problem I've tried completely removing disk_files.js.coffee and then the same error occurs for application.js.
I've then changed my application.js manifest so that it doesn't require anything and then I get a similar error for application.css
I've commented out my custom css and now I get:
** [out :: persephone] rake aborted!
** [out :: persephone] undefined method `[]' for nil:NilClass
** [out :: persephone] (in /rails/myapp/releases/20130919200133/app/assets/stylesheets/application.css)
** [out :: persephone] /rails/myapp/shared/bundle/ruby/2.0.0/gems/sprockets-2.10.0/lib/sprockets/sass_functions.rb:63:in `sprockets_context'
Each of these steps requires a git commit to origin and then a cap deploy.
FWIW- adding #encoding: UTF-8 as per SO#9857443 doesn't help.
Anyone know what's going on? How can I debug this?

Related

Error while deploying on a staging server

I just reinstalled my staging server and I can't deploy my code. I installed pgsql and libpq-dev on the Ubuntu server 16.04 that I use. The file /srv/outils/www/projectname/shared/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg_ext.so do exist.
Here is the error I encounter :
executing "cd -- /srv/outils/www/projectname/releases/20171119230417 && RAILS_ENV=prodtest RAILS_GROUPS=assets bundle exec rake assets:precompile"
servers: ["**.**.**.**"]
[**.**.**.**] executing command
** [out :: **.**.**.**] rake aborted!
** [out :: **.**.**.**]
** [out :: **.**.**.**] LoadError: libruby.so.2.3: cannot open shared object file: No such file or directory - /srv/outils/www/projectname/shared/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg_ext.so
** [out :: **.**.**.**]
** [out :: **.**.**.**] /srv/outils/www/projectname/shared/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg.rb:4:in `require'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /srv/outils/www/projectname/shared/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg.rb:4:in `<top (required)>'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /var/lib/gems/2.3.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:81:in `require'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /var/lib/gems/2.3.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /var/lib/gems/2.3.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:76:in `each'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /var/lib/gems/2.3.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:76:in `block in require'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /var/lib/gems/2.3.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:65:in `each'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /var/lib/gems/2.3.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:65:in `require'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /var/lib/gems/2.3.0/gems/bundler-1.16.0/lib/bundler.rb:114:in `require'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /srv/outils/www/projectname/releases/20171119230417/config/application.rb:11:in `<top (required)>'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /srv/outils/www/projectname/releases/20171119230417/Rakefile:6:in `require'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /srv/outils/www/projectname/releases/20171119230417/Rakefile:6:in `<top (required)>'
** [out :: **.**.**.**]
** [out :: **.**.**.**] /srv/outils/www/projectname/shared/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
** [out :: **.**.**.**]
** [out :: **.**.**.**] (See full trace by running task with --trace)
** [out :: **.**.**.**]
command finished in 2861ms
*** [deploy:update_code] rolling back
I checked all I could think of. It's the same error if I do manually the capistrano commands in the server.
I was fixated on pg_est.so, but what I was missing was libruby.so.2.3
I uninstalled my ruby and reinstalled it, and now this step works.

trying to deploy to DO with capistrano. got an error when cap deploy:cold

executing "cd --
/home/harris/harrisrobin.co/releases/20140128225905 &&
RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake
assets:precompile"
servers: ["198.199.122.209"]
[198.199.122.209] executing command ** [out :: 198.199.122.209] rake aborted! ** [out :: 198.199.122.209] ** [out ::
198.199.122.209] Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available
runtimes. ** [out :: 198.199.122.209] ** [out :: 198.199.122.209]
/home/harris/harrisrobin.co/shared/bundle/ruby/2.0.0/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in
autodetect' ** [out :: 198.199.122.209] ** [out ::
198.199.122.209] /home/harris/harrisrobin.co/shared/bundle/ruby/2.0.0/gems/execjs-2.0.2/lib/execjs.rb:5:in
' ** [out :: 198.199.122.209] ** [out ::
198.199.122.209] /home/harris/harrisrobin.co/shared/bundle/ruby/2.0.0/gems/execjs-2.0.2/lib/execjs.rb:4:in
<top (required)>' ** [out :: 198.199.122.209] ** [out ::
198.199.122.209] /home/harris/harrisrobin.co/shared/bundle/ruby/2.0.0/gems/uglifier-2.4.0/lib/uglifier.rb:3:in
require' ** [out :: 198.199.122.209] ** [out :: 198.199.122.209]
/home/harris/harrisrobin.co/shared/bundle/ruby/2.0.0/gems/uglifier-2.4.0/lib/uglifier.rb:3:in
<top (required)>' ** [out :: 198.199.122.209] ** [out ::
198.199.122.209] /home/harris/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in
require' ** [out :: 198.199.122.209] ** [out :: 198.199.122.209]
/home/harris/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in
block (2 levels) in require' ** [out :: 198.199.122.209] ** [out
:: 198.199.122.209]
/home/harris/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in
each' ** [out :: 198.199.122.209] ** [out :: 198.199.122.209]
/home/harris/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in
block in require' ** [out :: 198.199.122.209] ** [out ::
198.199.122.209] /home/harris/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in
each' ** [out :: 198.199.122.209] ** [out :: 198.199.122.209]
/home/harris/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in
require' ** [out :: 198.199.122.209] ** [out :: 198.199.122.209]
/home/harris/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler.rb:131:in
require' ** [out :: 198.199.122.209] ** [out :: 198.199.122.209]
/home/harris/harrisrobin.co/releases/20140128225905/config/application.rb:7:in
<top (required)>' ** [out :: 198.199.122.209] ** [out ::
198.199.122.209] /home/harris/harrisrobin.co/releases/20140128225905/Rakefile:4:in
require' ** [out :: 198.199.122.209] ** [out :: 198.199.122.209]
/home/harris/harrisrobin.co/releases/20140128225905/Rakefile:4:in
`' ** [out :: 198.199.122.209] ** [out ::
198.199.122.209] (See full trace by running task with --trace) ** [out :: 198.199.122.209]
command finished in 2183ms
* [deploy:update_code] rolling back * executing "rm -rf /home/harris/harrisrobin.co/releases/20140128225905; true"
servers: ["198.199.122.209"]
[198.199.122.209] executing command
command finished in 354ms failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'default' -c 'cd --
/home/harris/harrisrobin.co/releases/20140128225905 &&
RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake
assets:precompile'" on 198.199.122.209
Any ideas ? I have no clue what this means :
command finished in 354ms failed: "rvm_path=$HOME/.rvm
$HOME/.rvm/bin/rvm-shell 'default' -c 'cd --
I am following this guide and got stuck at cap deploy:cold :
https://coderwall.com/p/yz8cha
It seems like you're missing JavaScript runtime library. Install NodeJS on the server using this:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Also, for rails deployments on DO and Ubuntu in general, this is a great resource for all the steps (and a video walkthrough):
https://gorails.com/deploy/ubuntu/14.04

deploy capistrano ruby 2.0

what it means, when i deploy my project i have error :
** transaction: commit
* 2014-01-10 15:52:54 executing `deploy:bundle'
* executing "cd /var/www/current; bundle install"
servers: ["10.3.27.72"]
[10.3.27.72] executing command
** [out :: 10.3.27.72] /home/shibanov/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0) among 0 total gem(s) (
** [out :: 10.3.27.72] Gem::LoadError)
** [out :: 10.3.27.72] from /home/shibanov/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
** [out :: 10.3.27.72] from /home/shibanov/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
** [out :: 10.3.27.72] from /home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin/bundle:22:in `<main>'
** [out :: 10.3.27.72] from /home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin/ruby_executable_hooks:15:in `eval'
** [out :: 10.3.27.72] from /home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin/ruby_executable_hooks:15:in `<main>'
command finished in 41ms
failed: "env PATH=/home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin:/home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin:/home/shibanov/.rvm/rubies/ruby-2.0.0-p195/bin:/home/shibanov/.rvm/bin:$PATH RUBY_VERSION=ruby-2.0.0-p195 GEM_HOME=/home/shibanov/.rvm/gems/uby-2.0.0-p195#sprut GEM_PATH=/home/shibanov/.rvm/gems/uby-2.0.0-p195#sprut:/home/shibanov/.rvm/gems/uby-2.0.0-p195#sprut BUNDLE_PATH=/home/shibanov/.rvm/gems/uby-2.0.0-p195#sprut sh -c 'cd /var/www/current; bundle install'" on 10.3.27.72
it error happen when i migrate project from ruby 1.9.3 to ruby 2.0
You have to set GEM_HOME accordingly:
$ export GEM_HOME='/home/shibanov/.rvm/gems/ruby-2.0.0-p195'

Moonshine Deployment Error

When I try to deploy my rails app to Rackspace using Moonshine, I get the following error:
* 2013-01-20 22:54:44 executing `app:symlinks:update'
* 2013-01-20 22:54:44 executing `deploy:create_symlink'
triggering before callbacks for `deploy:create_symlink'
* 2013-01-20 22:54:44 executing `moonshine:apply'
* executing "sudo -p 'sudo password: ' RAILS_ROOT=/srv/appname/releases/20130121065443 DEPLOY_STAGE= RAILS_ENV=production shadow_puppet /srv/appname/releases/20130121065443/app/manifests/application_manifest.rb"
servers: ["appname.com"]
[appname.com] executing command
** [out :: appname.com] Uncaught exception: LoadError: cannot load such file -- /srv/appname/releases/20130121065443/app/manifests/application_manifest.rb
** [out :: appname.com]
** [out :: appname.com]
** [out :: appname.com] /usr/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
** [out :: appname.com]
** [out :: appname.com]
** [out :: appname.com] /usr/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
** [out :: appname.com]
** [out :: appname.com]
** [out :: appname.com] /usr/lib/ruby/gems/1.9.1/gems/shadow_puppet-0.6.2/bin/shadow_puppet:130:in `<top (required)>'
** [out :: appname.com]
** [out :: appname.com]
** [out :: appname.com] /usr/bin/shadow_puppet:19:in `load'
** [out :: appname.com]
** [out :: appname.com]
** [out :: appname.com] /usr/bin/shadow_puppet:19:in `<main>'
** [out :: appname.com]
command finished in 2569ms
*** [deploy:update_code] rolling back
* executing "rm -rf /srv/appname/releases/20130121065443; true"
servers: ["appname.com"]
[appname.com] executing command
command finished in 364ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' RAILS_ROOT=/srv/appname/releases/20130121065443 DEPLOY_STAGE= RAILS_ENV=production shadow_puppet /srv/appname/releases/20130121065443/app/manifests/application_manifest.rb'" on appname.com
How should I go about fixing this?
If you don't know how to fix it, what are other gems that would help me deploy my app to Rackspace.
I found the issue. Capistrano was pulling the source from git and I forgot to push the new code. That means, application_manifest.rb didn't exist on the server. After pushing, it worked perfectly.

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