Some required libraries that you have to install on your development machine
When installing new gem for Rails application, you expect to run simple command bundle install
and hopefully all gems in Gemfile will be installed in your machine. Unfortunately, that is not always the case. It is because many gems require a specific library to be pre-installed. In this post, I am going to list several common libraries and you might miss and could prevent you from installing new gem.
mysql2
Error:
Error installing mysql2 : ERROR: Failed to build gem native extension.
Solution:
sudo apt-get install libmysqlclient-dev
paperclip
(carrierwave
) with image processing functionality (cropping, resizing, etc):
Error
/tmp/stream28514-0 is not recognized by the 'identify' command
Solution
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
nokogiri
Error:
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
Solution:
sudo apt-get install libxslt-dev libxml2-dev
geo_ip
Error: I don't remember exactly :)
Solution:
sudo apt-get install libgeoip-dev
bcrypt-ruby (json)
Error:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
Solution:
sudo apt-get install ruby1.9.1-dev
pg
Error:
ERROR: Failed to build gem native extension.
Solution: First, check and make sure PostgreSQL is installed. Then run the following command
sudo apt-get install postgresql-client libpq5 libpq-dev
- Can not precompile assets
Error:
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
Solution:
sudo apt-get install nodejs