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

macOS Monterey: fails to install a lower Ruby version #255

Open
belgoros opened this issue Mar 15, 2022 · 11 comments
Open

macOS Monterey: fails to install a lower Ruby version #255

belgoros opened this issue Mar 15, 2022 · 11 comments
Labels

Comments

@belgoros
Copy link

belgoros commented Mar 15, 2022

Describe the Bug

I could install 3 different versions of Ruby without problems:

 ~ asdf list ruby
  2.7.3
  3.0.0
  3.0.2

But when trying to install a lower one (2.6.5), it raised the error:

 ~ asdf install ruby 2.6.5
Downloading openssl-1.1.1l.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
Installing openssl-1.1.1l...
Installed openssl-1.1.1l to /Users/serguei/.asdf/installs/ruby/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 12.3 using ruby-build 20211109)

Inspect or clean up the working tree at /var/folders/yy/ld5smmzd38v1q3z259dwh8_w0000gn/T/ruby-build.20220315131245.95390.AuogfI
Results logged to /var/folders/yy/ld5smmzd38v1q3z259dwh8_w0000gn/T/ruby-build.20220315131245.95390.log

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

Used asdf version: version: v0.9.0

Steps to Reproduce

run asdf install ruby 2.6.5

Expected Behaviour

Have ruby 2.6.5 installed

Actual Behaviour

1 warning generated.
linking shared-object psych.bundle
422 warnings generated.
linking shared-object date_core.bundle
make: *** [build-ext] Error 2

Environment

macOS version:  Monterey, `12.3`

asdf plugins affected (if relevant)

Ruby

@belgoros belgoros added the bug label Mar 15, 2022
@Stratus3D Stratus3D transferred this issue from asdf-vm/asdf Mar 17, 2022
@Stratus3D
Copy link
Member

I moved this to the asdf-ruby issue tracker because this is not an issue with asdf core.

Please provide the output from asdf info so we can debug the issue. Did you install all the dependencies listed here? https://github.com/rbenv/ruby-build/wiki#suggested-build-environment

@belgoros
Copy link
Author

Here is the output from asdf info command:

~ asdf info
OS:
Darwin serguei.local 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:36:53 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T8101 arm64

SHELL:
zsh 5.8 (x86_64-apple-darwin21.0)

ASDF VERSION:
v0.9.0

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/opt/homebrew/opt/asdf/libexec

ASDF INSTALLED PLUGINS:
elixir                       https://github.com/asdf-vm/asdf-elixir.git master 8d018f2
erlang                       https://github.com/asdf-vm/asdf-erlang.git master c215f6b
java                         https://github.com/halcyon/asdf-java.git master 7e886b4
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master 54113a9
ruby                         https://github.com/asdf-vm/asdf-ruby.git master e06154e
yarn                         https://github.com/twuni/asdf-yarn.git main 376c540

I'm using Oh My Zsh terminal.
Here is how the ~/.zshrc file looks like:

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/serguei/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled  # disable automatic updates
# zstyle ':omz:update' mode auto      # update automatically without asking
# zstyle ':omz:update' mode reminder  # just remind me to update when it's time

# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git ruby rails rake yarn)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

. /opt/homebrew/opt/asdf/libexec/asdf.sh

#export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
#export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"
#export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@3)"

eval "$(rbenv init -)"

export PATH="$HOME/.rbenv/bin:$PATH"

@Stratus3D
Copy link
Member

@belgoros I'm not sure what is going on. I do see that you have rbenv on your path before asdf, so you might try commenting out this line in your zshrc and see if that fixes it:

export PATH="$HOME/.rbenv/bin:$PATH"

@belgoros
Copy link
Author

@Stratus3D Thank you for your feedback. Unfortunately, it didn't fix the error.

@rockarloz
Copy link

rockarloz commented Mar 30, 2022

Same issue but with rbenv, maybe this command can help u for something

CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.6.5

@belgoros

@necrodome
Copy link

Same issue but with rbenv, maybe this command can help u for something

CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.6.5

@belgoros

works with asdf, too.

CFLAGS="-Wno-error=implicit-function-declaration" asdf install ruby 2.6.5

@dersnek
Copy link

dersnek commented May 4, 2022

@lucia-w
Copy link

lucia-w commented Oct 6, 2022

RUBY_CFLAGS="-w" rbenv install 2.6.6 works for M1

@ghost
Copy link

ghost commented Nov 14, 2022

RUBY_CFLAGS="-w" rbenv install 2.6.6 works for M1

Works for asdf as well RUBY_CFLAGS="-w" asdf install ruby 2.6.1

@claudiorivera
Copy link

Not sure if it's related, but I'm on macOS Ventura 13.4.1 with an Intel processor, and here's what worked for me and allowed me to install both newer and older Ruby versions with asdf-ruby:

brew install openssl@1.1 openssl@3 ruby-build

In .zshrc, add two lines (which we'll use one at a time):

export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" # Ruby 2.x–3.0
# export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@3)" # Ruby 3.1+

Then:

brew link --overwrite openssl@1.1 # for Ruby 2.x-3.0, or openssl@3 for Ruby 3.1+
source ~/.zshrc
asdf install ruby [version]

Hope that's useful to someone!

@allisonphillips
Copy link

@claudiorivera You don't need to overwrite the brew link, you just need add OSSL 1 to the package config path (export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig") to ensure that dependencies like GMP can find the package for OSSL 1.1... homebrew also includes this information in the post-install instructions for openssl@1.1.

But OP's problem here is different... they are trying to install a ruby version below 2.7 on an M1 mac, but the first ruby version with support for those processors was 2.7. You can hack at getting versions below 2.7 to install on an M1 machine by passing it RUBY_CFLAGS="-w" (as others have mentioned) and by poring through the log file to see which additional flags need to be adjusted if subsequent builds fail (just pass the log path from Results logged to /var/folders/stuff.log as an arg to open, like open /var/folders/stuff.log , and it opens the build log in the Console utility application where it should be really clear what's breaking and where).

That said, suppressing errors long enough to force a square peg into a round hole by getting an old ruby version to reach the end of the install sequence without exiting is likely to have some wonky side effects, both with Ruby and with old gems in your project's dependencies that don't support your machine's architecture. If you truly need to develop with a ruby version that has been EOL for over a year at this point, your time would be better spent dockerizing the application.

IMO this should be closed; it's not a bug, it's just an unsupportable use case to expect asdf to install an EOL version of ruby on processor architecture that did not exist at the time that version of ruby was released.

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

No branches or pull requests

8 participants