Skip to content

rvm / rbenv is too slow?⚓︎

Preface⚓︎

I was recently moved to Sputnik team with in Transport Engineering which is more like a Kernel team for Gojek. So in which I will be spending lot of time on infrastructure and will be working towards stabilization of the overall infrastructure. In short it's kinda SRE team, but I wouldn't like to call it as SRE team totally.

While I am working on HAProxy cookbooks to address an issue1, I faced lot of issues because of the way ruby versions are installed in my mac. To avoid and eliminate all the hacky things2 that are done by the ruby version manager, RVM, I decided to go ahead and switch to rbenv.

  • You can follow official rbenv documentatoin/README to install it.

Context⚓︎

Once it is installed, in order to install ruby version, I tried the default thing that is mentioned in the README, which is rbenv install 2.5.8. But to my surprise it took enormous amount of time. It is mostly stuck in installing openssl. So I did a bit of googling to print verbose logging, you can do it by rbenv install --verbose 2..5.0.

The Problem...⚓︎

So I figured out that it is spending most of the time in installing openssl. I suddenly happen to recollect that (from history) I installed ruby through rvm by specifying --with-openssl-dir, and a bit more googling helped me to find the similar thing with rbenv.

& The Fix!⚓︎

So we can specify RUBY_CONFIGURE_OPTS as env variable to use the openssl installed in system. You can figured out the openssl directory in mac by asking brew itself brew --prefix openssl.

To fix the slow installation issues with rvm:⚓︎

1
rvm install 2.3.5 --with-openssl-dir=`brew --prefix openssl`

To fix the slow installation issues with rbenv:⚓︎

1
2
RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` rbenv install
2.5.0

To understand how slow it is, I completed writing this article since I started both of the installations procedures with and without system openssl dir, and the one where we specified openssl direcotry completed about 5mins, and the one where it has to install openssl is still running,

Happy Coding! 🎉


  1. HAProxy does not start if there is any backend whose DNS can not be resolved. 

  2. rvm installs some hooks into your shell to change cd which is causing the chef and couple of binary executable gems to fail. To get rid of this, chef introduced appbundler. Read about it more. 


Last update: 2021-06-21
Authors:

Comments