Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

2.6.6 on ARM64 #1699

Closed
nelseric opened this issue Dec 28, 2020 · 22 comments
Closed

2.6.6 on ARM64 #1699

nelseric opened this issue Dec 28, 2020 · 22 comments

Comments

@nelseric
Copy link

I've managed to install 2.7.2 and 3.0.0, but 2.6.6 fails with the following error

compiling closure.c
closure.c:264: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.
@hsbt
Copy link
Member

hsbt commented Dec 28, 2020

It's known issue. Ruby 2.6 didn't support M1 macOS yet.

If you want to use Ruby 2.6 with M1 macOS, Can you file it to https://bugs.ruby-lang.org/? Thanks.

@hsbt hsbt closed this as completed Dec 28, 2020
@nelseric
Copy link
Author

Thanks for pointing me in the right direction.

@mrkn
Copy link

mrkn commented Dec 28, 2020

@nelseric I guess the error is only due to fiddle. Probably, you can install Ruby 2.6 with specifying --with-out-ext=fiddle in the configure option.

@nelseric
Copy link
Author

@mrkn Thanks, that worked

@rience
Copy link

rience commented Dec 29, 2020

I was also able to install Ruby 2.6.6 with this

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.6.6

@santostiago
Copy link

I ended up doing this:

export optflags="-Wno-error=implicit-function-declaration"; 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" | rbenv install 2.5.5

@SalvatoreT
Copy link

@santostiago, that worked for me. Thank you!

@ak15
Copy link

ak15 commented Feb 5, 2021

I ended up doing this:

export optflags="-Wno-error=implicit-function-declaration"; 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" | rbenv install 2.5.5

This worked for me in My Apple M1 - Please try this if you are facing issue (I tried for ruby v 2.6.0) and don't need rosetta too

@santostiago

Once again thanks worked with 2.6.6

@HundredBillion
Copy link

THIS WORKED FOR ME
I spent 3hrs trying to get ruby 2.6.2 installed on my M1.

These 3 lines of code worked for me. Just make sure to change the version number to 2.6.2 (if that is what you need)

export optflags="-Wno-error=implicit-function-declaration"; 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" | rbenv install 2.5.5

@edmangimelli
Copy link

thank you so much @santostiago 😭

this actually solved my asdf install problem: (fish shell)

set -gx optflags "-Wno-error=implicit-function-declaration"
set -gx LDFLAGS "-L/opt/homebrew/opt/libffi/lib"
set -gx CPPFLAGS "-I/opt/homebrew/opt/libffi/include"
set -gx PKG_CONFIG_PATH "/opt/homebrew/opt/libffi/lib/pkgconfig"
asdf install ruby 2.6.6

andrewwestling added a commit to andrewwestling/dotfiles that referenced this issue Apr 12, 2021
I was having issues installing Ruby 2.6.5 on M1

Error message was:

```
% rbenv install 2.6.5
Downloading openssl-1.1.1j.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/aaf2fcb575cdf6491b98ab4829abf78a3dec8402b8b81efc8f23c00d443981bf
Installing openssl-1.1.1j...
Installed openssl-1.1.1j to /Users/amw/.rbenv/versions/2.6.5

Downloading ruby-2.6.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
Installing ruby-2.6.5...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.2.3 using ruby-build 20210405)

Inspect or clean up the working tree at /var/folders/sb/2zy1b11x4c915mw2x62j6_j00000gn/T/ruby-build.20210412150925.6205.WXbdPw
Results logged to /var/folders/sb/2zy1b11x4c915mw2x62j6_j00000gn/T/ruby-build.20210412150925.6205.log

Last 10 log lines:
    ~~~~~~ ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
compiling ../.././ext/psych/yaml/reader.c
compiling ../.././ext/psych/yaml/emitter.c
3 warnings generated.
compiling ../.././ext/psych/yaml/parser.c
5 warnings generated.
linking shared-object zlib.bundle
1 warning generated.
linking shared-object psych.bundle
make: *** [build-ext] Error 2

```

So I added libffi, readline, and openssl and tried again, and I was able to install

(see .zshrc for changes there, too)

This comment helped me: rbenv/ruby-build#1699 (comment)
@jujudellago
Copy link

jujudellago commented Apr 18, 2021

I ended up doing this:

export optflags="-Wno-error=implicit-function-declaration"; 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" | rbenv install 2.5.5

more thanks for you @santostiago !!! you saved my day !!

  • oh edit... now that I got ruby compiled with rbenv or asdf successfully, now looking for a way to actually run rails....

endless ffi errors

/Users/juju/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.9.18/lib/ffi/types.rb:69:in find_type': unable to resolve type 'size_t' (TypeError)`

@olivierlacan
Copy link
Contributor

@jujudellago Did you try to update the ffi gem? Or uninstall and reinstall it with the same flags shown above prefixed before you run bundle install? Bundler accepts build flags configuration it can store for specific gems. See: https://bundler.io/v1.16/bundle_config.html#BUILD-OPTIONS

@jujudellago
Copy link

Oh, so actually my error was just related to my project, I had a hardcoded version of ffi in my gemfile

To figure this out I just made an empty rails app, saw everything was fine, and realized I had the wrong ffi in gemfile.lock

With other compatibility issues I ended up using ruby 2.7.2

@soheil
Copy link

soheil commented Jun 4, 2021

rvm install 2.6.6 --with-out-ext=fiddle works great.

@olivierlacan
Copy link
Contributor

olivierlacan commented Jun 5, 2021

I’m sorry the flag is --with-out-ext?

Seriously?
Not --without-ext, but --with-out-ext? 😳

Can we please fix that if it wasn’t a typo on your side? Seems bad.

@tf-rshearer
Copy link

rvm install 2.6.6 --with-out-ext=fiddle Worked for me on Big Sur 11.4 w/ m1. Thanks!

@michaelsmith-st
Copy link

michaelsmith-st commented Jun 28, 2021

RVM is much more fussy on the installation process (pgp keys, openSSL installation). And after all that,
rvm install 2.6.6 --with-out-ext=fiddle did not work for me on Big Sur 11.4 w/ M1.

The combination of export commands with rbenv install 2.6.6 above worked great. Plus the dependency installation is soooo much smoother.

I use RVM on my Intel Mac...but I'm inclined to switch to rbenv now. (My use case is simple, so I skipped the rbenv-gem-rehash and gem install parts).
https://thoughtbot.com/blog/using-rbenv-to-manage-rubies-and-gems

@BGMP
Copy link

BGMP commented Jul 4, 2021

@michaelsmith-st Were you able to get Ruby 2.6.6 to install via RVM in the end? I haven't had any luck so far, and pretty much every answer pointing to its installation through the use of flags and so on ends up as a [broken] install for me.

@etipton
Copy link

etipton commented Sep 16, 2021

I was also able to install Ruby 2.6.6 with this

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.6.6

Just wanted to chime in and confirm that this is safe to do... I didn't really understand what this would actually do so I dug in a bit... wanted to be sure this wouldn't cause unexpected issues down the line*

To cut to the chase...

You can see here that by setting the USE_FFI_CLOSURE_ALLOC macro, the offending function (ffi_prep_closure) is never referenced.

And to confirm that the macro makes sense (the ffi_closure_alloc function is indeed available):

irb(main):001:0> require 'mkmf'
=> true
irb(main):002:0> pkg_config('libffi')
=> ["", "", "-lffi"]
irb(main):003:0> have_library('ffi')
checking for -lffi... yes
=> true
irb(main):004:0> have_func('ffi_closure_alloc', 'ffi.h')
checking for ffi_closure_alloc() in ffi.h... yes
=> true

*In hindsight, I guess that's what compilation is for in the first place, lol

@yeukfei02
Copy link

encounter same problem in macbook m1

export optflags="-Wno-error=implicit-function-declaration"; 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" | rvm install ruby-2.6.5

I tried this I am able to install ruby 2.6.5, not sure if this rvm install 2.6.5 --with-out-ext=fiddle also work in m1
just to share to let others know

ogirginc pushed a commit to rubytr/ruby-tr that referenced this issue Dec 2, 2021
- Ruby versions' below 2.7 are not supported[1] on Apple M1 chips.

[1] rbenv/ruby-build#1699
MuhammetDilmac pushed a commit to rubytr/ruby-tr that referenced this issue Dec 2, 2021
* Update Ruby version

- Ruby versions' below 2.7 are not supported[1] on Apple M1 chips.

[1] rbenv/ruby-build#1699

* Update ffi gem

- ffi gem's version had some problems[1]. To fix, I have updated it.

[1] ffi/ffi#137

* Add asdf-ruby's dotfile

* Update Ruby version on github workflows
@genezys
Copy link

genezys commented Dec 21, 2021

Thanks for all the comments. Here is the exact commands I used to install 2.6.7 using rbenv on an M1 Pro:

export optflags="-Wno-error=implicit-function-declaration"
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"
rbenv install 2.6.7

I hope this multi-line version will be more readable to others.
Based on previous comments, it should work for RVM too.

@rimian
Copy link

rimian commented Mar 1, 2022

Thanks for all the comments. Here is the exact commands I used to install 2.6.7 using rbenv on an M1 Pro:

export optflags="-Wno-error=implicit-function-declaration"
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"
rbenv install 2.6.7

I hope this multi-line version will be more readable to others. Based on previous comments, it should work for RVM too.

This worked with chruby and 2.6.5 for me. Thanks!

@rbenv rbenv locked and limited conversation to collaborators Mar 1, 2022
@hsbt hsbt converted this issue into discussion #1946 Mar 1, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests