-
-
Save nicksieger/03bf346d3a8b63c5f822993b897da418 to your computer and use it in GitHub Desktop.
| --- ext/bigdecimal/bigdecimal.c.orig 2024-09-25 16:24:50 | |
| +++ ext/bigdecimal/bigdecimal.c 2024-09-25 16:25:15 | |
| @@ -65,7 +65,7 @@ | |
| static ID id_half; | |
| /* MACRO's to guard objects from GC by keeping them in stack */ | |
| -#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0 | |
| +#define ENTER(n) volatile VALUE vStack[n];int iStack=0 | |
| #define PUSH(x) (vStack[iStack++] = (VALUE)(x)) | |
| #define SAVE(p) PUSH((p)->obj) | |
| #define GUARD_OBJ(p,y) ((p)=(y), SAVE(p)) |
Thanks @Taimoor2500
Thanks!
i tried this but apparently didn't work, tried the fix from rvm/rvm#5507 (comment) and it worked
For those of you having issues with chruby, here's what worked for me.
Ruby 3.0.7 Manual Installation Guide for chruby on Apple Silicon
This guide documents the step-by-step process to manually compile and install Ruby 3.0.7 for use with chruby on Apple Silicon Macs (M1/M2/M3, maybe M4 and M5).
Prerequisites
- macOS with Apple Silicon (ARM64)
- Homebrew installed
- chruby and ruby-install installed
- Xcode Command Line Tools
- OpenSSL 1.1 from rbenv tap
Required Dependencies
# Ensure OpenSSL 1.1 is available
brew list openssl@1.1 || echo "OpenSSL 1.1 needed from rbenv/tap"
# Verify OpenSSL location
brew --prefix openssl@1.1
# Should output: /opt/homebrew/opt/openssl@1.1Step 1: Create the Apple Silicon Compatibility Patch
Create Nick Sieger's patch file needed for Ruby 3.0.7 on Apple Silicon:
cat > /tmp/ruby-3.0.7-bigdecimal.patch << 'EOF'
--- ext/bigdecimal/bigdecimal.c.orig 2024-09-25 16:24:50
+++ ext/bigdecimal/bigdecimal.c 2024-09-25 16:25:15
@@ -65,7 +65,7 @@
static ID id_half;
/* MACRO's to guard objects from GC by keeping them in stack */
-#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
+#define ENTER(n) volatile VALUE vStack[n];int iStack=0
#define PUSH(x) (vStack[iStack++] = (VALUE)(x))
#define SAVE(p) PUSH((p)->obj)
#define GUARD_OBJ(p,y) ((p)=(y), SAVE(p))
EOFStep 2: Download Ruby 3.0.7 Source
cd /tmp
wget https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.7.tar.xz -O ruby-3.0.7.tar.xz
tar xf ruby-3.0.7.tar.xz
cd ruby-3.0.7Step 3: Configure the Build
Configure Ruby to be installed in the chruby directory with proper OpenSSL linking:
./configure \
--prefix=/Users/$USER/.rubies/ruby-3.0.7 \
--with-openssl-dir=/opt/homebrew/opt/openssl@1.1Key Configuration Options:
--prefix=/Users/$USER/.rubies/ruby-3.0.7- Install to chruby-compatible location--with-openssl-dir=/opt/homebrew/opt/openssl@1.1- Link with OpenSSL 1.1
Step 4: Apply the Patch
As noted above, the Ruby 3.0.7 source needs to be patched for Apple Silicon compatibility. This was already handled by downloading the clean source, but if you encounter issues, you can manually apply the patch:
# If needed, apply patch manually:
# patch -p0 < /tmp/ruby-3.0.7-bigdecimal.patchStep 5: Compile Ruby
Compile Ruby using multiple CPU cores for faster build:
make -j4Expected Output:
- Compilation warnings are normal
- Build should complete successfully
- RDoc documentation will be generated
Step 6: Install Ruby
Install the compiled Ruby to the chruby directory:
make installInstallation includes:
- Binary commands in
~/.rubies/ruby-3.0.7/bin - Libraries in
~/.rubies/ruby-3.0.7/lib - Default gems and bundled gems
- Documentation and man pages
Step 7: Verify Installation
Test that chruby can see and use Ruby 3.0.7:
# Reload chruby to detect new installation
source /opt/homebrew/opt/chruby/share/chruby/chruby.sh
# List available Ruby versions
chruby
# Should show ruby-3.0.7 in the list
# Switch to Ruby 3.0.7
chruby ruby-3.0.7
# Verify Ruby version
ruby -v
# Expected: ruby 3.0.7p220 (2024-04-23 revision 724a071175) [arm64-darwin23]
# Test RubyGems
gem env
# Should show proper gem paths and Ruby versionStep 8: Cleanup
Remove temporary build files:
rm -rf /tmp/ruby-3.0.7*Configuration for Default Use
To make Ruby 3.0.7 your default Ruby version, add to your ~/.zshrc:
# Add to ~/.zshrc
chruby ruby-3.0.7Troubleshooting
Common Issues
- OpenSSL not found: Ensure
openssl@1.1is installed from the rbenv tap - Compilation errors: Verify Xcode Command Line Tools are installed
- chruby doesn't see Ruby: Reload chruby configuration or restart terminal
- Gem install failures: Check gem paths with
gem env
Verification Commands
# Check Ruby version and platform
ruby -v
# Verify gem environment
gem env
# Test basic gem installation
gem install bundler
# Check available Ruby versions in chruby
chruby
# Verify OpenSSL integration
ruby -ropenssl -e 'puts OpenSSL::VERSION'Notes
- This approach bypasses ruby-install's automatic patching issues
- The manual compilation ensures proper library paths for chruby
- The installation is fully compatible with chruby's ruby switching mechanism
Thanks @tritraneh