rtomayko / posix-spawn

Ruby process spawning library
Other
520 stars 52 forks source link

coompiling posix-spawn on mac failed #72

Closed feyy closed 5 years ago

feyy commented 8 years ago

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 8 years ago

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
jkthorne commented 8 years ago

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 5 years ago

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 5 years ago

Installing Mac OS headers fixed the issue (from https://github.com/rbenv/ruby-build/issues/1233#issuecomment-435643603):

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

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.