Ruby on Rails and Unicorn


Ruby gems are stored in GEM_HOME=/usr/local/share/ruby-bundler-stuff. When installing or uninstalling any gem be sure $GEM_HOME is set correctly. Binaries are in GEM_HOME/bin. The script /etc/profile.d/ sets GEM_HOME and adds the bin dir to the end of $PATH. It is loaded automatically by login shells.

Try not to install gems to the system. That can cause conflict with pacman. Especially binaries which are put in /usr/bin.

By default gem installs to $HOME which makes them inaccessible to other users (such as http). This is fine in some cases and is a useful default. To make gem install to $GEM_HOME use the flag –no-user-install.

Some commands,

  • gem help - show help info
  • gem env - show RubyGems Environment
  • gem list $pkg - list installed versions of $pkg
  • gem install $pkg -v $vrs –no-user-install - install $vrs version of $pkg to $GEM_HOME
  • gem uninstall $pkg -v $vrs –no-user-install - uninstall $vrs version of $pkg from $GEM_HOME

Bundler must be run with a Gemfile in cwd. It is a strange command and you will grow to hate it if you do not hate it already.

By default bundler does stuff to the system directories (/usr/bin and so on) ignoring whatever settings gem has. To override it, set GEM_HOME or use the –path option.

  • bundle show $pkg - list the path to where $pkg is installed
  • bundle install - installs, does not change Gemfile.lock if it exists
  • bundle update - updates gems, changes Gemfile.lock



This process was followed (with editing) when upgrading from 2.2.2 to 2.2.3. Some commands need to be run as user git as they will edit the file system.

  • merge from upstream
    git pull upstream tag 2.2.3
  • stop redmine
    sudo systemctl stop unicorn.service
  • copy redmine directory
    sudo cp -ai redmine_backup
    check with
    sudo diff -rq redmine_backup
  • run aw-data-backup and pull git repo
  • git push to server
  • install gems, from redmine dir,
    sudo -u git -i bundle update
  • follow:
    rest of commands are from there
  • update database
    sudo -u git -i rake db:migrate RAILS_ENV=production
  • if have plugins
    sudo -u git -i rake redmine:plugins:migrate RAILS_ENV=production
  • clear cache and existing session
    sudo -u git -i rake tmp:cache:clear
    sudo -u git -i rake tmp:sessions:clear
  • start server
    sudo systemctl start unicorn.service

aw-tech/ruby.txt · Last modified: 2014/03/12 22:08 by meskarune