socketry / nio4r

Cross-platform asynchronous I/O primitives for scalable network clients and servers.
Other
964 stars 85 forks source link

gem install nio4r -v '2.3.1' fails #195

Closed AndrewRayCode closed 5 years ago

AndrewRayCode commented 5 years ago

This is possibly related to https://github.com/thoughtbot/capybara-webkit/issues/1071. I'm on OSX 10.13.6 and using XCode 10. The second cstddef error is also in the linked ticket.

Error 1

$ bundle
Fetching nio4r 2.3.1
Installing nio4r 2.3.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /.gem/ruby/2.5.1/gems/nio4r-2.3.1/ext/nio4r
/.rubies/ruby-2.5.1/bin/ruby -r ./siteconf20181018-35780-1247lnx.rb extconf.rb
checking for unistd.h... yes
checking for sys/select.h... yes
checking for port_event_t in poll.h... no
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port_event_t in port.h... no
checking for sys/resource.h... yes
creating Makefile

current directory: /.gem/ruby/2.5.1/gems/nio4r-2.3.1/ext/nio4r
make "DESTDIR=" clean

current directory: /.gem/ruby/2.5.1/gems/nio4r-2.3.1/ext/nio4r
make "DESTDIR="
compiling bytebuffer.c
compiling monitor.c
monitor.c:182:40: warning: implicit conversion loses integer precision: 'VALUE' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    NIO_Monitor_update_interests(self, interest);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ^~~~~~~~
monitor.c:192:40: warning: implicit conversion loses integer precision: 'VALUE' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    NIO_Monitor_update_interests(self, interest);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ^~~~~~~~
2 warnings generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:
./../libev/ev.c:488:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1068:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
  return ecb_popcount32 (x) + ecb_popcount32 (x >> 32);
         ~~~~~~~~~~~~~~~~^~
./../libev/ev.c:930:49: note: expanded from macro 'ecb_popcount32'
  #define ecb_popcount32(x) __builtin_popcount (x)
                            ~~~~~~~~~~~~~~~~~~  ^
./../libev/ev.c:1274:13: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
      if (e < (14 - 24)) /* might not be sharp, but is good enough */
          ~ ^  ~~~~~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:1591:
/usr/local/include/float.h:29:10: fatal error: 'CGAL/utils.h' file not found
#include <CGAL/utils.h>
         ^~~~~~~~~~~~~~
3 warnings and 1 error generated.
make: *** [nio4r_ext.o] Error 1

make failed, exit code 2

Gem files will remain installed in /.gem/ruby/2.5.1/gems/nio4r-2.3.1 for inspection.
Results logged to /.gem/ruby/2.5.1/extensions/x86_64-darwin-17/2.5.0-static/nio4r-2.3.1/gem_make.out

An error occurred while installing nio4r (2.3.1), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.3.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
    rails was resolved to 5.2.0, which depends on
      actioncable was resolved to 5.2.0, which depends on
        nio4r

Fix attempt #1:

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

It's not very effective

Fix attempt #2:

$ brew install cgal

Error 2

$ gem install nio4r -v '2.3.1'
Building native extensions. This could take a while...
ERROR:  Error installing nio4r:
    ERROR: Failed to build gem native extension.

    current directory: /.gem/ruby/2.5.1/gems/nio4r-2.3.1/ext/nio4r
/.rubies/ruby-2.5.1/bin/ruby -r ./siteconf20181018-42027-1ly3ifg.rb extconf.rb
checking for unistd.h... yes
checking for sys/select.h... yes
checking for port_event_t in poll.h... no
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port_event_t in port.h... no
checking for sys/resource.h... yes
creating Makefile

current directory: /.gem/ruby/2.5.1/gems/nio4r-2.3.1/ext/nio4r
make "DESTDIR=" clean

