I wanted to setup ruby source code on my machine. The source on Github has detailed instructions on how to do the setup.
git clone github.com/ruby/ruby cd ruby autoconf ./configure make make install
worked correctly on Mac OS X and Ruby was installed in
I use rbenv for managing Ruby versions. After setting up the Ruby from source, i wanted to use it using rbenv. Why? It will make very easy to switch between dev version and normal version.
rbenv shell ruby-dev, do something, make some changes, compile again, test again.
rbenv shell 2.1.2, and back to normal.
But as the source Ruby was installed in
usr/local/bin, rbenv was not able to find it.
I asked question on #ruby on IRC and Postmodern pointed me to this.
It mentions passing
--prefix option to the
./configure command. We can pass the name of directory where we want to install Ruby to this option.
So we can run
rbenv by default, installs all rubies in
And when we do
rbenv versions, it looks for all rubies installed in this directory and lists them.
The content of my
~/.rbnev/versions directory looked like these:
prathamesh ~/.rbenv/versions 2.0.0 $ ls 2.0.0-p247 2.0.0-p353 2.0.0-p481 2.1.0 2.1.1 2.1.2 rbx-2.2.6 prathamesh ~/.rbenv/versions 2.0.0
Now if we give prefix path to configure command, the dev-ruby will be installed in ~/.rbenv/versions
make install, dev ruby was installed in
~/.rbnenv/versions in ruby-dev directory.
rbenv versions output had ruby-dev also.
prathamesh ~/.rbenv/versions 2.0.0 $ rbenv versions * system (set by /Users/prathamesh/.rbenv/version) 2.0.0-p247 2.0.0-p353 2.0.0-p481 2.1.0 2.1.1 2.1.2 rbx-2.2.6 ruby-dev prathamesh ~/.rbenv/versions 2.0.0
ruby-dev is listed by
rbenv versions, i can switch to it easily:
rbenv shell ruby-dev
On Mac OS X Sierra, I had to also pass the flag for openssl directory while configuring.
cd ruby make clean ./configure --prefix="$HOME/.rbenv/versions/ruby-dev" --with-opt-dir="/usr/local/opt/openssl/" make make install
This sets up Ruby dev version on my machine and also allows me to switch back and forth using rbenv.
Top comments (0)