Saturday 28 January 2017

Installing ruby environment (rbenv) on MacOSX

Pre-requisites:
- OS X 10.10 or higher
- Xcode must be installed on Mac
- If Xcode beta version is installed, the name of Xcode file in "Applications" folder must be "Xcode".
(To install Xcode, either download from apple developer account or give "xcode-select --install" command in terminal)

Installing rbenv-

Step 1:
Install Brew using below command:

> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

(This is the standard script that install homebrew to "/usr/local" folder, so that, user doesn't need to use "sudo" while using the
command "brew install ...")

Step 2:
Then install rbenv using brew command as:
terminal>> brew install rbenv

Step 3:
Export rbenv path to bash profile.
> vi ~/.bash_profile

In bash_profile, write following lines:
> export RBENV_ROOT=/usr/local/var/rbenv
> if which rbenv > /dev/null;
> then eval "$(rbenv init -)";
> fi;
save the bash_profile and quit.

Step 4:
Run the bash_profile.
> . ~/.bash_profile

Step 5:
give rbenv command and it should show the new version of rbenv (0.4.0, in this case)
> rbenv

Step 6: To install ruby-build on MacOSX
By default, rbenv doen't know how to install ruby build. Hence, for that we will use a plugin "ruby-build" by cloning a github project
from the link "https://github.com/rbenv/ruby-build" to a directory in our local drive "plugins"
For this step, first we need to create "plugins" folder in "/usr/local/var/rbenv"

//first go to home dir
> cd
> cd /usr/local/var/rbenv
> ls

If "plugins" folder is not found, create one.
> mkdir plugins
> cd plugins
Now clone the github project here.

> git clone https://github.com/rbenv/ruby-build.git

Step 7: Now check the latest version of ruby-build which can be installed using below command
> rbenv install --list

Step 8: install latest version of rbenv (2.1.2, in this case)
> rbenv install 2.1.2

Step 9: Now rbenv is installed on machine but the default version of ruby being used is still the
pre-installed ruby version in mac. Check it using command
> ruby -v

Step 10:
set our installed rbenv 2.1.2 as the global version.
>  rbenv global 2.1.2
> ruby -v

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Step 11: (To install bundler)
install bundler after rbenv is installed properly.
> gem install bundler

Step 12: (To install calabash-cucumber)
> gem install calabash-cucumber

Step 13: (To use binding.pry)
> gem install pry

No comments:

Post a Comment

Installing ios-webkit-debug-proxy on MacOSX

Installing ios_webkit_debug_proxy on MacOSX: ios_webkit_debug_proxy is used to access WebViews or MobileSafari on real iOS devices while ...