current directory: /.gem/ruby/2.5.1/gems/nio4r-2.3.1/ext/nio4r
make "DESTDIR="
compiling bytebuffer.c
compiling monitor.c
monitor.c:182:40: warning: implicit conversion loses integer precision: 'VALUE' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    NIO_Monitor_update_interests(self, interest);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ^~~~~~~~
monitor.c:192:40: warning: implicit conversion loses integer precision: 'VALUE' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    NIO_Monitor_update_interests(self, interest);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ^~~~~~~~
2 warnings generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:
./../libev/ev.c:488:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1068:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
  return ecb_popcount32 (x) + ecb_popcount32 (x >> 32);
         ~~~~~~~~~~~~~~~~^~
./../libev/ev.c:930:49: note: expanded from macro 'ecb_popcount32'
  #define ecb_popcount32(x) __builtin_popcount (x)
                            ~~~~~~~~~~~~~~~~~~  ^
./../libev/ev.c:1274:13: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
      if (e < (14 - 24)) /* might not be sharp, but is good enough */
          ~ ^  ~~~~~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:1591:
In file included from /usr/local/include/float.h:29:
In file included from /usr/local/include/CGAL/utils.h:25:
In file included from /usr/local/include/CGAL/utils_classes.h:22:
In file included from /usr/local/include/CGAL/config.h:136:
In file included from /usr/local/include/boost/container/flat_map.hpp:24:
In file included from /usr/local/include/boost/container/allocator_traits.hpp:31:
In file included from /usr/local/include/boost/container/container_fwd.hpp:61:
/usr/local/include/boost/container/detail/std_fwd.hpp:27:1: error: unknown type name 'namespace'
BOOST_MOVE_STD_NS_BEG
^
/usr/local/include/boost/move/detail/std_ns_begin.hpp:27:34: note: expanded from macro 'BOOST_MOVE_STD_NS_BEG'
   #define BOOST_MOVE_STD_NS_BEG namespace std{
                                 ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:1591:
In file included from /usr/local/include/float.h:29:
In file included from /usr/local/include/CGAL/utils.h:25:
In file included from /usr/local/include/CGAL/utils_classes.h:22:
In file included from /usr/local/include/CGAL/config.h:136:
In file included from /usr/local/include/boost/container/flat_map.hpp:24:
In file included from /usr/local/include/boost/container/allocator_traits.hpp:31:
In file included from /usr/local/include/boost/container/container_fwd.hpp:61:
/usr/local/include/boost/container/detail/std_fwd.hpp:27:1: error: expected ';' after top level declarator
/usr/local/include/boost/move/detail/std_ns_begin.hpp:27:47: note: expanded from macro 'BOOST_MOVE_STD_NS_BEG'
   #define BOOST_MOVE_STD_NS_BEG namespace std{
                                              ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:1591:
In file included from /usr/local/include/float.h:29:
In file included from /usr/local/include/CGAL/utils.h:25:
In file included from /usr/local/include/CGAL/utils_classes.h:22:
In file included from /usr/local/include/CGAL/config.h:136:
In file included from /usr/local/include/boost/container/flat_map.hpp:24:
In file included from /usr/local/include/boost/container/allocator_traits.hpp:31:
/usr/local/include/boost/container/container_fwd.hpp:80:10: fatal error: 'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
3 warnings and 3 errors generated.
make: *** [nio4r_ext.o] Error 1

make failed, exit code 2

Gem files will remain installed in /.gem/ruby/2.5.1/gems/nio4r-2.3.1 for inspection.
Results logged to /.gem/ruby/2.5.1/extensions/x86_64-darwin-17/2.5.0-static/nio4r-2.3.1/gem_make.out
tarcieri commented 5 years ago

This is a problem with your local environment:

In file included from ./../libev/ev.c:1591:
In file included from /usr/local/include/float.h:29:

For whatever reason /usr/local/include has higher precedence than the system include directories, and it's pulling in /usr/local/include/float.h instead of the one from your C standard library.

AndrewRayCode commented 5 years ago

For any archaeologists, this error occurred on a new computer (mac) that I had done a hard drive transfer to. There were lots of old homebrew-y files and probably other things left lying around, and since the operating system version had changed, things were in a weird state.

My solution was to first fully uninstall homebrew, then rm -rf /usr/local, and reinstall things with homebrew as I needed them