Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First installation (of Ruby 2.4.0) fails on OS X #292

Closed
ELLIOTTCABLE opened this issue Feb 1, 2017 · 10 comments
Closed

First installation (of Ruby 2.4.0) fails on OS X #292

ELLIOTTCABLE opened this issue Feb 1, 2017 · 10 comments

Comments

@ELLIOTTCABLE
Copy link

> ruby-install ruby                         
>>> Installing ruby 2.4.0 into /Users/ec/.rubies/ruby-2.4.0 ...
>>> Installing dependencies for ruby 2.4.0 ...
Updating Homebrew...
Warning: automake-1.15 already installed
Warning: bison is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
Warning: openssl is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
Warning: readline is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
Warning: libyaml-0.1.7 already installed
Warning: gdbm-1.12 already installed
Warning: libffi is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
>>> Downloading https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2 into /Users/ec/src ...
>>> Verifying ruby-2.4.0.tar.bz2 ...
>>> Extracting ruby-2.4.0.tar.bz2 to /Users/ec/src/ruby-2.4.0 ...
>>> Configuring ruby 2.4.0 ...
checking for ruby... /usr/local/bin/ruby
config.guess already exists
config.sub already exists
checking build system type... x86_64-apple-darwin16.4.0
checking host system type... x86_64-apple-darwin16.4.0
checking target system type... x86_64-apple-darwin16.4.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/Users/ec/src/ruby-2.4.0':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
!!! Configuration of ruby 2.4.0 failed!

It looks like there's a bunch of packages already installed in Homebrew — (it'd be helpful if the output for those lines included which version chruby wants, and which it's getting.)

But even after brew uninstall automake bison openssl readline libyaml gdbm libffi, it still fails in the same way upon configuration.

@mattwynne
Copy link

mattwynne commented Feb 2, 2017

I get something similar:

...
compiling resize.c
linking shared-object -test-/array/resize.bundle
ld: warning: directory not found for option '-L/usr/local/Cellar/openssl/1.0.2k/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/openssl/1.0.2k/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/openssl/1.0.2k/lib'
Undefined symbols for architecture x86_64:
  "_rb_ary_resize", referenced from:
      _ary_resize in resize.o
  "_rb_cArray", referenced from:
      _Init_resize in resize.o
  "_rb_define_method", referenced from:
      _Init_resize in resize.o
  "_rb_num2long", referenced from:
      _ary_resize in resize.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../../../../.ext/x86_64-darwin16/-test-/array/resize.bundle] Error 1
make[1]: *** [ext/-test-/array/resize/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 2.4.0 failed!

Will write up more if I learn anything.

@mattwynne
Copy link

OK so the fix for me was to brew install openssl --force (I'm not sure whether the --force was necessary or not) and follow the post-install instructions to export two environment variables:

LDFLAGS:  -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

With that, it's installed like a charm. Thanks for a great piece of software @postmodern!

@graygilmore
Copy link

I had a very similar issue that was solved with:

brew install --force readline

@twe4ked
Copy link

twe4ked commented Feb 12, 2017

I'm getting similar to @mattwynne:

compiling resize.c
linking shared-object -test-/array/resize.bundle
ld: warning: directory not found for option '-L/usr/local/Cellar/openssl/1.0.2k/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/openssl/1.0.2k/lib'
ld: warning: directory not found for option '-L/usr/local/Cellar/openssl/1.0.2k/lib'
Undefined symbols for architecture x86_64:
  "_rb_ary_resize", referenced from:
      _ary_resize in resize.o
  "_rb_cArray", referenced from:
      _Init_resize in resize.o
  "_rb_define_method", referenced from:
      _Init_resize in resize.o
  "_rb_num2long", referenced from:
      _ary_resize in resize.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../../../../.ext/x86_64-darwin16/-test-/array/resize.bundle] Error 1
make[1]: *** [ext/-test-/array/resize/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 2.4.0 failed!
2:31.03s total, 93.46s user, 45.90s system, 92% cpu
$ ls -la /usr/local/Cellar/openssl/
total 0
drwxr-xr-x   8 odin  admin   272 17 Oct 10:34 ./
drwxr-xr-x  95 odin  admin  3230 12 Feb 17:15 ../
drwxr-xr-x  11 odin  admin   374 29 May  2015 1.0.2a-1/
drwxr-xr-x  11 odin  admin   374 24 Jul  2015 1.0.2d_1/
drwxr-xr-x  11 odin  admin   374 18 Dec  2015 1.0.2e/
drwxr-xr-x  11 odin  admin   374 30 Jan  2016 1.0.2f/
drwxr-xr-x  11 odin  admin   374 30 Jun  2016 1.0.2h_1/
drwxr-xr-x  11 odin  admin   374 12 Feb 18:43 1.0.2j/

@bsy
Copy link

bsy commented Mar 8, 2017

Tried reinsatlling openssl and readline but still getting:

rbenv install 2.4.0
ruby-build: use openssl from homebrew
Downloading ruby-2.4.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2
Installing ruby-2.4.0...
ruby-build: use readline from homebrew

BUILD FAILED (OS X 10.12.3 using ruby-build 20170201)

Inspect or clean up the working tree at /var/folders/sp/61ygj3qn6q1dl_8hmg0ljg8h0000gn/T/ruby-build.20170308011359.67034
Results logged to /var/folders/sp/61ygj3qn6q1dl_8hmg0ljg8h0000gn/T/ruby-build.20170308011359.67034.log

Last 10 log lines:
checking build system type... x86_64-apple-darwin16.4.0
checking host system type... x86_64-apple-darwin16.4.0
checking target system type... x86_64-apple-darwin16.4.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/var/folders/sp/61ygj3qn6q1dl_8hmg0ljg8h0000gn/T/ruby-build.20170308011359.67034/ruby-2.4.0':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

log file:

/var/folders/sp/61ygj3qn6q1dl_8hmg0ljg8h0000gn/T/ruby-build.20170308011359.67034 ~/code/hynt/dice_rails
/var/folders/sp/61ygj3qn6q1dl_8hmg0ljg8h0000gn/T/ruby-build.20170308011359.67034/ruby-2.4.0 /var/folders/sp/61ygj3qn6q1dl_8hmg0ljg8h0000gn/T/ruby-build.20170308011359.67034 ~/code/hynt/dice_rails
checking for ruby... /usr/bin/ruby
config.guess already exists
config.sub already exists
checking build system type... x86_64-apple-darwin16.4.0
checking host system type... x86_64-apple-darwin16.4.0
checking target system type... x86_64-apple-darwin16.4.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/var/folders/sp/61ygj3qn6q1dl_8hmg0ljg8h0000gn/T/ruby-build.20170308011359.67034/ruby-2.4.0':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

@bsy
Copy link

bsy commented Mar 8, 2017

nevermind, a full laptop restart fixed the issue!

@sobrinho
Copy link

sobrinho commented Sep 15, 2021

closure.c:263:14: 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);
             ^
1 error generated.
make[2]: *** [closure.o] Error 1
make[1]: *** [ext/fiddle/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 2.4.10 failed!

I know homebrew has the [email protected] package which runs under the M1 architecture.

Any ideas on how to fix this?

@sobrinho
Copy link

Fixed with:

export RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC
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"

@marknus
Copy link

marknus commented Mar 29, 2023

Fixed with:

export RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC
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"

Worked for me.
MacOS: 13.2.1 (22D68)
M1 max

@postmodern
Copy link
Owner

Looks like brew --prefix libffi needed to be added to the --with-opt-dir list of directories to compile against, since homebrew installs everything into a non-standard directory which ./configure cannot find by default. Should be fixed in 0.10.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants