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

Building ruby on mac m1 #5252

Closed
rachitpant opened this issue Sep 15, 2022 · 11 comments
Closed

Building ruby on mac m1 #5252

rachitpant opened this issue Sep 15, 2022 · 11 comments

Comments

@rachitpant
Copy link

Description

Steps to reproduce

Unable to install a universal ruby with rvm.

  1. rvm install ruby-2.7.2 -C --with-arch=x86_64,arm64

Expected behavior

Expected rvm to make a universal build of ruby2.7.2

Actual behavior

rpant@MBK-WCV41P7JVM ncaa-forms % rvm install ruby-2.7.2 -C --with-arch=x86_64,arm64 Checking requirements for osx. Certificates bundle '/opt/homebrew/etc/[email protected]/cert.pem' is already up to date. Requirements installation successful. Warning: DYLD_LIBRARY_PATH environment variable is set, this might interact with the compilation and ruby. Installing Ruby from source to: /Users/rpant/.rvm/rubies/ruby-2.7.2, this may take a while depending on your cpu(s)... ruby-2.7.2 - #downloading ruby-2.7.2, this may take a while depending on your connection... ruby-2.7.2 - #extracting ruby-2.7.2 to /Users/rpant/.rvm/src/ruby-2.7.2 - please wait ruby-2.7.2 - #configuring - please wait Error running './configure --prefix=/Users/rpant/.rvm/rubies/ruby-2.7.2 --with-arch=x86_64 arm64 --with-opt-dir=/opt/homebrew/opt/libyaml:/opt/homebrew/opt/libksba:/opt/homebrew/opt/readline:/opt/homebrew/opt/zlib:/opt/homebrew/opt/[email protected] --disable-install-doc --enable-shared', please read /Users/rpant/.rvm/log/1663273468_ruby-2.7.2/configure.log There has been an error while running configure. Halting the installation.

Output of configure.log
configure: WARNING: you should use --build, --host, --target
checking for ruby... /Users/rpant/.rvm/rubies/ruby-3.0.0/bin/ruby
tool/config.guess already exists
tool/config.sub already exists
checking build system type... Invalid configuration arm64': machine arm64-unknown' not recognized
configure: error: /bin/sh tool/config.sub arm64 failed

Environment info

rpant@MBK-WCV41P7JVM ncaa-forms % rvm remove ruby-2.7.2
ruby-2.7.2 - #removing src/ruby-2.7.2 - please wait
ruby-2.7.2 - #removing rubies/ruby-2.7.2 - please wait
ruby-2.7.2 - #removing gems - please wait
ruby-2.7.2 - #removing wrappers - please wait
ruby-2.7.2 - #removing environments - please wait
Using /Users/rpant/.rvm/gems/ruby-3.0.0
rpant@MBK-WCV41P7JVM ncaa-forms % rvm list
=* ruby-3.0.0 [ arm64 ]

=> - current

=* - current && default

* - default

rpant@MBK-WCV41P7JVM ncaa-forms % rvm install ruby-2.7.2 -C --with-arch=x86_64,arm64
Checking requirements for osx.
Certificates bundle '/opt/homebrew/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
Warning: DYLD_LIBRARY_PATH environment variable is set, this might interact with the compilation and ruby.
Installing Ruby from source to: /Users/rpant/.rvm/rubies/ruby-2.7.2, this may take a while depending on your cpu(s)...
ruby-2.7.2 - #downloading ruby-2.7.2, this may take a while depending on your connection...
ruby-2.7.2 - #extracting ruby-2.7.2 to /Users/rpant/.rvm/src/ruby-2.7.2 - please wait
ruby-2.7.2 - #configuring - please wait
Error running './configure --prefix=/Users/rpant/.rvm/rubies/ruby-2.7.2 --with-arch=x86_64 arm64 --with-opt-dir=/opt/homebrew/opt/libyaml:/opt/homebrew/opt/libksba:/opt/homebrew/opt/readline:/opt/homebrew/opt/zlib:/opt/homebrew/opt/[email protected] --disable-install-doc --enable-shared',
please read /Users/rpant/.rvm/log/1663273468_ruby-2.7.2/configure.log
There has been an error while running configure. Halting the installation.
rpant@MBK-WCV41P7JVM ncaa-forms % rvm info

ruby-3.0.0:
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

system:
uname: "Darwin MBK-WCV41P7JVM 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64"
name: "OSX"
version: "12.1"
architecture: "arm64"
bash: "/bin/bash => GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)"
zsh: "/bin/zsh => zsh 5.8 (x86_64-apple-darwin21.0)"
remote_path: "osx/12.1/arm64"
xcode: ""

rvm:
version: "1.29.12 (latest)"
updated: "8 days 4 hours 35 minutes 16 seconds ago"
path: "/Users/rpant/.rvm"
autolibs: "[4] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."

ruby:
interpreter: "ruby"
version: "3.0.0p0"
date: "2020-12-25"
platform: "arm64-darwin21"
patchlevel: "2020-12-25 revision 95aff21468"
full_version: "ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin21]"

homes:
gem: "/Users/rpant/.rvm/gems/ruby-3.0.0"
ruby: "/Users/rpant/.rvm/rubies/ruby-3.0.0"

binaries:
ruby: "/Users/rpant/.rvm/rubies/ruby-3.0.0/bin/ruby"
irb: "/Users/rpant/.rvm/rubies/ruby-3.0.0/bin/irb"
gem: "/Users/rpant/.rvm/rubies/ruby-3.0.0/bin/gem"
rake: "/Users/rpant/.rvm/rubies/ruby-3.0.0/bin/rake"

environment:
PATH: "/Users/rpant/.rvm/gems/ruby-3.0.0/bin:/Users/rpant/.rvm/gems/ruby-3.0.0@global/bin:/Users/rpant/.rvm/rubies/ruby-3.0.0/bin:/Users/rpant/.rvm/bin:/Users/rpant/.nvm/versions/node/v18.4.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/rpant/code/ncaa-forms/node_modules/.bin:/Users/rpant/Library/Application Support/JetBrains/Toolbox/scripts:/Library/Oracle/instantclient_19_8"
GEM_HOME: "/Users/rpant/.rvm/gems/ruby-3.0.0"
GEM_PATH: "/Users/rpant/.rvm/gems/ruby-3.0.0:/Users/rpant/.rvm/gems/ruby-3.0.0@global"
MY_RUBY_HOME: "/Users/rpant/.rvm/rubies/ruby-3.0.0"
IRBRC: "/Users/rpant/.rvm/rubies/ruby-3.0.0/.irbrc"
RUBYOPT: ""
gemset: ""

@rachitpant
Copy link
Author

I will also add that i am trying to build ruby in the hopes this universal ruby would be able to build ruby-oci8.

@leedrum
Copy link

leedrum commented Oct 31, 2022

Did you find any solution?

@leedrum
Copy link

leedrum commented Nov 1, 2022

I checked the log of rvm install 3.0.0
I have resolved this issue by the steps:

  • First, I lost gcc => install it brew install gcc
  • Next, I still faced the issue configure: error: something wrong with LDFLAGS= => I found this
brew install [email protected]

export PATH="$(brew --prefix)/opt/[email protected]/bin:$PATH"
export LDFLAGS="-L$(brew --prefix)/opt/[email protected]/lib"
export CPPFLAGS="-I$(brew --prefix)/opt/[email protected]/include"
export PKG_CONFIG_PATH="$(brew --prefix)/opt/[email protected]/lib/pkgconfig"

rvm autolibs disable

export RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC
export optflags="-Wno-error=implicit-function-declaration"

rvm install 3.0.0 --with-openssl-dir=$(brew --prefix)/opt/[email protected]

and finally I got Install of ruby-3.0.0 - #complete

@simonknoll
Copy link

For me, uninstalling brew and rvm and reinstalling it did the trick:
https://stackoverflow.com/a/74443264/328602

@leedrum
Copy link

leedrum commented Nov 15, 2022

@simonknoll but you can not uninstall every time you need to install a new version

@simonknoll
Copy link

you don't have to, i've installed 2.7.2 and 3.1.2
although it looks like 2.5.1 makes some problems.

@dprater
Copy link

dprater commented Feb 13, 2023

I was entirely unable (after quite a lot of trying) to get 3.0.2 to install on my M1. That includes using the instructions posted here and elsewhere. No joy. Tried multiple versions of openssl, messing with the includes directory - nothing I tried worked. Fortunately, 3.1.3 did install, at least for me.

@CARocha
Copy link

CARocha commented Jul 12, 2023

this working for me M1-macbook air
rvm install 3.1.2 --with-openssl-dir=$(brew --prefix)/opt/openssl@3

@mayur-kambariya
Copy link

@leedrum you save my day, thanks a lot 🥳

@eldare
Copy link

eldare commented Jan 2, 2024

The --with-openssl-dir solution by @CARocha also worked to install ruby 3.3.0.
I don't know why rvn insists on using openssl 1 instead of 3.

@Furqanameen
Copy link

Furqanameen commented Feb 26, 2024

That one helped for me!!!
Actually what was the issue..
In mac default openssle@3 was installed that not supporting anymore old ruby/rvm version as well.

So what I did...
Uninstall openssl@3 and reinstalled [email protected] and then ran below command so thats works for me....

brew uninstall openssl
brew uninstall openssl@3
brew uninstall [email protected]

Then install OpenSSL 1 using brew:

brew install [email protected]
Last, install your ruby 2.7.2 using rvm and OpenSSL 1:

PKG_CONFIG_PATH=$(brew --prefix [email protected])/lib/pkgconfig rvm install 2.7.2

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

No branches or pull requests

8 participants