Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.
claucece edited this page Jul 17, 2015 · 1 revision

Issue a pull request to Leap_web and install CouchDB on Mac OSX Lion

*This may also work on prior or newer versions of OSX.

1.1 Introduction

This document describes how to build and install CouchDB on OSX Lion with all the system requirements, and avoiding issues while compiling Erlang. Even though, Erlang/OTP should be possible to build from source on any Unix/Linux system, including OS X, it sometimes gives compile issues. You are advised to read the whole document before attempting to build and install CouchDB, its requirements and pulling a request to Leap_app.

Dependencies needed for installing CouchDB

You should have the following installed:

  • Erlang OTP (>=R14B01, =<R17)
  • ICU
  • OpenSSL
  • Mozilla SpiderMonkey (1.8.5)
  • GNU Make
  • GNU Compiler Collection
  • libcurl
  • help2man
  • Python (>=2.7) for docs
  • Python Sphinx (>=1.1.3)

Most of the installation tutorials give you information on how to install them. Usually, if you install with Brew, they'll be automatically installed with CouchDB.

1.3 Issues

While trying to install CouchDB on OSX, several issues may happen depending on the system requirements, on Brew or on system permissions. Here is a summary of those issues:

1.3.1. Possible incorrect Erlang compilation:

After the installation of CouchDB (through brew, Macports, source, etc -you can see the installation steps for CouchDB here: https://wiki.apache.org/couchdb/Installing_on_OSX)-, and try to run curl http://127.0.0.1:5984/, this error prompts in the terminal:

Apache CouchDB 1.6.1 (LogLevel=info) is starting. {"init terminating in do_boot",{{badmatch,{error,{bad_return,{{couch_app,start,[normal,["/usr/local/etc/couchdb/default.ini","/usr/local/etc/couchdb/local.ini"]]},{'EXIT',{{badmatch,{error,{shutdown,{failed_to_start_child,couch_secondary_se",[]},{couch_uuids,new_prefix,0,[{file,"couch_uuids.erl"},{line,84}]},{couch_uuids,state,0,[{file,"couch_uuids.erl"},{line,100}]},{couch_uuids,init,1,[{file,"couch_uuids.erl"},{line,50}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,306}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}}}}}}},[{couch_server_sup,start_server,1,[{file,"couch_server_sup.erl"},{line,98}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,272}]}]}}}}}},[{couch,start,0,[{file,"couch.erl"},{line,18}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}

See more about this issue here: https://gist.github.com/claucece/b7fa4667c0dc9a57b3fb

Possible solutions and causes:

  1. You forgot to ./configure once you satisfied the dependencies. This command should be run right after the installation of dependencies and prior to brew install couchdb.
  2. Permissions got hosed. Run: sudo chown -R $USER /usr/local/, brew rm --force erlang, brew install -v erlang |& tee /tmp/b.log.
  3. Problems with Brew. Run brew doctor. Solve the warnings or uninstall brew: sudo mv /usr/local /usr/local.messy and sudo mkdir -m 0775 /usr/local ; sudo chown -R $USER /usr/local. Install again Brew with: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  4. Changes in XCode : Apple now provides a stand-alone (command-line) build chain, which successfully builds CouchDB and required dependencies, or you can use XCode 4.2 and below directly. Users of a current XCode >= 4.3 will need to install the additional command-line tools
  5. Installed Erlang (or any other dependency) from source or using Macports, while installed CouchDB with Brew: don't ever do this. If done, uninstall everything (even Brew) and reinstall again.
  6. Check Erlang issues: For example, gcc-4.3.0 has a serious optimizer bug. It produces an Erlang emulator that will crash immediately. The bug is supposed to be fixed in gcc-4.3.1. Check them here: http://www.erlang.org/doc/installation_guide/INSTALL.html#Known-platform-issues
  7. Several problems with Erlang: see this thread: [https://github.com/Homebrew/homebrew/issues/7691](Erlang 3). This links may also be useful: https://github.com/Homebrew/homebrew/issues/6852 and http://librelist.com/browser//homebrew/2011/8/11/gcc-without-xcode-script/

If everything fails and you still get the same error, install CouchDB with the binary. Can be found here: http://couchdb.apache.org/. This is highly recommended.

1.3.2. While brew install couchdb, installation hangs at the final make.

More information about this issue could be found here: https://gist.github.com/rybesh/1147077.

Possible solutions and causes:

  1. No know cause: run brew install -v couchdb.

  2. No know cause: kill process with Ctrl-C. Retry.

See about this issue here: https://github.com/Homebrew/homebrew/issues/7024

For more issues, check this page: http://wiki.apache.org/couchdb/Troubleshooting and this page https://wiki.apache.org/couchdb/Error_messages

1.4. Best solution

Install CouchDB with the binary. Can be found here: http://couchdb.apache.org/.

1.5. Installation pages:

  1. https://wiki.apache.org/couchdb/Installing_on_OSX

  2. http://docs.couchdb.org/en/latest/install/unix.html


1.6. Issue a pull request to Leap_web

Taken from this page: [https://leap.se/en/docs/get-involved/coding](Leap app). This should be done after or before CouchDB is installed.

All development happens via pull requests. To add a new feature or fix a bug, the developer must create a new branch off develop, make their changes, and then issue a pull request for another developer to review before the changes get merged back into develop.

Here is an example, using github with username "rms" and repository leap_web. You don't need to use github, but it is a friendly way to get started.

Step 1 — Fork on github

Login to github.com as 'rms', browse to https://github.com/leapcode/leap_web/, and click the fork button.

Now you should have a fork of the code available at https://github.com/"rms"/leap_web.

Step 2 — Set up local clone

Clone the upstream repository. Paste this commands to your terminal:

git clone https://leap.se/git/leap_web and cd leap_web

Step 4 — Add a "remote" for your fork

Next, you need to add the fork you created on github as an alternate remote in your local repository:

``git remote add "rms" https://github.com/rms/leap_web.git```

Step 5 — Create a new feature branch

git fetch origin, git checkout develop and git checkout -b feature/my_new_feature

Step 6 — Hack away

Make all your changes in your feature/my_new_feature branch, with a separate git commit for each discrete modification you make.

Step 7 — Prepare for pull request

Once you are happy with your branch, prepare it for a pull request by rebasing on the latest upstream develop branch. This will also give you an opportunity to clean up your commit history by squashing and changing commit messages.

git fetch origin (# ensure the latest), git checkout feature/my_new_feature (# if not already checked out) and git rebase -i develop (# rebase and clean up commits)

Step 8 — Submit pull request

Next, you will push your local feature branch to your fork on github, and then issue a pull request.

git push "rms" feature/my_new_feature

Then browse to https://github.com/"rms"/leap_web, where you will see a handy button to issue a pull request. Make sure that the upstream branch is leapcode/leap_web:develop and you are requesting the merge of "rms"/leap_web:feature/my_new_feature.

Then you are done. Some other developer will get a notice of your pull request, review the changes, and merge into upstream develop branch. If they have questions or comments, you will get an email from github.


1.7. Additional things:

  • Change bin_adress to 0.0.0.0: change it with: sudo vim /usr/local/etc/couchdb/local.ini? and sudo service couchdb restart.

  • Install rbenv and rbenv install -v 1.9.3-p194. Check it on rbenv versions.

  • Use this commands for running leap_web: gem install bundler, bundle --binstubs, rake db:rotate db:migrate and rails s.

  • Go to http://localhost:3000. If you see the app, then.. Success! Be happy and time to relax!