Software installation issue

I keep getting this error when trying to install the Raspberry Pi Farmbot software. I can see it is a permission issue, but how do I solve this?

pi@raspberrypi:~/farmbot-raspberry-pi-controller $ gem install bundler
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /var/lib/gems/2.1.0 directory.

Try this to run on root privilege =>
$sudo gem install bundler