Skip to content

Instantly share code, notes, and snippets.

@mrcasals mrcasals/explanation.md
Last active Aug 29, 2015

Embed
What would you like to do?
rbenv: remove RUBY_FREE_MIN and RUBY_HEAP_MIN_SLOTS warnings on Ruby 2.1.0

rbenv: remove RUBY_FREE_MIN and RUBY_HEAP_MIN_SLOTS warnings on Ruby 2.1.0

If you are like me, then you might have some Ruby projects running on different Ruby versions, so you'll need to either upgrade those old projects to Ruby 2.1.10 or deal with these warnings:

/Users/marc/.rbenv/versions/2.1.0/bin/ruby: warning: RUBY_FREE_MIN is obsolete. Use RUBY_GC_HEAP_FREE_SLOTS instead.
/Users/marc/.rbenv/versions/2.1.0/bin/ruby: warning: RUBY_HEAP_MIN_SLOTS is obsolete. Use RUBY_GC_HEAP_INIT_SLOTS instead.
ruby: warning: RUBY_FREE_MIN is obsolete. Use RUBY_GC_HEAP_FREE_SLOTS instead.
ruby: warning: RUBY_HEAP_MIN_SLOTS is obsolete. Use RUBY_GC_HEAP_INIT_SLOTS instead.

RVM takes care of these warnings automatically, but rbenv doesn't, so you'll need to take care of it yourself.

The way of hiding those warnings is, as the notice says, unsetting the RUBY_FREE_MIN and RUBY_HEAP_MIN_SLOTS constants from your environment. I have them set on my .zshrc file, and I need those constants for older Ruby versions, so you might want to do this:

$ mkdir -p /usr/local/etc/rbenv.d/exec/
$ $EDITOR /usr/local/etc/rbenv.d/exec/gc.bash

And copy the following code in this gc.bash file you've just created:

if [ `rbenv version-name` = "2.1.0" ]; then
  unset RUBY_FREE_MIN
  unset RUBY_HEAP_MIN_SLOTS
fi

Credits go to mislav on this issue on rbenv project.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.