Skip to content

How to Install & Run OpenFarm on an Ubuntu System

nicmel edited this page May 20, 2019 · 10 revisions

Follow these instructions to install and run OpenFarm (and the software it depends on) on an Ubuntu-like (18.10) Linux system:

0. Install libs and other dependencies

sudo apt update && sudo apt install -y zlib1g-dev libssl-dev libcurl4-gnutls-dev build-essential patch ruby-dev zlib1g-dev liblzma-dev openjdk-8-jre ruby ruby-dev rails imagemagick

1. Install Git

sudo apt-get install git

2. Install Ruby

sudo apt-get install ruby

3. Install Rails

sudo apt-get install rails

4. Install ElasticSearch

A specific version of Elastic is needed

This is more complex as ElasticSearch is not found in standard Ubuntu repositories. If you try to simply apt-get install you will see the error “E: Unable to locate package elasticsearch”. Instead, enter the following commands, which will add ElasticSearch’s repository to apt and will install and configure ElasticSearch appropriately:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &&
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list &&
sudo apt-get update &&
sudo apt-get install elasticsearch=6.5.1 &&
sudo systemctl enable elasticsearch.service && 
sudo systemctl start elasticsearch.service

5. Install MongoDB

Use the following commands to install MongoDB:

sudo apt install -y mongodb

6. Install OpenFarm Itself

To install OpenFarm, enter these commands: if necessary, change Ruby version within Gemfile

git clone https://github.com/openfarmcc/OpenFarm.git
cd OpenFarm
bundle install

7. Start and Test the OpenFarm Server

OpenFarm has a web-based interface. When you install it on your own system, you are installing a web server, and to interact with it as a member would, you do so through your browser. Here are the final commands you need to issue to bring the server up and to connect to it with a browser:

echo "ENV['SECRET_KEY_BASE'] = '$(rake secret)'" >> config/app_environment_variables.rb
rake db:setup
rails s

Then, visit http://127.0.0.1:3000/ in your browser to see the OpenFarm web application running on your local machine. There is a default administrator account and password: [email protected] and admin123.

Troubleshooting

Failed: Your Ruby version is 1.9.3, but your Gemfile specified 2.2.0

First, install RVM:

gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
sudo apt-get install curl
curl -sSL https://get.rvm.io | bash -s stable

Then restart your terminal so that RVM commands will work, and issue this command:

rvm install ruby-2.2.0

Next, adjust your terminal (a.k.a. shell, console) settings:

  1. Open a terminal, or click on your terminal so that it gets focus.
  2. From the terminal application menu, select Edit > Profile Preferences.
  3. Select the Title and Command tab.
  4. Check the box labeled Run command as a login shell.
  5. Exit and restart the terminal.

Next, adjust OpenFarm:

cd OpenFarm
rvm --default use 2.2.0 

And try again:

bundle install
rake db:setup
echo "ENV['SECRET_KEY_BASE'] = '$(rake secret)'" >> config/app_environment_variables.rb
rails s

Failed due to gem 'patron' failing

If you get an error of this sort, you may need to install patron separately. Do this with the following command:

sudo gem install patron

Failed because cannot find libcurl

If your attempt to install patron fails with an error of this sort, you may need to first install libcurl separately. Do this with the following command:

sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev

Then attempt to install patron again:

sudo gem install patron

And finally, reattempt the process:

bundle install
rake db:setup
echo "ENV['SECRET_KEY_BASE'] = '$(rake secret)'" >> config/app_environment_variables.rb
rails s

Failed, cannot connect to localhost port 9200

This is a problem with ElasticSearch. This may be because it is not running. You can check if ElasticSearch is running by issuing the following command:

curl http://localhost:9200

If that command returns a 200 HTTP status code, ElasticSearch is running. If you instead see a message like "curl: (7) Failed to connect to localhost port 9200: Connection refused" this indicates that ElasticSearch is probably not running.

If ElasticSearch is running but you still encounter this error, try setting an environment variable to explicitly point to the correct location by adding the following line to the file config/app_environment_variables.rb (create the file if it does not already exist):

ENV['ELASTICSEARCH_URL'] = 'http://127.0.0.1:9200'

If ElasticSearch is not running, you can start it with the following command:

sudo /etc/init.d/elasticsearch start

Then try the bundle process again:

bundle install
rake db:setup
echo "ENV['SECRET_KEY_BASE'] = '$(rake secret)'" >> config/app_environment_variables.rb
rails s

Failed due to Java not being installed

If the process fails because Java is not installed, install it with the following commands:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installerx	

export JAVA_HOME=jdk-install-dir
export PATH=$JAVA_HOME/bin:$PATH

Then start ElasticSearch with this command:

sudo /etc/init.d/elasticsearch start

And finally start the server:

bundle install
rake db:setup
echo "ENV['SECRET_KEY_BASE'] = '$(rake secret)'" >> config/app_environment_variables.rb
rails s

Failed: "in 'require': cannot load such file"

An error of this sort will look something like this:

Failed - /home/roryaronson/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- rails/cli (LoadError) 
	from /home/roryaronson/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require' 
	from /usr/bin/rails:7:in `<main>' 

If you get an error of this sort, try re-bundling and continuing from there:

bundle install
rake db:setup
echo "ENV['SECRET_KEY_BASE'] = '$(rake secret)'" >> config/app_environment_variables.rb
rails s

Failed: RSpec fails to upload/edit images

Make sure you have imagemagick installed:

sudo apt-get install imagemagick

Failed: Connection timed out

A failure of this sort will look something like this:

Gem::RemoteFetcher::FetchError: Errno::ETIMEDOUT: Connection timed out - connect(2) for "rubygems.org" port 443 (https://rubygems.org/gems/railties-4.0.2.gem)
An error occurred while installing railties (4.0.2), and Bundler cannot
continue.
Make sure that `gem install railties -v '4.0.2'` succeeds before bundling.

This usually indicates a transient network error. Try issuing the bundle command again or perhaps waiting a while first to see if the problem goes away before reissuing the command.

Failed: An error occurred while installing tzinfo

An error of this sort will look something like this:

Failed - Gem::RemoteFetcher::FetchError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A (https://rubygems.global.ssl.fastly.net/gems/tzinfo-0.3.41.gem) 
An error occurred while installing tzinfo (0.3.41), and Bundler cannot continue. 
Make sure that `gem install tzinfo -v '0.3.41'` succeeds before bundling.

If you get an error of this sort, you may need to explicitly install tzinfo. Do this with the following command:

gem install tzinfo

Then re-bundle with the following command:

bundle install

If that fails, one more thing you can try is to manually install the AWS SDK before making another re-bundling attempt. Do this with the following commands:

gem install aws-sdk-v1 -v '1.55.0'
bundle install 

Next, try starting the server:

rake db:setup
echo "ENV['SECRET_KEY_BASE'] = '$(rake secret)'" >> config/app_environment_variables.rb
rails s

That should do the trick.

Failure: 500 Internal Server Error

500 errors can happen for a myriad of reasons. If you just started running your server by executing rails s and are immediately getting this error, it is possible that your mongo database is not yet running. You can start the database manually by issuing the command monogod -dbpath db in your OpenFarm directory.

Clone this wiki locally