Debugging asset compilation errors

Using bundle show to debug undefined method 'directory?' for nil:NilClass while compiling rails assets

Thomas V.

2 minute read

While trying to deploy a new rails app to production I came across this undefined method ‘directory?’ error during asset compilation: ** 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 rake aborted! undefined method directory?' for nil:NilClass /srv/www/rails/arthouse/shared/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:189:inblock in each_entry’ /srv/www/rails/arthouse/shared/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each’ This problem was only showing up in production, and there were a number of symlinks I thought may have been the culprit, unfortunately the error output was less than helpful.

apt-get upgrade nginx adds ipv6 by default

and what happens when a merge goes bad

Thomas V.

2 minute read

I discovered this when I ran the latest server update for the NGINX PPA on Ubuntu, which includes a new default configuration file. Instead of choosing to overwrite or discard the new config, I merged the new one with my old and when I restarted NGINX I got an address already in use error: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] still could not bind() This is because the latest NGINX update adds IPv6 support by default

Automatically start Rails applications after reboot

Create a simple shell script that restarts your Ruby on Rails application's unicorn instance.

Thomas V.

1 minute read

Convert the deploy:start functionality of your existing capistrano deploy recipe to a shell script:

/var/www/app/start.sh cd /var/www/app/current && (PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin: RAILS_ENV=production /usr/bin/env bundle exec unicorn -c /var/www/app/current/config/unicorn.rb -E production -D) Make it executable:

chmod u+x /var/www/app/start.sh Add it to /etc/rc.local (be sure to replace app with whatever your applications user is): #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel.

Configuring ImageMagick and RMagick to play nice

Using homebrew on OSX Mavericks

Thomas V.

2 minute read

Sometimes it takes a little work to get ruby gems and homebrew installs working properly on your Mac. The error message below shows that bundler is having trouble finding the MagickWand.h header file. pkg-config is a super useful helper tool that will help ruby gems find installed libraries. 19:11:06 $ thomas@bear arthouse (master): bundle install Fetching source index from https://rubygems.org/ Installing rmagick (2.13.2) Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

Thomas V.

3 minute read

We’ve been using MongoDB in production at AJJ, Inc. for almost two years now. We initially chose Mongo because we needed to store large SOAP responses (500kb/ea on average) and we were in need of a way to cache them locally. Everything worked well, and I had no complaints or gripes unlike many others. Everything was going great until last Friday when the application lost database connectivity. After logging into our Mongo server the problem was immediately apparent: