Ruby & Rails notes

This page contains various notes for myself and maybe something helpful for you.


Execute around, a way to use ruby blocks to execute boilerplate or helpful code without adding the code to a method. This helps when trying to log around a method without adding the logging code to the method itself.

RVM issues

RVM is plagued with various OS level issues so below are some fixes for OS X:

Autolibs is a feature built into RVM to allow you to automatically install dependencies on your system.


Issue below:

ยป rvm install ruby-2.4.6 --with-openssl=/usr/local/opt/[email protected]/bin/openssl
Warning, new version of rvm available '1.29.10-next', you are using older version '1.29.0'.
You can disable this warning with:    echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
ruby-2.4.6 - #removing src/ruby-2.4.6 - please wait
Checking requirements for rvm_pkg.
Warning, you are using 'rvm autolibs rvm_pkg', this is rarely used and can produce errors,
make sure to report any problems to
Requirements installation successful.
Installing Ruby from source to: /Users/muhammad/.rvm/rubies/ruby-2.4.6, this may take a while depending on your cpu(s)...
ruby-2.4.6 - #downloading ruby-2.4.6, this may take a while depending on your connection...
ruby-2.4.6 - #extracting ruby-2.4.6 to /Users/muhammad/.rvm/src/ruby-2.4.6 - please wait
ruby-2.4.6 - #configuring - please wait
ruby-2.4.6 - #post-configuration - please wait
ruby-2.4.6 - #compiling - please wait
Error running '__rvm_make -j 1',
showing last 15 lines of /Users/muhammad/.rvm/log/1587154276_ruby-2.4.6/make.log
num2int.c:64:21: error: expected ')'
    sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
num2int.c:64:5: note: to match this '('
    sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
190 warnings and 2 errors generated.
make[2]: *** [num2int.o] Error 1
make[1]: *** [ext/-test-/num2int/all] Error 2
make: *** [build-ext] Error 2
+__rvm_make:0> return 2
There has been an error while running make. Halting the installation.

This breaks if RVM is trying to use autolibs, fix this by first enforcing homebrew as the package manager:

rvm autolibs homebrew

Then use your installation command, in my version:

rvm install ruby-2.4.6 --with-openssl-dir=brew --prefix openssl

Helpful gems