Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveAdmin uninitialized constant

I am getting the following error after deploying my application to my VPS. ActiveAdmin works fine on my local development environment, but once I deploy using capistrano, it looks like the gem is not being installed?

E, [2013-03-14T01:27:04.901577 #24972] ERROR -- : uninitialized constant ActiveAdmin (NameError)
/home/deployer/apps/papaya/releases/20130314052558/config/initializers/active_admin.rb:1:in `<top (required)>'

My gem file

source 'https://rubygems.org'

gem 'rails', '3.2.11'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'pg'
gem 'bootstrap-sass'
gem 'font-awesome-sass-rails'
# gem 'acts_as_tree', :git => 'git://github.com/amerine/acts_as_tree.git'
gem 'closure_tree'
gem 'kaminari'
gem 'friendly_id'
gem 'slim'
gem 'gmaps4rails'
gem 'devise'
gem 'omniauth'
gem 'oauth2'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem 'simple_form'
gem 'pg_search'
gem 'stamp'
gem 'acts-as-taggable-on', '~> 2.3.1'
gem 'rmagick'
gem 'carrierwave'
gem 'select2-rails'
# gem 'roo'
gem 'activeadmin'
gem "meta_search",    '>= 1.1.0.pre'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby
  gem 'uglifier', '>= 1.0.3'
  gem 'compass-rails'
  gem 'turbo-sprockets-rails3'
end

I am able to run the console without a problem and require activeadmin

deployer@pareto:~/apps/papaya/current$ RAILS_ENV=production bundle exec irb
irb(main):001:0> require 'activeadmin'
=> true
irb(main):002:0>
like image 787
AlexBrand Avatar asked Mar 14 '13 05:03

AlexBrand


1 Answers

What's Happening?

When requiring gems that define constants, like ActiveAdmin or ActiveAdmin::Comment, if for some reason during definition of that constant something goes wrong Bundler leaves that constant undefined and won't reraise the exception.

Possible Causes

ActiveAdmin depends on ExecJS and ExecJS needs a working JavaScript runtime. ExecJS will throw an error like this during definition of ActiveAdmin constant.

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

In this case, just install Node.js. sudo apt-get install nodejs

How to Debug Problems Like This

  1. Try to run Rails console. bundle exec rails console
  2. If that fails, try to manually require problematic gem inside irb and work through its dependencies.
  3. Require the gem or part if it that should be defined but isn't. When requiring manually Rubygems throw an exception describing the problem.
  4. Work through exceptions and fix them until the problem is resolved.
like image 195
Pooyan Khosravi Avatar answered Oct 11 '22 13:10

Pooyan Khosravi