noxenal
noxenal

Reputation: 21

Nokogiri installation error and fails with macOS 14 Sonoma

I am trying to install an older version of nokogiri (1.6.8.1) on a x86 intel mac using Sonoma 14.4 with a ruby project of mine but i am experiencing a problem with either bundle install or gem install nokogiri

xml_document.c:46:25: error: incompatible function pointer types passing 'int (xmlNodePtr, xmlNodePtr, xmlDocPtr)' (aka 'int (struct _xmlNode *, struct _xmlNode *,
struct _xmlDoc *)') to parameter of type 'st_foreach_callback_func *' (aka 'int (*)(unsigned long, unsigned long, unsigned long)')
[-Wincompatible-function-pointer-types]
  st_foreach(node_hash, dealloc_node_i, (st_data_t)doc);
                        ^~~~~~~~~~~~~~
/Users/username/.rvm/rubies/ruby-2.7.8/include/ruby-2.7.0/ruby/st.h:141:57: note: passing argument to parameter here
int rb_st_foreach(st_table *, st_foreach_callback_func *, st_data_t);
                                                        ^

Common fixes like using system libraries (like libxml2-dev and libxslt1-dev), installing and updating xcode command line permissions have been tried and failed. I have also attempted using

gem install nokogiri -v '1.6.8.1' -- --with-cflags="-Wno-incompatible-function-pointer-types"

but to no avail.

This error is also encountered on a m2 macbook (running on Sonoma too). I believe it is a problem with xcode compiling the c files in the gem.

For more details, the project is running on ruby 2.7.8. With my own trial and error, I could only install nokogiri versions 1.11 and above, but I need to use version1.6 for this project

Any help or pointers that could lead to fixing this issue would be appreciated! :)

Upvotes: 2

Views: 776

Answers (3)

NaveenKumar A
NaveenKumar A

Reputation: 11

Try this command, It helps to install nokogiri after many trails. "-Wno-int-conversion" is playing trick here. gem install nokogiri -v '1.6.8.1' --source 'https://artifactory.roving.com/artifactory/gems/' -- --with-cflags="-Wno-incompatible-function-pointer-types -Wno-int-conversion"

Upvotes: 1

lyneux
lyneux

Reputation: 71

I had the same problem and then succeeded by installing libxslt and libxml2 via bundler and then supplied all of the parameters together:

gem install nokogiri -v 1.8.5 -- \
--use-system-libraries \
--with-xslt-dir=/usr/local/opt/libxslt \
--with-xml2-dir=/usr/local/opt/libxml2 \
--with-cflags="-Wno-incompatible-function-pointer-types"

Upvotes: 7

Mike Jaffe
Mike Jaffe

Reputation: 562

I just had this issue, and running brew install llvm@15 solved it for me. Hope that helps

Upvotes: 0

Related Questions