Installing Ruby 3.4.1 and Rails 8.0.1 on Apple Silicon

by | Jan 26, 2025 | Rails Renaissance | 0 comments

A modern, minimalist tech illustration showing a sleek Apple Silicon chip merging with Ruby's red crystal logo. The composition features clean lines and a gradient background transitioning from deep ruby red to space gray. Including a subtle circuit board pattern and floating SSL lock symbols to represent secure connections. Style is professional yet approachable, using Apple's design aesthetic with a developer-friendly twist. The image conveys both technical precision and successful problem-solving.

A Tale of OpenSSL and Persistence

Picture this: You’re excited to dive into Ruby on Rails 8 development on your shiny new M1/M2 Mac, but OpenSSL is giving you the cold shoulder. Don’t worry – you’re not alone in this dance! Let’s turn that frustration into a success story with this comprehensive guide.

The Challenge

If you’ve tried installing Ruby 3.4.1 on your Apple Silicon Mac and encountered OpenSSL-related errors, you might have seen something like:

Error running '__rvm_make -j8',
please read /Users/username/.rvm/log/ruby-3.4.1/make.log

Or perhaps the dreaded:

OpenSSL is not available. Install OpenSSL and rebuild Ruby

The Solution: A Fresh Start Approach

Sometimes the best way forward is to start fresh. Here’s our battle plan:

1. Clean House: Remove Old Version Managers

First, let’s remove any existing Ruby version managers. They’re like having multiple GPS systems giving you different directions – not helpful!

# If you have RVM installed
rvm implode

# If you have rbenv installed
rm -rf ~/.rbenv

# Clean up any remaining pieces
sudo rm -rf /usr/local/lib/ruby
sudo rm -rf /usr/local/bin/ruby
sudo rm -rf /usr/local/share/ruby
rm -rf ~/.gem

2. Install Homebrew in the Correct Location

On Apple Silicon Macs, Homebrew needs to live in /opt/homebrew, not /usr/local:

# Uninstall existing Homebrew (if it's in the wrong location)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

# Install Homebrew fresh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Add Homebrew to your PATH
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/opt/homebrew/bin/brew shellenv)"

3. Install ASDF Version Manager

ASDF is like a Swiss Army knife for version management – it handles multiple languages beautifully:

# Install ASDF
brew install asdf

# Add ASDF to your shell
echo "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ~/.zshrc
source ~/.zshrc

4. Configure OpenSSL

Now for the secret sauce – proper OpenSSL configuration:

# Install OpenSSL@3
brew install openssl@3

# Set up environment variables
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/readline/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/readline/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig:/opt/homebrew/opt/readline/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/opt/openssl@3 --enable-shared"

5. Install Ruby and Rails

With our foundation solid, let’s install Ruby and Rails:

# Install Ruby plugin for ASDF
asdf plugin add ruby

# Install Ruby 3.4.1
asdf install ruby 3.4.1

# Set it as your global Ruby version
asdf global ruby 3.4.1

# Verify installation
ruby -v  # Should show 3.4.1 with PRISM

Now for Rails:

# Install Rails 8.0.1
gem install rails -v 8.0.1

# Verify installation
rails -v  # Should show 8.0.1

6. Create Your First Rails 8 API

Let’s test our setup with a new Rails API project:

# Create a new API-only Rails application
rails new my_api_app --api

Bonus: Shell Configuration

Here’s a clean, organized .zshrc configuration that ties everything together:

# ASDF Setup
. /opt/homebrew/opt/asdf/libexec/asdf.sh

# Ruby/Rails Configuration
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/readline/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/readline/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig:/opt/homebrew/opt/readline/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/opt/openssl@3 --enable-shared"

# Auto-set Ruby version on terminal launch
. /opt/homebrew/opt/asdf/libexec/asdf.sh && asdf local ruby 3.4.1

Troubleshooting Tips

  1. Getting permission errors? Try running sudo chown -R $(whoami) ~/.asdf
  2. Rails command not found? Run asdf reshim ruby
  3. Still seeing old Ruby versions? Check your PATH with echo $PATH | tr ':' '\n' and remove any duplicate entries

Conclusion

Setting up Ruby and Rails on Apple Silicon might feel like solving a puzzle blindfolded, but with the right approach, it’s totally manageable. The key is starting fresh and ensuring everything is properly configured for the M1/M2 architecture.

Remember: A clean development environment is like a well-organized kitchen – everything has its place, and cooking (or coding) becomes a joy rather than a chore!

Additional Resources


Last updated: January 2024

Written By Topher Warrington

Related Posts

Rails 7 Multiple Database Connections: A Love Story

Rails 7 Multiple Database Connections: A Love Story

What if the best way to make your Rails API faster is to completely bypass it?

That’s exactly what we did with Prayer Nook and Heis Soma using Rails 7’s multiple database connections—and it cut authentication latency by 70%. User lookups went from 50-100ms to 5-10ms. API calls dropped by thousands per day.

The secret? Direct database access instead of HTTP API calls.

When Rails 7 enhanced multiple database support, it transformed our reasonable architectural decision (custom OAuth2 SSO) into a strategic masterstroke. We maintained microservices-level separation where it mattered while avoiding microservices-level complexity where it didn’t.

This post breaks down the complete implementation: configuration, security model, performance benchmarks, migration strategy, and honest assessment of when this pattern makes sense (and when it absolutely doesn’t).

Spoiler: After three years in production, it was absolutely worth it.

read more
Building a Custom SSO: Why We Chose OAuth2 Over Devise

Building a Custom SSO: Why We Chose OAuth2 Over Devise

In 2021, we made a decision that seemed crazy: build our own OAuth2 Single Sign-On system instead of using Devise. Three years and three Rails upgrades later, that “crazy” decision looks like strategic foresight.

This is the story of Heis Soma—our custom authentication service powering Prayer Nook and positioning us to serve the broader Christian ministry ecosystem. It’s about architectural decisions, technical tradeoffs, and the surprising ways that following standards can future-proof your applications.

We built ~2,000 lines of OAuth2-compliant code. Survived Rails 6.1 → 8.0 with minimal changes. Achieved 10x performance improvements through Rails 7’s multiple database connections. Served 1,000+ users with zero security incidents.

Was it worth the 200-hour investment? Yes—but not for everyone. Here’s when custom authentication makes sense, when it doesn’t, and what we learned from three years in production.

read more

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *