Install and use your custom gems on Bluehost

It’s very normal your Rails app has to run under a Rails version different from the one on Bluehost (or any other hosts). If so, we have to find a way to install our own Rails gem and let the application knows about it.

Install a new gem on Bluehost (or any other hosts) is easy, just run

gem install gem_name -v=gem_version

Next, we’ll let our app where our own gems are located. In your ~/.bashrc, added these:

export GEM_HOME=$HOME/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib64/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HOME/ruby/gems/bin

then run this command:

# source ~/.bashrc

Sometimes you would need to add this to your environment.rb:

ENV['GEM_PATH'] = '$HOME/ruby/gems:/usr/lib64/ruby/gems/1.8'

One is your custom gems location, one is the Bluehost gems location.

Your Rails application should now know where your gems located :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s