Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Mac Installation Instructions

sb-prateekkeerthi edited this page May 9, 2022 · 36 revisions

Absolute Beginner’s Guide to BONNIE Development on a Mac

Setting up Your Local BONNIE Environment

  1. Download and install xcode and xcode developer tools – without them, nothing works
  1. If needed, setup http_proxies in your bash profile (~/.profile)
  • export http_proxy="[proxy]"
  • export https_proxy="[proxy]"
  • export HTTP_PROXY="[proxy]"
  • export HTTPS_PROXY="[proxy]"
  • export no_proxy="localhost,127.0.0.1"
  • export NO_PROXY="localhost,127.0.0.1"
  1. Install homebrew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" For more information- http://brew.sh/
  • brew install openssl
  1. Install Yarn
  • brew install yarn
  1. Install mongodb using homebrew
  • brew tap mongodb/brew

  • brew install [email protected]

  • If you want mongod and mongo command to be available from anywhere in the terminal, export mongodb path to .bash_profile as:

    sudo vi ~/.bash_profile  //open .bash_profile
    export PATH="/usr/local/opt/[email protected]/bin:$PATH"   //paste this in .bash_profile
    source ~/.bash_profile    //reload .bash_profile
    
  1. If mongodb 3.6 or newer is installed. Configure mongodb to allow more depth in BSON documents. Add the following to /usr/local/etc/mongod.conf

     setParameter:
        maxBSONDepth: 500
    
  2. Follow instructions for starting mongo db on launch and immediately. Should look something like:

  • To have launchd start mongodb now and on reboot: brew services start mongodb/brew/[email protected]
  • If you don't want to run mongodb on reboot but run in background: mongod --config /usr/local/etc/mongod.conf &
  • Note that you may also have the option to use: brew services mongodb start
  1. Install gpg: https://gpgtools.org

  2. Install RVM: https://rvm.io/

  • Install RVM stable with ruby: \curl -sSL https://get.rvm.io | bash -s stable --ruby
  • This will ask gp2 keys to import. You can generate using gptools or import one given by rvm
  • To start using RVM run: source ~/.rvm/scripts/rvm
  • Bonnie uses ruby 2.7.2. To install ruby 2.7.2:
      rvm install 2.7.2
      rvm use 2.7.2
      rvm --default 2.7.2
    
  • If installation is failing due to an error message similar to "bash: /root/.rvm/scripts/rvm: No such file or directory" try following the top solution in this Stack Overflow page.
  1. Now add rvm to bash profile
  • sudo vi ~/.bash_profile
  • Add the following to end of file [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session as a function
  • Restart terminal
  • Now try rvm list it should display 2.7.2 as your default ruby
  1. (Optional) install git bash-completion tools
  • brew install git bash-completion
  • Add the following to ~/.bash_profile
      if [ -f `brew --prefix`/etc/bash_completion ]; then
        . `brew --prefix`/etc/bash_completion
      fi
    
  1. Install bonnie
  • mkdir git

  • cd git

  • git clone https://github.com/projecttacoma/bonnie.git

  • cd bonnie

  • gem install eventmachine -v '1.0.7'

  • bundle install (If this doesn’t work, do gem install bundler)

  • (Also sometimes gem install eventmachine –v '1.0.7' -- --with-cppflags=-I/usr/local/opt/openssl/include)

  • If bundle fails on libv8, and the error looks something like: Unable to find a compiler officially supported by v8.

    There are a number of things you may have to do depending on your particular setup, but the following worked on Catalina 10.15.5:

      $ brew install [email protected]
      $ bundle config build.libv8 --with-system-v8
      $ bundle config build.therubyracer --with-v8-dir=$(brew --prefix [email protected])
      $ bundle install
    
  1. Set up the bonnie_development database
  • bundle exec rake db:setup
  • mongo
  • show dbs; shows:
      admin               0.000GB
      bonnie_development  0.000GB
      local               0.000GB
    
  1. Make a temp directory in ~/git/bonnie
  • mkdir tmp
  1. Open the rails shell:
  • bundle exec rails console
  • User.last
  • Should not be nil.
  • If you get nil, try in various orders starting the mongo db and calling the bundle exec rake commands
  1. Start the web server:
  • bundle exec rails server
  • BONNIE should be available at http://localhost:3000
  1. Log in
  • The package comes with one user account:
  • To make any user an admin, open the rails console (bundle exec rails console) and use the following:
    • User.first.update_attributes approved: true, admin: true
    • Replace User.first with any user you would like to make admin, e.g. User.where(email:/\w/).first
    • NOTE that [email protected] will be set up as an admin by default.
  1. To run Bonnie in IntelliJ, please follow Bonnie setup guide for IntelliJ

Set up the rest of your Coding Environment

  1. Pull down a few more dependencies
cd ~/git
git clone https://github.com/cqframework/cql-execution
git clone https://github.com/projecttacoma/cqm-models
git clone https://github.com/projecttacoma/cqm-execution
git clone https://github.com/projecttacoma/cqm-execution-service
git clone https://github.com/projecttacoma/cqm-parsers
git clone https://github.com/projecttacoma/cqm-reports

Troubleshooting and Debugging in BONNIE

  1. If working with local copies of libraries
  • In /Gemfile, set up BONNIE to pull hqmf2js and health-data-standards from your local environment rather than git

    • Comment out:
    gem 'cqm-models', :git => 'https://github.com/projecttacoma/cqm-models.git', :branch => 'master'
    
    • Uncomment:
    # gem 'cqm-models', :path => '../cqm-models'
    
  • In package.json,

    • replace
        "cqm-execution": "https://github.com/projecttacoma/cqm-execution#2019-standards-update"
    
    • with
        "cqm-execution": "../cqm-execution"
    
  • Then re-run bundle install (which also calls yarn install)

  1. Helpful web browser console commands
  • bonnie.mainView.getView().model.attributes – this gets the attributes of the model of the current view, which should be super helpful for discovering data inconsistencies
  • In the chrome developer console (option + command + I)
  • Sources tab > assets has all of the rendered items for this page (helpful to figure out how everything fits together)
  • Using the Development db is great, because stuff is not minified like it is for the production db

Important Security Setup With Git Secrets (https://github.com/awslabs/git-secrets)

  • Use brew to install git secrets
    • brew install git-secrets
  • Clone this repository (see git/Github Basics below)
    • Note: You may have to reinitialize these hooks each time you clone a new copy of the repo
  • Follow the instructions for setting up the pre-commit hooks (from https://github.com/awslabs/git-secrets)
    • cd /path/to/bonnie
      git secrets --install
      git secrets --register-aws
      
  • Done! Now each commit should be automatically scanned for accidental AWS secret leaks.

git/GitHub Basics

  • Get the original repository
    • git clone %%github address%%
  • Check out a new branch (mostly for creating bugfixes or new features)
    • git checkout -b %%some new branch name%%
  • Check out an existing branch
    • git checkout %%some existing branch name%%
  • Figure out the status of your local repository
    • git status
  • Commit a change to your local repo
    • git commit -a –m “%%some commit message%%”
  • Push the change to github
    • git push origin %%some existing branch name%%
  • Go back to master
    • git checkout master