Apple M1: rbenv install 3.1.2
fails but installing ruby 3.1.2 from source succeeds
#2106
-
Hardware: Apple M1 MacBook Air running Big Sur 11.6.8 Step 1: Run
Step 2: Notice that
Step 3: Install 3.1.2 manually from source, bypassing ruby-build entirely
Step 4: Notice that
Please do not move this to the Discussions tab as the installation works when not using ruby-build. This leads me to believe that it is indeed a ruby-build issue. For what it's worth, I can install ruby 3.1.2 this way with either OpenSSL 3.0 or OpenSSL 1.1 depending on what I provide in the configure step. I can provide Thanks to #1961 (reply in thread) for finding this workaround that makes the source build usable with rbenv. |
Beta Was this translation helpful? Give feedback.
Replies: 39 comments 11 replies
-
Please share full of your logs. |
Beta Was this translation helpful? Give feedback.
-
They are in #1961 |
Beta Was this translation helpful? Give feedback.
-
No, I want to see full of |
Beta Was this translation helpful? Give feedback.
-
The following is the output of running
The rbs-2.1.0 gem successfully compiles/links/loads, and thus the installation fully completes. However, in the ruby-build.20221029165815.98770.log log file from my previous comment (which is the output from So the question becomes: Why does the rbs-2.1.0 gem install successfully in the manual |
Beta Was this translation helpful? Give feedback.
-
Thanks.
The above line is not related with ruby-build. Maybe, build system/toolchains of Ruby core does. I'll investigate its detail at next week. |
Beta Was this translation helpful? Give feedback.
-
I just found that there is a major difference in the rbenv:
manual:
We can see that To recap: When compiling manually, the full
If we then add
Then we get the same error as with rbenv. So I think you may be right - it may not be a ruby-build issue after all. Please do try to check if it's an issue with ruby's build system or toolchain and let me know if I can help with troubleshooting since I can reproduce both scenarios consistently. |
Beta Was this translation helpful? Give feedback.
-
Thanks for narrowing this down, @milosivanovic. |
Beta Was this translation helpful? Give feedback.
-
@hsbt Were you ever able to take a look into this? I'm wondering whether there is something we should fix in ruby-build regarding this. In the meantime, this is what I suggest as workaround to affected users: #1961 (reply in thread) |
Beta Was this translation helpful? Give feedback.
-
Yes, I'll track this issue now. But I couldn't reproduce this with Ventura 13.1 beta and Xcode 14 🤔
We will release all stable versions includes the fixes of Ventura and Xcode14 in Nov 2022. We will wait to try them for users who get same issues. |
Beta Was this translation helpful? Give feedback.
-
@milosivanovic, you should follow up over here with your discussion over in ruby-build! #1961 |
Beta Was this translation helpful? Give feedback.
-
@SeanSith Thanks for the ping. Closing since Ruby |
Beta Was this translation helpful? Give feedback.
-
@mislav Unfortunately I'm still having the same issues noted in the original thread. The discussion over in ruby-build got me going (having to install openssl@3, disable shared-libraries), so it's not a straight-up My command was:
|
Beta Was this translation helpful? Give feedback.
-
@SeanSith Sorry for the trouble. Are you saying that downloading a Ruby 3.1.3 tarball and running It would help us if you posted the full failed build log using a gist. Thanks! |
Beta Was this translation helpful? Give feedback.
-
@mislav the issue regarding the mismatched architecture still occurs on my machine with 3.1.3. I am still on Big Sur and still have Xcode 13.2.1. Steps to reproduce:
During the
The contents of the
The built shared library from the
And it's showing as having arm64 architecture:
|
Beta Was this translation helpful? Give feedback.
-
Here is the full workaround with shared library support enabled:
It installs successfully without any errors. I was able to validate that it was built with shared libraries:
I then redid it but this time building with just
The Could you test the removal of |
Beta Was this translation helpful? Give feedback.
-
Can you check your environmental variable of I still couldn't reproduce this with
and this seems not ruby-build issue. We should move to https://bugs.ruby-lang.org/ |
Beta Was this translation helpful? Give feedback.
-
The environment variable is not set in our standard bash terminal, which is why it was tricky to detect in the first place. It's the configure script which sets it: https://github.com/ruby/ruby/blob/master/configure.ac#L3050 Before
After
After
That's where miniruby gets the And, yes, this is a ruby issue. I will report it at https://bugs.ruby-lang.org/ later today and propose that |
Beta Was this translation helpful? Give feedback.
-
Why only your system affects with This environmental variable used by injecting another libraries like |
Beta Was this translation helpful? Give feedback.
-
It's not only my system:
There are also quite a few who just gave a thumbs up without commenting. But yes, you're right - when we want to override the default memory allocator with jemalloc, we would need DYLD_INSERT_LIBRARIES. I'll report my findings to the ruby team and hopefully we can make more progress on this. |
Beta Was this translation helpful? Give feedback.
-
Thanks so much @milosivanovic for excellent sleuthing and @hsbt for helping. Agreed this should be primarily handled in the Ruby issue tracker. But, is there something that we could do from ruby-build in the meantime as a workaround for all people affected? |
Beta Was this translation helpful? Give feedback.
-
@hsbt I was able to compile and run ruby with jemalloc even after removing
Confirm jemalloc is in use by running
So it does not appear DYLD_INSERT_LIBRARIES is necessary to exist in the manner that it does for jemalloc to be injectable. |
Beta Was this translation helpful? Give feedback.
-
@mislav My (temporary) suggestion would be for ruby-build to strip out that line from the configure script, as per my repro steps. I'm open to hearing if there are other concerns. |
Beta Was this translation helpful? Give feedback.
-
@milosivanovic Thanks for the suggestion. I do not know what DYLD_INSERT_LIBRARIES does, so I'd be careful about stripping it out and potentially negatively affecting builds on other platforms. I welcome suggestions of others who have more knowledge about this and why it's needed in the configure steps 🙇 |
Beta Was this translation helpful? Give feedback.
-
@mislav The linux version of that variable is When a dynamically-built binary tries to reference a symbol from a shared library, the library that the symbol comes from can be overridden with To your point, if jemalloc can work without I'll be submitting all of these findings over to the ruby core team this weekend, so hopefully someone with more knowledge can help us understand what's happening. Thanks @hsbt and @mislav for your patience and help thus far! |
Beta Was this translation helpful? Give feedback.
-
Hi there, I've investigated this issue a little bit, and finally got a repro on my end. Let me put my idea before going that direction. The essential requirement for repro is that SIP is disabled. TL;DR: Please re-enable SIP by following the official instruction and retry Why?
The error repoted during rbs_extension build is produced by the dynamic loader dyld. It says that the Mach-O executable file and the inserted Mach-O dylib by Okay, so we can't set Executable binaries that is code-signed with Apple certificates are called platform binaries: https://developer.apple.com/documentation/endpointsecurity/es_process_t/3228979-is_platform_binary The additional security protections, Hardened Runtime, disables Considering the above discussion, we have two workarounds for now: Workaround 1: Re-enable SIPThis is a little bit tricky, but enabling SIP would also solve the issue because it prevents loading incompatible library through (Potential) Workaround 2: Use clang compiled for arm64
So building with explicit compiler path may solve the issue:
|
Beta Was this translation helpful? Give feedback.
-
Tried the first workaround and was able to install MacOS: Ventura 13.0.1 and Xcode 14.1 - M1 |
Beta Was this translation helpful? Give feedback.
-
@kateinoigakukun Those are excellent findings, thank you for diving deep into this with us. You are right, I have SIP disabled! I will try enabling SIP on the affected machine later today, but it sounds like @ydarbleoj already confirmed this - nice! That might also explain why some users who reinstalled their system saw the issue go away - they likely did not re-enable SIP, or did so after their installation of ruby succeeded. Regarding the architecture differences: The Your theoretical workaround definitely makes sense - I had wondered myself if clang had been built against Having said all of this, if with SIP enabled (which is the default on all macOS systems) the |
Beta Was this translation helpful? Give feedback.
Hi there, I've investigated this issue a little bit, and finally got a repro on my end. Let me put my idea before going that direction.
The essential requirement for repro is that SIP is disabled.
TL;DR: Please re-enable SIP by following the official instruction and retry
rbenv install 3.1.3
Why?
The error repoted during rbs_extension build is produced by the dynamic loader dyld. It says that the Mach-O executable file and the inserted Mach-O dylib by
DYLD_INSERT_LIBRARIES
have incompatible cpu-subtype. Especially, the executable (/usr/bin/clang
) is compiled for arm64e but the dylib (libruby.3.1.dylib
) is compiled for ar…