简体   繁体   English

在 mac os 上安装 ruby 2.6.7 时出错 - 如何解决?

[英]Error installing ruby 2.6.7 on mac os - how to resolve?

I get the following error when trying to upgrade Ruby to 2.6.7:尝试将 Ruby 升级到 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?有解决办法吗?

Yes, this is a known issue upstream: https://bugs.ruby-lang.org/issues/17777是的,这是上游的一个已知问题: https://bugs.ruby-lang.org/issues/17777
ruby-build is also tracking this issue: https://github.com/rbenv/ruby-build/issues/1489 ruby-build 也在跟踪这个问题: https://github.com/rbenv/ruby-build/issues/1489

The work around is to run the following code, and install ruby 2.6.7 again:解决方法是运行以下代码,并再次安装 ruby 2.6.7:

$ 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 安装( mysql2就是其中之一):

gem install <GEMNAME> -- --with-cflags="-Wno-error=implicit-function-declaration"

Additionally to following Gavin's answer, I had to reinstall readline.除了遵循 Gavin 的回答之外,我还必须重新安装 readline。 brew reinstall readline

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM