Failed to install ruby 3.1.0 on M1 #1933
-
Tried to install ruby 3.1.0 via rbenv, but it returns failed. It said Output$ rbenv install 3.1.0
Downloading openssl-1.1.1l.tar.gz...
-> https://www.openssl.org/source/openssl-1.1.1l.tar.gz
Installing openssl-1.1.1l...
Installed openssl-1.1.1l to /Users/puer/.rbenv/versions/3.1.0
Downloading ruby-3.1.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz
Installing ruby-3.1.0...
ruby-build: using readline from homebrew
BUILD FAILED (macOS 12.2 using ruby-build 20220125)
Inspect or clean up the working tree at /var/folders/p7/bg9zlhk97dd0kydc9ss7w_9h0000gn/T/ruby-build.20220208143322.15659.B7yYav
Results logged to /var/folders/p7/bg9zlhk97dd0kydc9ss7w_9h0000gn/T/ruby-build.20220208143322.15659.log
Last 10 log lines:
linking shared-library libruby.3.1.dylib
ld: library not found for -lcapstone
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libruby.3.1.dylib] Error 1
make: *** Waiting for unfinished jobs....
transdb.h updated
transform_mjit_header: making external definition static inline: rb_vm_lvar_exposed, Init_vm_stack_canary, rb_vm_opt_cfunc_p, rb_vm_opt_mod, rb_vm_ic_hit_p, rb_vm_splat_array, rb_vm_defined, rb_vm_cc_general, rb_aliased_callable_method_entry, rb_find_defined_class_by_owner, rb_vm_call_ivar_attrset_p, rb_iseq_only_kwparam_p, rb_iseq_only_optparam_p, rb_vm_set_ivar_idx, rb_vm_setinstancevariable, rb_vm_setclassvariable, rb_vm_getclassvariable, rb_vm_rewrite_cref, rb_vm_get_cref, rb_vm_block_ep_update, rb_vm_cref_new_toplevel, rb_vm_cref_dup_without_refinements, rb_vm_frame_block_handler, rb_vm_cframe_keyword_p, rb_vm_ep_local_ep
transform_mjit_header: making declaration static inline: rb_vm_lvar_exposed, rb_vm_lvar_exposed, Init_vm_stack_canary, rb_vm_rewrite_cref, rb_vm_frame_block_handler, rb_vm_block_ep_update, rb_vm_ep_local_ep
transform_mjit_header: SKIPPED to transform: __sigbits, isspecial, isrune, isphonogram, isnumber, isideogram, ishexnumber, digittoint, toupper, tolower, toascii, isxdigit, isupper, isspace, ispunct, isprint, islower, isgraph, isdigit, iscntrl, isblank, isalpha, isalnum, __wcwidth, __isctype, __istype, isascii, __sincospi, __sincospif, __sincos, __sincosf, __inline_isnormall, __inline_isnormald, __inline_isnormalf, __inline_signbitl, __inline_signbitd, __inline_signbitf, __inline_isnanl, __inline_isnand, __inline_isnanf, __inline_isinfl, __inline_isinfd, __inline_isinff, __inline_isfinitel, __inline_isfinited, __inline_isfinitef, __darwin_fd_clr, __darwin_fd_set, __darwin_fd_isset, __darwin_check_fd_set, __sputc
ln -sf ../../../.ext/include/arm64-darwin21/rb_mjit_min_header-3.1.0.h include/ruby-3.1.0/arm64-darwin21/rb_mjit_min_header-3.1.0.h Environment
$ rbenv --version
rbenv 1.2.0 $ uname -a
Darwin xxx 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T8101 arm64 $ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /opt/homebrew/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install` support: /opt/homebrew/bin/rbenv-install (ruby-build 20220125)
Counting installed Ruby versions: none
There aren't any Ruby versions installed under '/Users/puer/.rbenv/versions'.
You can install Ruby versions like so: rbenv install 3.1.0
Checking RubyGems settings: OK
Auditing installed plugins: OK |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
I have solved this issue by export capstone library (I'm using Fish shell). $ set -gx LDFLAGS "-L/opt/homebrew/opt/capstone/lib"
$ set -gx CPPFLAGS "-I/opt/homebrew/opt/capstone/include"
$ rbenv install 3.1.0
Downloading openssl-1.1.1l.tar.gz...
-> https://www.openssl.org/source/openssl-1.1.1l.tar.gz
Installing openssl-1.1.1l...
Installed openssl-1.1.1l to /Users/puer/.rbenv/versions/3.1.0
Downloading ruby-3.1.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz
Installing ruby-3.1.0...
ruby-build: using readline from homebrew
Installed ruby-3.1.0 to /Users/puer/.rbenv/versions/3.1.0 But I don't if this is the best solution. |
Beta Was this translation helpful? Give feedback.
-
Normally capstone is optional. We use it in YJIT but only when cppflags="-DRUBY_DEBUG" is specified. Are you building in debug mode? |
Beta Was this translation helpful? Give feedback.
-
Just to update everybody, we're in the process of porting YJIT to Rust and hoping to upstream that next month. This should fix the capstone issue as the library will only be used when building in dev mode. |
Beta Was this translation helpful? Give feedback.
-
I had to remove my Otherwise I still got:
and in the mentioned
|
Beta Was this translation helpful? Give feedback.
-
My complete working solution below for asdf on Sonoma 14.1.2. Similar to others, but for some reason it was also complaining about not being able to find capstone. install_jemalloc.sh
output:
and
|
Beta Was this translation helpful? Give feedback.
-
I think there might still be something missing with this, but I'm not sure how to triage/debug it and I've resolved the issue for me locally by removing capstone gem before installing ruby. I tried this on 2 systems, both M3 Max chipsets:
It failed for both of us but we fixed it:
This was with Ruby 3.1.2, I haven't tried other versions but happy to do additional testing if needed On my machine, with all my configs, I had installed the same version of ruby a number of times, months ago, before I had colima (and capstone) installed, so I don't think it's directly related to my config. I didn't try setting the LDFLAG for capstone, but I expect that could actually maybe fix it. I noted in another thread here that I saw similar-ish anomalous behavior with Since that issue I've been adding LDFLAGS for every homebrew dependency that suggests to add them in their output/info (which seems overkill tbh) |
Beta Was this translation helpful? Give feedback.
I have solved this issue by export capstone library (I'm using Fish shell).
But I don't if this is the best solution.