Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RVM install ruby 2.6.4 fails with makefile error: implicit declaration of function 'ffi_prep_closure' is invalid in C99

RVM rvm 1.29.12-next

Mac OS Big Sur on M1 chip

rvm install 2.6.4 fails with:

Error running '__rvm_make -j8',
please read /Users/jason/.rvm/log/1626110300_ruby-2.6.4/make.log

There has been an error while running make. Halting the installation.

the makefile error is:

error: implicit declaration of function 'ffi_prep_closure' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    result = ffi_prep_closure(pcl, cif, callback, (void *)self);
like image 927
Jason FB Avatar asked Jul 12 '21 17:07

Jason FB


1 Answers

this is caused by the environment flags not set in your shell.

brew info libffi

will tell you the variables you need:

For compilers to find libffi you may need to set: export LDFLAGS="-L/opt/homebrew/opt/libffi/lib" export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"

For pkg-config to find libffi you may need to set: export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"

for ZSH, edit ~/.zshenv and add:

export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"

Close & reopen your terminal window or source ~/.zshrc to load your changes

Check your work with

% echo $LDFLAGS
-L/opt/homebrew/opt/libffi/lib
% echo $CPPFLAGS
-I/opt/homebrew/opt/libffi/include
% echo $PKG_CONFIG_PATH
/opt/homebrew/opt/libffi/lib/pkgconfig

(confirm that the environment variables are correct)

re-try to install the rvm version you want to install.

like image 171
Jason FB Avatar answered Oct 26 '22 12:10

Jason FB