简体   繁体   中英

Problem when installing Ruby 2.2.9 on Mac Big Sur M1

I tried to install Ruby 2.2.9 on Big Sur - M1 chipset.

I tried to use RVM, ASDF... but I always get this error during compilation:

encoding.c:825:2: error: implicit declaration of function 'rb_str_change_terminator_length' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    rb_str_change_terminator_length(obj, oldtermlen, termlen);

Well the answer would be trial and error by trying older versions of command line tools since it's BigSur I don't now the oldest supported, otherwise you can downgrade to Catalina and use command line tools 11.4.1. The issue is that older ruby versions don't compile because of some clang errors that have to do with the compiler in use at the time (did answer this in a post). One last very important mention is to use RBENV if is supported on M1 macs. I answered a similar question but with Catalina. If it helps.

You can also try setting this flag to ignore the errors (before the install process):

export optflags="-Wno-error=implicit-function-declaration"

A workmate found this fix (he's running a macbook 16inch with Big Sur)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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