Some Rails Deployment Errors & Fixes

Error #1:
libssl.so.10: cannot open shared object file: No such file or directory – /efs/www/rprod/sites/digitalreadingroom.nypl.org/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/mysql2.so

Solution:
The fix was to symlink it from a old version to this new one or update mysql client in the QA.

Error #2:
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

Solution:
Adding the gems ‘execjs’ and ‘therubyracer’ – most of the time that works. Or installing node.js.  But in my case it did not work, ‘therubyracer’ gem depends on the gem ‘libv8’, which has newer version that was not working, so  forced ‘rubyracer’ to downgrade to version ‘0.10.2’ which made ‘libv8’ version to be downgraded and that solved it 🙂

Error #3:
We had two asset precompile issues: 1) Error compiling the assets because of css import issues. 2) Rendering issue after deployment.

Solution:
For #1, resolve the css issues. For #2, added the following to prod env file and made sure to run precompile in deploy.rb script:

config.assets.enabled = true

config.assets.compress = true

config.assets.precompile += %w( *.js *.css )

Error #5:
Mistakenly commented the line Bundler.require(:default, :assets, Rails.env), and totally forgot to uncomment it :/ And spend a good time investigating why none of the gems were available to the app! It took me a while to realize without that line an app has no clue to look for it gems in bundle path!!

Solution:
Uncomment that line!!!!

Fragment Caching in Rails App

Did fragment caching (using memcahe) in the Rails app today. Here are the things:
– Added the following in the view:

<% cache “my_cache_partial”, :expires_in => 1.hour do %>
<%= render :partial => “partials/my_partial” %>
<% end %>

– Added the gem ‘dalli’

– Then added the following in development.rb(and all other environemnts)

config.cache_store = :dalli_store, ‘localhost:11218’
DALLI_STORE = ‘localhost:11218’
config.action_controller.perform_caching = true

Note*: expire_in will not work without memcache!