rtomayko/posix-spawn

coompiling posix-spawn on mac failed

feyy opened this issue · 5 comments

feyy commented

logs below:

Building native extensions.  This could take a while...
ERROR:  Error installing posix-spawn-0.3.11.gem:
    ERROR: Failed to build gem native extension.

    /Users/yuebin/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20160118-38001-k13rjh.rb extconf.rb
creating Makefile

make  clean

make
compiling posix-spawn.c
posix-spawn.c:6:19: fatal error: errno.h: No such file or directory
 #include <errno.h>
                   ^
compilation terminated.
make: *** [posix-spawn.o] Error 1

make failed, exit code 2

Help me, please!

piki commented

Does it work when you check out posix-spawn by itself and run rake, rather than installing it with gem?

It's odd that errno.h would be missing. Can you Mac compile C programs at all?

cat <<EOF > hello.c
#include <errno.h>
#include <stdio.h>

int main() {
  puts("hello world");
  return 0;
}
EOF
make hello

this also fails for me. But it looks like an entirely different error.

ERROR:  Error installing posix:
    ERROR: Failed to build gem native extension.

    current directory: /Users/jack/.gem/ruby/2.3.0/gems/posix-0.0.5/ext/posix
/Users/jack/.rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160407-16494-1j4q3ow.rb extconf.rb
creating Makefile

current directory: /Users/jack/.gem/ruby/2.3.0/gems/posix-0.0.5/ext/posix
make "DESTDIR=" clean

current directory: /Users/jack/.gem/ruby/2.3.0/gems/posix-0.0.5/ext/posix
make "DESTDIR="
compiling posix.c
posix.c:101:9: warning: implicit declaration of function 'RHASH' is invalid in C99 [-Wimplicit-function-declaration]
    if (RHASH(_envp)->ntbl) {
        ^
posix.c:101:23: error: member reference type 'int' is not a pointer
    if (RHASH(_envp)->ntbl) {
        ~~~~~~~~~~~~  ^
posix.c:102:52: error: member reference type 'int' is not a pointer
        envp = malloc(sizeof(char**)*RHASH(_envp)->ntbl->num_entries + 1);
                                     ~~~~~~~~~~~~  ^
1 warning and 2 errors generated.
make: *** [posix.o] Error 1

make failed, exit code 2
janko commented

I'm getting the same error about missing errno.h. I think it might have been when I upgraded to Ruby 2.6.0.

My specs:

$ uname -a
Darwin Jankos-MacBook-Pro-2.local 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64
$ ruby -v 
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]

I'm on latest Mac OS Mojave (10.14.4), and have developer tools normally installed.

Can you Mac compile C programs at all?

Yes, I can compile that file.

janko commented

Installing Mac OS headers fixed the issue (from rbenv/ruby-build#1233 (comment)):

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg  -target /
piki commented

Closing this as solved. The only recent report was followed within 20 minutes by a correct solution.

xcode-select --install also sometimes works when you're missing basic system headers like errno.h.