I get the following error when trying to upgrade Ruby to 2.6.7:
$ rbenv install 2.6.7
...
implicit declaration of function 'rb_native_mutex_destroy' is invalid in C99
vm.c:2489:34: warning: expression does not compute the number of elements in this array; element type is 'const int', not 'VALUE' (aka 'unsigned long') [-Wsizeof-array-div]
sizeof(ec->machine.regs) / sizeof(VALUE));
~~~~~~~~~~~~~~~~ ^
vm.c:2489:34: note: place parentheses around the 'sizeof(VALUE)' expression to silence this warning
Is there a fix?
Note that MacOS users seldom download Ruby to build from source. Instead, Mac users install the latest Ruby with Homebrew or get the latest Ruby version with the installation utilities that accompany a version manager such as asdf, chruby, rbenv, or rvm.
You need to install Apple's Xcode Command Line Tools to get the Unix tools needed to install Ruby and develop applications. Apple's Xcode Command Line Tools provide a C language compiler. You'll need it to install Ruby.
If you're using Ruby on a Mac, it is set up by default, but you can't modify or upgrade it. Most developers don't use the pre-installed version of Ruby on their Macs. Instead, they configure several systems to help them manage Ruby installation (and other programs), and manage different versions of Ruby.
Additionally to following Gavin's answer,
I had to reinstall readline. brew reinstall readline
Yes, this is a known issue upstream: https://bugs.ruby-lang.org/issues/17777
ruby-build is also tracking this issue: https://github.com/rbenv/ruby-build/issues/1489
The work around is to run the following code, and install ruby 2.6.7 again:
$ export warnflags=-Wno-error=implicit-function-declaration
$ rbenv install 2.6.7
-or-
$ CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.6.7
Looks like this can also impact gem installation with native extensions (mysql2
is one of those):
gem install <GEMNAME> -- --with-cflags="-Wno-error=implicit-function-declaration"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With