Coder Social home page Coder Social logo

Comments (60)

joedarc avatar joedarc commented on August 23, 2024 64

I was able to get this installed on my M1 MacBook Pro using arch -x86_64. I followed some steps on this blog to get two homebrews set-up. Once I had the alias of ibrew using the x86 arch, I was able to install the gem by doing the following:

ibrew tap homebrew/versions
ibrew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

Should just need to put your version in instead. Hope this helps.

from libv8.

stanneeru avatar stanneeru commented on August 23, 2024 47

try out below.. did work for me

brew install [email protected]
bundle config --local build.libv8 --with-system-v8
bundle config --local build.therubyracer --with-v8-dir=/usr/local/opt/[email protected]
bundle install
https://stackoverflow.com/questions/34613215/gem-therubyracer-does-not-install-even-if-libv8-is-installed

from libv8.

dojutsu-user avatar dojutsu-user commented on August 23, 2024 28

I have tried this out already and it didn't work on Apple SIlicon Laptop. I have also mentioned this in the logs already in the issue description.

from libv8.

tiagogeraldi avatar tiagogeraldi commented on August 23, 2024 20

This is a simplified solution for M1 macs

https://gist.github.com/fernandoaleman/868b64cd60ab2d51ab24e7bf384da1ca#gistcomment-3723625

from libv8.

dojutsu-user avatar dojutsu-user commented on August 23, 2024 19

This issue is still unsolved.

from libv8.

lfrancarj avatar lfrancarj commented on August 23, 2024 19

I am able to install theruby racer using @joedarc's instructions but I get the following when I start my server:

Same here.
I was able to install libv8 using the intel compatible brew version and therubyracer.
I'm using rbenv

But as soon as I start the server, i get the same dyld: lazy symbol binding failed: Symbol not found:... error message

from libv8.

professor avatar professor commented on August 23, 2024 14

I've noticed that homebrew on M1 will install in /opt/homebrew, not /usr/local. I see that several of these solutions rely on brew placing v8 in /usr/local which makes me think that the solutions are not for M1.

Also brew install [email protected] fails on M1 BigSur for me. Error: [email protected]: no bottle available!

from libv8.

ZASMan avatar ZASMan commented on August 23, 2024 12

2022 and I still can't get therubyracer installed on the latest Mac either.

from libv8.

amitk avatar amitk commented on August 23, 2024 12

My operating system is Monterey and these are the steps worked for me

$ ibrew tap homebrew/core
$ ibrew install [email protected]
$ bundle config --local build.libv8 --with-system-v8
$ bundle config --local build.therubyracer --with-v8-dir=/usr/local/opt/[email protected]

ibrew here refers to solutions suggested by @joedarc here.
Thanks.

from libv8.

VparkalauMY avatar VparkalauMY commented on August 23, 2024 11

I was able to get this installed on my M1 MacBook Pro using arch -x86_64. I followed some steps on this blog to get two homebrews set-up. Once I had the alias of ibrew using the x86 arch, I was able to install the gem by doing the following:

ibrew tap homebrew/versions
ibrew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

Should just need to put your version in instead. Hope this helps.

Unfortunately it did not work at M1 BigSur. But this solution works for intel platform and Catalina v10.15.7

from libv8.

artoodeeto avatar artoodeeto commented on August 23, 2024 8

after bundle install. running the server bin/rails s I get an error:

/Users/raphaelgako/.rvm/gems/ruby-2.3.6/gems/therubyracer-0.12.3/lib/v8.rb:4:in `require': dlopen(/Users/raphaelgako/.rvm/gems/ruby-2.3.6/gems/therubyracer-0.12.3/lib/v8/init.bundle, 0x0009): symbol not found in flat namespace '__ZN2v810ScriptData10PreCompileEPKci' - /Users/raphaelgako/.rvm/gems/ruby-2.3.6/gems/therubyracer-0.12.3/lib/v8/init.bundle (LoadError)
	from /Users/raphaelgako/.rvm/gems/ruby-2.3.6/gems/therubyracer-0.12.3/lib/v8.rb:4:in `<top (required)>'
	from /Users/raphaelgako/.rvm/gems/ruby-2.3.6/gems/therubyracer-0.12.3/lib/therubyracer.rb:1:in `require'
	from /Users/raphaelgako/.rvm/gems/ruby-2.3.6/gems/therubyracer-0.12.3/lib/therubyracer.rb:1:in `<top (required)>'
	from /Users/raphaelgako/.rvm/rubies/ruby-2.3.6/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `require'

anyone has the same problem? I'm using M1.

from libv8.

artoodeeto avatar artoodeeto commented on August 23, 2024 6

@lloeki thank you for responding. I've decided to return the laptop no use fixing an unfixable problem. thank you. appreciate the reply.

from libv8.

monfresh avatar monfresh commented on August 23, 2024 6

After seeing so many people struggle with therubyracer on Apple Silicon Macs, I wrote this detailed guide that explains the history behind therubyracer, why you probably don't even need it anymore, and how to replace it with better options:

https://www.rubyonmac.dev/how-to-install-therubyracer-on-m1-m2-apple-silicon-mac

from libv8.

Nowaker avatar Nowaker commented on August 23, 2024 5

Here's my catch-all solution to this fiasco in Gemfile. Hope it helps someone:

# M1 Macs must use mini_racer. therubyracer is broken: https://github.com/rubyjs/libv8/issues/312
# Intel Macs may use either - but therubyracer requires `brew install [email protected]` and `bundle config build.therubyracer --with-v8-dir=$(brew --prefix)/opt/[email protected]`, while mini_racer works out of the box.
# New Linuxes may use either.
# Old Linuxes must use therubyracer, as mini_racer requires GCC 8+.
is_mac = RUBY_PLATFORM.include?('darwin')
gem 'mini_racer', install_if: is_mac
gem 'therubyracer', install_if: !is_mac
gem 'libv8-node', '16.10.0.0'

Please note that if you use Rails 4.x and, by definition, Bundler 1.x, you'll experience problems with musl version of libv8-node being forced by Bundler, which then causes an error, because one doesn't exist. You'll need to gem install the correct stuff first, so Bundler doesn't attempt to install the incorrect thing. In local dev:

for lib in libv8-node mini_racer; do grep -Po "(?<=$lib\', ).*" Gemfile | tr -d "'" | xargs gem install $lib -v; done

And when you deploy with Capistrano to Linux, you'll need to do the equivalent on the server before every deploy:

  desc 'Install libv8-node and mini_racer before bundle install'
  task :pre_bundler_install do
    on roles(:all) do
      execute <<~EOF
        export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
        export GEM_PATH=""
        export GEM_HOME="#{shared_path}/bundle/ruby/#{rbenv_ruby_version_major}"
        cd #{release_path}
        for lib in libv8-node mini_racer; do
          VERSION=$(grep -Po "(?<=$lib\', \').*" Gemfile | tr -d "'")
          REQUEST_VERSION=${VERSION:+-v $VERSION}
          rbenv exec gem install --conservative "$lib" $REQUEST_VERSION
        done
      EOF
    end
  end

Please note this is a knowledge dump from me. Use this information as you please, but I won't be answering questions or debugging your situation.

from libv8.

gilthoniel02 avatar gilthoniel02 commented on August 23, 2024 4

None of these suggestions work with Apple M1 Pro, Monterrey 12.4. ☚ī¸

from libv8.

lloeki avatar lloeki commented on August 23, 2024 2

You might be interested in libv8-node which has such binaries.

from libv8.

TorvaldsDB avatar TorvaldsDB commented on August 23, 2024 2

I was able to get this installed on my M1 MacBook Pro using arch -x86_64. I followed some steps on this blog to get two homebrews set-up. Once I had the alias of ibrew using the x86 arch, I was able to install the gem by doing the following:

ibrew tap homebrew/versions
ibrew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

Should just need to put your version in instead. Hope this helps.

it will cause other problems

$ rake routes                                                                                                                                                                                                                                                        
rake aborted!
LoadError: Could not open library '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so': dlopen(/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so, 0x0005): tried: '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.so' (no such file), '/usr/lib/cld.so' (no such file), '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.0.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.0.so' (no such file), '/usr/lib/cld.0.so' (no such file)
/Users/bdu/workspace/appen/make/config/application.rb:12:in `<top (required)>'
/Users/bdu/workspace/appen/make/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
$ rake -T       
rake aborted!
LoadError: Could not open library '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so': dlopen(/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so, 0x0005): tried: '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.so' (no such file), '/usr/lib/cld.so' (no such file), '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.0.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.0.so' (no such file), '/usr/lib/cld.0.so' (no such file)
/Users/bdu/workspace/appen/make/config/application.rb:12:in `<top (required)>'
/Users/bdu/workspace/appen/make/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

@TorvaldsDB, You can once try Rosette Terminal for your whole development setup. follow here It has saved me a lot of hours of being stuck at various issues.

Thanks @amitk-vmware I'm not sure whether it works, but it looks too hacker. I have to use the terminal instead of the iTerm2 or original terminal. Maybe I will have a try it finally, but I wish there were a better way to fix it.

from libv8.

neoswf avatar neoswf commented on August 23, 2024 2

Thank you @joedarc!!!! You saved me tons of time. Thank you!!!!!

from libv8.

niick7 avatar niick7 commented on August 23, 2024 2

A. I'm using macOS Monterey version 12.5 (maybe the macOS latest version). And all 5 below solutions didn't work for me. Any other suggestion?

  1. Install [email protected] by Homebrew. And then config therubyracer with [email protected]:

brew install [email protected]
bundle config --local build.libv8 --with-system-v8
bundle config --local build.therubyracer --with-v8-dir=/usr/local/opt/[email protected]
bundle install

  1. Use multiple homebrew with this url: https://soffes.blog/homebrew-on-apple-silicon . And then use ibrew instead of brew to fix the issue.

ibrew tap homebrew/versions
ibrew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

Notes:

ibrew tap homebrew/versions

is deprecated. And you could search v8 by this command:

ibrew search v8

  1. Use gem mini_racer as an alternative way to replace therubyracer. I'm not sure by changing to another gem will generate other issues or not. However, install mini_racer didn't work with my current macOS although I tried with multiple versions of mini_racer gem.
  2. Use duplicate terminal, Rosetta. It didn't work for me.
  3. Use clang++ and brew to install therubyracer. And it didn't work as well.

$ clang++ -v
// install intel v8:
$ arch -x86_64 brew install [email protected]
// Build libv8 with the v8 engine that you just installed via brew:
$ gem install libv8 -v "3.16.14.19" -- --with-system-v8
// Provide a compatible C++ compiler and specify path to the v8 directory you just brew installed:
$ CXX=clang++ gem install therubyracer -v "0.12.3" -- --with-v8-dir=$(arch -x86_64 brew --prefix [email protected])

B. Here is my Mac information:

macOS Monterey version 12.5
Chip: Apple M1 Pro

ruby -v
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]

bundle -v
Bundler version 1.17.2

brew -v
Homebrew 3.5.6
Homebrew/homebrew-core (git revision 6e3e8c9eaea; last commit 2022-07-21)
Homebrew/homebrew-cask (git revision 19fcfaa54f; last commit 2022-07-21)

uname -a
Darwin Dinhs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 arm64

libv8 version: 3.16.14.19

therubyracer version: 0.12.0

too long to read. Hopefully there's an easy way

I tried all suggested solution in this post but no one worked for me.

I'm using the latest macOS version: Monterey 12.5 and Apple M1 Pro chip.

from libv8.

marko-avlijas avatar marko-avlijas commented on August 23, 2024 2

@dojutsu-user
I successfully installed libv8/therubyracer on M1 Macbook Pro today at work.

TL/DR

  • you did not export compiler flags like brew told you after you installed v8
  • you are mixing and matching arm and x86_64 architecture. Compile everything (brew, ruby..) using rosetta terminal.

I am not sure if last point is really necessary but it worked for me after many hours of pain.


What I did was:

  • remove all brew installations & packages, all ruby versions & gems
  • setup rosetta Iterm (finder -> apps, right click on iTerm, Duplicate and Rename to Rosetta iTerm, right click -> Get Info, In General, check the Open using Rosetta check-box.)

Key is to install brew, ruby & everything in rosetta terminal.

Command arch must return i386 if you setup rosetta terminal correctly.

Then installation is normal:

brew install [email protected]

After this step brew will tell you what exports you need. Copy paste them in terminal or therubyracer installation will fail.
It looks something like this:

export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

Rest is easy.

gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=$(brew --prefix [email protected])

from libv8.

bradical avatar bradical commented on August 23, 2024 1

Hi @VishalAher0108, while I can't help you directly with that problem since we never got therubyracer to build properly, I can say that swapping in mini_racer which is maintained was relatively painless.

from libv8.

amitk030 avatar amitk030 commented on August 23, 2024 1

I was able to get this installed on my M1 MacBook Pro using arch -x86_64. I followed some steps on this blog to get two homebrews set-up. Once I had the alias of ibrew using the x86 arch, I was able to install the gem by doing the following:

ibrew tap homebrew/versions
ibrew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

Should just need to put your version in instead. Hope this helps.

it will cause other problems

$ rake routes                                                                                                                                                                                                                                                        
rake aborted!
LoadError: Could not open library '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so': dlopen(/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so, 0x0005): tried: '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.so' (no such file), '/usr/lib/cld.so' (no such file), '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.0.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.0.so' (no such file), '/usr/lib/cld.0.so' (no such file)
/Users/bdu/workspace/appen/make/config/application.rb:12:in `<top (required)>'
/Users/bdu/workspace/appen/make/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
$ rake -T       
rake aborted!
LoadError: Could not open library '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so': dlopen(/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so, 0x0005): tried: '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.so' (no such file), '/usr/lib/cld.so' (no such file), '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.0.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.0.so' (no such file), '/usr/lib/cld.0.so' (no such file)
/Users/bdu/workspace/appen/make/config/application.rb:12:in `<top (required)>'
/Users/bdu/workspace/appen/make/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

@TorvaldsDB, You can once try Rosette Terminal for your whole development setup. follow here It has saved me a lot of hours of being stuck at various issues.

from libv8.

MattBudz avatar MattBudz commented on August 23, 2024 1

I was able to get a successful installation on an M1 macbook running macOS 12.5 by adding the following to my Gemfile:

gem 'libv8-node', '16.10.0.0'
gem 'mini_racer'

Without the libv8-node gem in the gemfile, libv8-node was just being added as a dependency of mini_racer and always pulling the x86_64-darwin version for some reason. When adding the libv8-node gem into the gemfile explicitly, it pulled the correct arm64 version.

from libv8.

VparkalauMY avatar VparkalauMY commented on August 23, 2024

I have tried this out already and it didn't work on Apple SIlicon Laptop. I have also mentioned this in the logs already in the issue description.

did you resolve it? I have the same issue.

`brew install --build-from-source [email protected]
==> Cloning https://chromium.googlesource.com/external/gyp.git
Updating /Users/vladimir/Library/Caches/Homebrew/[email protected]
==> Checking out revision f7bc250ccc4d619a1cf238db87e5979f89ff36d7
HEAD is now at f7bc250c Make gyp/win32 compatible with upstream ninja.
HEAD is now at f7bc250c Make gyp/win32 compatible with upstream ninja.
==> Downloading https://github.com/v8/v8-git-mirror/archive/3.15.11.18.tar.gz
Already downloaded: /Users/vladimir/Library/Caches/Homebrew/downloads/26ea05158c6c6ebb67cc42075858df9a986f9c615513933b1e62bb707f707854--v8-3.15.11.18.tar.gz
==> make native -j8 library=shared snapshot=on console=readline
Last 15 lines from /Users/vladimir/Library/Logs/Homebrew/[email protected]/01.make:
Atomic32 Acquire_Load(volatile const Atomic32* ptr);
^
In file included from ../src/conversions.cc:32:
In file included from ../src/conversions-inl.h:42:
In file included from ../src/platform.h:100:
In file included from ../src/lazy-instance.h:94:
../src/once.h:115:7: error: no matching function for call to 'Acquire_Load'
if (Acquire_Load(once) != ONCE_STATE_DONE) {
^~~~~~~~~~~~
../src/atomicops.h:125:10: note: candidate function not viable: no known conversion from 'v8::internal::OnceType *' (aka 'long *') to 'const volatile v8::internal::Atomic32 *' (aka 'const volatile int ') for 1st argument
Atomic32 Acquire_Load(volatile const Atomic32
ptr);
^
5 errors generated.
make[1]: *** [/private/tmp/v8-3.15-20210220-8824-33trcn/v8-3.15.11.18/out/native/obj.target/preparser_lib/src/conversions.o] Error 1
make: *** [native] Error 2

Do not report this issue to Homebrew/brew or Homebrew/core!

`

from libv8.

joedarc avatar joedarc commented on August 23, 2024

I was able to get this installed on my M1 MacBook Pro using arch -x86_64. I followed some steps on this blog to get two homebrews set-up. Once I had the alias of ibrew using the x86 arch, I was able to install the gem by doing the following:

ibrew tap homebrew/versions
ibrew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

Should just need to put your version in instead. Hope this helps.

Unfortunately it did not work at M1 BigSur. But this solution works for intel platform and Catalina v10.15.7

Sorry I should have mentioned, this is working on my M1 MacBook on BigSur 11.2 using the steps I provided.

from libv8.

KyleAsaff avatar KyleAsaff commented on August 23, 2024

I am able to install theruby racer using @joedarc's instructions but I get the following when I start my server:

17:58:09 web.1  | started with pid 70200
17:58:10 web.1  | [70200] Puma starting in cluster mode...
17:58:10 web.1  | [70200] * Version 4.3.6 (ruby 2.6.6-p146), codename: Mysterious Traveller
17:58:10 web.1  | [70200] * Min threads: 5, max threads: 5
17:58:10 web.1  | [70200] * Environment: development
17:58:10 web.1  | [70200] * Process workers: 3
17:58:10 web.1  | [70200] * Preloading application
17:58:13 web.1  | dyld: lazy symbol binding failed: Symbol not found: __ZN2v82V821AddGCPrologueCallbackEPFvNS_6GCTypeENS_15GCCallbackFlagsEES1_
17:58:13 web.1  |   Referenced from: /Users/kyle/.rvm/gems/ruby-2.6.6/gems/therubyracer-0.12.3/lib/v8/init.bundle
17:58:13 web.1  |   Expected in: flat namespace
17:58:13 web.1  | 
17:58:13 web.1  | dyld: Symbol not found: __ZN2v82V821AddGCPrologueCallbackEPFvNS_6GCTypeENS_15GCCallbackFlagsEES1_
17:58:13 web.1  |   Referenced from: /Users/kyle/.rvm/gems/ruby-2.6.6/gems/therubyracer-0.12.3/lib/v8/init.bundle
17:58:13 web.1  |   Expected in: flat namespace
17:58:13 web.1  | 
17:58:13 web.1  | terminated by SIGIOT
17:58:13 system | sending SIGTERM to all processes

anyone know how to fix this?

from libv8.

KyleAsaff avatar KyleAsaff commented on August 23, 2024

@lfrancarj let me know if you find a work around or a solution, I'm still stuck 😕

from libv8.

VishalAher0108 avatar VishalAher0108 commented on August 23, 2024

Hello

I search and referred to many links from Google but it didn't work for me. Still, I'm facing the same issue while installing therubyracer gem.

I'm using macOS Big Sur version: 11.3.1 (M1)
Ruby version = 2.4.1
Rails Version = 5.2.0

Whenever I install therubyracer gem, I'm getting the following error.


@vishalaher@Vishals-MacBook-Air ro-ec % gem install therubyracer

Building native extensions. This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.

current directory: /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/ext/libv8
/Users/vishalaher/.rvm/rubies/ruby-2.4.1/bin/ruby -I /Users/vishalaher/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0 -r ./siteconf20210507-54026-1q3hc8w.rb extconf.rb
creating Makefile
Applying /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/patches/disable-building-tests.patch
Applying /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/patches/disable-werror-on-osx.patch
Applying /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/patches/disable-xcode-debugging.patch
Applying /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/patches/do-not-imply-vfp3-and-armv7.patch
Applying /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/patches/do-not-use-MAP_NORESERVE-on-freebsd.patch
Applying /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/patches/do-not-use-vfp2.patch
Applying /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/patches/fPIC-for-static.patch
Compiling v8 for arm
Using python 2.7.16
Using compiler: c++ (clang version 12.0.5)
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Beginning compilation. This will take some time.
Building v8 with env CXX=c++ LINK=c++ /usr/bin/make arm.release vfp2=off vfp3=on hardfp=on ARFLAGS.target=crs werror=no
GYP_GENERATORS=make
build/gyp/gyp --generator-output="out" build/all.gyp
-Ibuild/standalone.gypi --depth=.
-Dv8_target_arch=arm
-S.arm -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=false -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror='' -Dv8_use_arm_eabi_hardfloat=true
CXX(target) /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/preparser_lib/src/allocation.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from ../src/allocation.cc:33:
../src/utils.h:33:10: fatal error: 'climits' file not found
#include
^~~~~~~~~
1 error generated.
make[1]: *** [/Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [arm.release] Error 2
/Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/ext/libv8/location.rb:36:in block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound) from /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in each'
from /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in verify_installation!' from /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19/ext/libv8/location.rb:26:in install!'
from extconf.rb:7:in `

'

extconf failed, exit code 1

Gem files will remain installed in /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/gems/libv8-3.16.14.19 for inspection.
Results logged to /Users/vishalaher/.rvm/gems/ruby-2.4.1@ro-ec/extensions/-darwin-20/2.4.0/libv8-3.16.14.19/gem_make.out


Can anyone help me to solve this issue?

from libv8.

atticusliu avatar atticusliu commented on August 23, 2024

Has anyone figured out a solution to these issues?

from libv8.

joedarc avatar joedarc commented on August 23, 2024

@professor if you go to the link I provided in my original answer you'll see why, the solution that worked for me required two installations of homebrew. The normal installation will be located at /opt/homebrew correct, but the Rosetta installed version will be at /usr/local.

from libv8.

samsmata avatar samsmata commented on August 23, 2024

anyone having answer for rake commands are not working?.

from libv8.

rodrigotoledo avatar rodrigotoledo commented on August 23, 2024

#312 (comment)
this works for me using rvm

from libv8.

nonuabi avatar nonuabi commented on August 23, 2024

I have tried this out already and it didn't work on Apple SIlicon Laptop. I have also mentioned this in the logs already in the issue description.

did you resolve it? I have the same issue.

`brew install --build-from-source [email protected] ==> Cloning https://chromium.googlesource.com/external/gyp.git Updating /Users/vladimir/Library/Caches/Homebrew/[email protected] ==> Checking out revision f7bc250ccc4d619a1cf238db87e5979f89ff36d7 HEAD is now at f7bc250c Make gyp/win32 compatible with upstream ninja. HEAD is now at f7bc250c Make gyp/win32 compatible with upstream ninja. ==> Downloading https://github.com/v8/v8-git-mirror/archive/3.15.11.18.tar.gz Already downloaded: /Users/vladimir/Library/Caches/Homebrew/downloads/26ea05158c6c6ebb67cc42075858df9a986f9c615513933b1e62bb707f707854--v8-3.15.11.18.tar.gz ==> make native -j8 library=shared snapshot=on console=readline Last 15 lines from /Users/vladimir/Library/Logs/Homebrew/[email protected]/01.make: Atomic32 Acquire_Load(volatile const Atomic32* ptr); ^ In file included from ../src/conversions.cc:32: In file included from ../src/conversions-inl.h:42: In file included from ../src/platform.hđŸ’¯ In file included from ../src/lazy-instance.h:94: ../src/once.h:115:7: error: no matching function for call to 'Acquire_Load' if (Acquire_Load(once) != ONCE_STATE_DONE) { ^~~~~~~~~~~~ ../src/atomicops.h:125:10: note: candidate function not viable: no known conversion from 'v8::internal::OnceType *' (aka 'long *') to 'const volatile v8::internal::Atomic32 *' (aka 'const volatile int ') for 1st argument Atomic32 Acquire_Load(volatile const Atomic32 ptr); ^ 5 errors generated. make[1]: *** [/private/tmp/v8-3.15-20210220-8824-33trcn/v8-3.15.11.18/out/native/obj.target/preparser_lib/src/conversions.o] Error 1 make: *** [native] Error 2

Do not report this issue to Homebrew/brew or Homebrew/core!

`

@ VparkalauMY, Did you get any working solution for this issue? because I'm facing the same issue and I'm able to install v8 using ibrew, then installed rubyracer using this command.

gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

But new whenever starting the puma server this error occure.

rails s
[DEPRECATED] Bootsnap's autoload_paths_cache: option is deprecated and will be removed. If you use Zeitwerk this option is useless, and if you are still using the classic autoloader upgrading is recommended.
[DEPRECATED] Bootsnap's disable_trace: option is deprecated and will be removed. If you use Ruby 2.5 or newer this option is useless, if not upgrading is recommended.
/Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in require': dlopen(/Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rmagick-4.2.4/lib/RMagick2.bundle, 0x0009): symbol not found in flat namespace '_AcquireDrawInfo' - /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rmagick-4.2.4/lib/RMagick2.bundle (LoadError) from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in block in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in register' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in require' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rmagick-4.2.4/lib/rmagick_internal.rb:23:in

'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in require' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in block in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in register' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in require' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/rmagick-4.2.4/lib/rmagick.rb:1:in '
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in require' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in block in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in register' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in require' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/2.6.0/bundler/runtime.rb:81:in block (2 levels) in require'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/2.6.0/bundler/runtime.rb:76:in each' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/2.6.0/bundler/runtime.rb:76:in block in require'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/2.6.0/bundler/runtime.rb:65:in each' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/2.6.0/bundler/runtime.rb:65:in require'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/2.6.0/bundler.rb:114:in require' from /Users/abhishekverma/Desktop/galaxy/config/application.rb:9:in '
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in require' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in block in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in register' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in require' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in block in perform'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in tap' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in perform'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/thor-1.1.0/lib/thor/command.rb:27:in run' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in invoke_command'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/thor-1.1.0/lib/thor.rb:392:in dispatch' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.1.7/lib/rails/command/base.rb:63:in perform'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.1.7/lib/rails/command.rb:44:in invoke' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/railties-5.1.7/lib/rails/commands.rb:16:in '
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in require' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in block in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in register' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require_with_bootsnap_lfi'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in require' from /Users/abhishekverma/Desktop/galaxy/bin/rails:9:in <top (required)>'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in load' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in call'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in call' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client.rb:30:in run'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/spring-2.1.1/bin/spring:49:in <top (required)>' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in load'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in <top (required)>' from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /Users/abhishekverma/.rbenv/versions/2.6.9/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Users/abhishekverma/Desktop/galaxy/bin/spring:15:in <top (required)>'
from bin/rails:3:in load' from bin/rails:3:in '

from libv8.

VparkalauMY avatar VparkalauMY commented on August 23, 2024

It looks like you have a conflict related to ruby version. Also i think you can try to change the gems version .

from libv8.

chrishough avatar chrishough commented on August 23, 2024

This issue is still open for both M1 and non-M1 machines. libv8 does not work

from libv8.

bensaufley avatar bensaufley commented on August 23, 2024

Related comment over on #318: #318 (comment)

from libv8.

iamajvillalobos avatar iamajvillalobos commented on August 23, 2024

try out below.. did work for me

brew install [email protected] bundle config --local build.libv8 --with-system-v8 bundle config --local build.therubyracer --with-v8-dir=/usr/local/opt/[email protected] bundle install https://stackoverflow.com/questions/34613215/gem-therubyracer-does-not-install-even-if-libv8-is-installed

This work for me. I still don't think we have native m1 solution for this.

from libv8.

lloeki avatar lloeki commented on August 23, 2024

I still don't think we have native m1 solution for this.

You're not going to, the first libv8 version that supports M1 is V8 9.something, and therubyracer is stuck at V8 3.x.

Switch to mini_racer if you can, and encourage projects to move to it if you have such transient dependencies.

from libv8.

samsmata avatar samsmata commented on August 23, 2024

from libv8.

artoodeeto avatar artoodeeto commented on August 23, 2024

@samsmata do you think this will be resolve anytime soon? Just wondering because if not im going to return the laptop. We have legacy code at my work and we are using ruby 2.3.6 and wont upgrade it, do you think this will be a problem on this specific ruby version? thank you for your response and I appreciate it.

from libv8.

lloeki avatar lloeki commented on August 23, 2024

We have legacy code at my work and we are using ruby 2.3.6 and wont upgrade it

The first Ruby version that supports M1 is 2.7.1 (IIRC, maybe 2.7.2), so unless you're running it exclusively as aarch64-linux a VM or in Docker for Mac (which runs a VM) you're opening yourself to a world of hurt (that is, if things are even working).

You're not going to, the first libv8 version that supports M1 is V8 9.something, and therubyracer is stuck at V8 3.x.

Also, I reiterate this 👆

from libv8.

lloeki avatar lloeki commented on August 23, 2024

That, or you install and run Ruby as Intel under Rosetta 2, but Rosetta 2 does have issues with libv8 due to its very dynamic nature.

from libv8.

bensaufley avatar bensaufley commented on August 23, 2024

Support for Ruby 2.3 ended in March of 2019; it's not safe to be using anymore.

from libv8.

bradical avatar bradical commented on August 23, 2024

What does the:

$ ibrew tap homebrew/core

do here?

from libv8.

amitk avatar amitk commented on August 23, 2024

What does the:

$ ibrew tap homebrew/core

do here?

While trying to install v8. I was getting error regading no formulae found from brew. To get that formula It was suggested to use ibrew tap homebrew/versions, but returned

Error: homebrew/versions was deprecated. This tap is now empty and all its contents were either deleted or migrated.

And somewhere I read they have been migrated to core. Hence, I used that.

from libv8.

TorvaldsDB avatar TorvaldsDB commented on August 23, 2024

I was able to get this installed on my M1 MacBook Pro using arch -x86_64. I followed some steps on this blog to get two homebrews set-up. Once I had the alias of ibrew using the x86 arch, I was able to install the gem by doing the following:

ibrew tap homebrew/versions
ibrew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

Should just need to put your version in instead. Hope this helps.

it will cause other problems

$ rake routes                                                                                                                                                                                                                                                        
rake aborted!
LoadError: Could not open library '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so': dlopen(/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so, 0x0005): tried: '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.so' (no such file), '/usr/lib/cld.so' (no such file), '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.0.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.0.so' (no such file), '/usr/lib/cld.0.so' (no such file)
/Users/bdu/workspace/appen/make/config/application.rb:12:in `<top (required)>'
/Users/bdu/workspace/appen/make/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
$ rake -T       
rake aborted!
LoadError: Could not open library '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so': dlopen(/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so, 0x0005): tried: '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.so' (no such file), '/usr/lib/cld.so' (no such file), '/opt/homebrew/Cellar/rbenv/1.2.0/versions/2.5.5/lib/ruby/gems/2.5.0/gems/cld-0.8.0/ext/cld/lib/cld.0.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/cld.0.so' (no such file), '/usr/lib/cld.0.so' (no such file)
/Users/bdu/workspace/appen/make/config/application.rb:12:in `<top (required)>'
/Users/bdu/workspace/appen/make/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

from libv8.

solidiquis avatar solidiquis commented on August 23, 2024

Hey ya'll, I've dealt with every iteration of this problem possible while trying to install libv8 and therubyracer on my M1. The two prominent issues I've faced were GCC issues and dyld: lazy symbol binding failed: Symbol not found:... errors. Ultimately this is what I did after ton of digging into source code to successfully install my version of libv8 and therubyracer:

Quick disclaimer: My terminal emulator is not using Rosetta mode.

First you'll need to make sure you have a C/C++ compiler that v8 is compatible with. Libv8 recommends GCCv4.4 or higher, so I just opted to use clang++. This is what mine looks like:

$ clang++ -v
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Next, I just install [email protected] and the gems individually:

# install intel v8:
$ arch -x86_64 brew install [email protected]

# Build libv8 with the v8 engine that you just installed via brew:
$ gem install libv8 -v "3.16.14.19" -- --with-system-v8 

# Provide a compatible C++ compiler and specify path to the v8 directory you just brew installed:
$ CXX=clang++ gem install therubyracer -v "0.12.3" -- --with-v8-dir=$(arch -x86_64 brew --prefix [email protected])

This method uses a compatible C/C++ compiler which solves this issue, and having both libv8 and therubyracer build from the same v8 folder prevents symbol loading errors.

from libv8.

niick7 avatar niick7 commented on August 23, 2024

A. I'm using macOS Monterey version 12.5 (maybe the macOS latest version). And all 5 below solutions didn't work for me. Any other suggestion?

  1. Install [email protected] by Homebrew. And then config therubyracer with [email protected]:

brew install [email protected]
bundle config --local build.libv8 --with-system-v8
bundle config --local build.therubyracer --with-v8-dir=/usr/local/opt/[email protected]
bundle install

  1. Use multiple homebrew with this url: https://soffes.blog/homebrew-on-apple-silicon . And then use ibrew instead of brew to fix the issue.

ibrew tap homebrew/versions
ibrew install v8-315
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

Notes:

ibrew tap homebrew/versions

is deprecated. And you could search v8 by this command:

ibrew search v8

  1. Use gem mini_racer as an alternative way to replace therubyracer. I'm not sure by changing to another gem will generate other issues or not. However, install mini_racer didn't work with my current macOS although I tried with multiple versions of mini_racer gem.

  2. Use duplicate terminal, Rosetta. It didn't work for me.

  3. Use clang++ and brew to install therubyracer. And it didn't work as well.

$ clang++ -v
// install intel v8:
$ arch -x86_64 brew install [email protected]
// Build libv8 with the v8 engine that you just installed via brew:
$ gem install libv8 -v "3.16.14.19" -- --with-system-v8
// Provide a compatible C++ compiler and specify path to the v8 directory you just brew installed:
$ CXX=clang++ gem install therubyracer -v "0.12.3" -- --with-v8-dir=$(arch -x86_64 brew --prefix [email protected])

B. Here is my Mac information:

macOS Monterey version 12.5
Chip: Apple M1 Pro

ruby -v
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]

bundle -v
Bundler version 1.17.2

brew -v
Homebrew 3.5.6
Homebrew/homebrew-core (git revision 6e3e8c9eaea; last commit 2022-07-21)
Homebrew/homebrew-cask (git revision 19fcfaa54f; last commit 2022-07-21)

uname -a
Darwin Dinhs-MBP.lan 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 arm64

libv8 version: 3.16.14.19

therubyracer version: 0.12.0

from libv8.

bradical avatar bradical commented on August 23, 2024

Thanks @marko-avlijas. What is the result of this? Is this effectively installing homebrew and running everything over x86? What do you do for apps/packages that you actually want to install via homebrew but using arm?

from libv8.

marko-avlijas avatar marko-avlijas commented on August 23, 2024

from libv8.

memlirestelica avatar memlirestelica commented on August 23, 2024

@marko-avlijas Thanks for this extra information

export LDFLAGS="-L/usr/local/something"
export CPPFLAGS="-I/usr/local/something"

These two flags are very IMPORTANT

from libv8.

memlirestelica avatar memlirestelica commented on August 23, 2024

@marko-avlijas Thanks for this extra information
export LDFLAGS="-L/usr/local/something" export CPPFLAGS="-I/usr/local/something"
These two flags are very IMPORTANT

did it work on your end?

Yes it did.

from libv8.

marko-avlijas avatar marko-avlijas commented on August 23, 2024

from libv8.

memlirestelica avatar memlirestelica commented on August 23, 2024

@Drewberrysteph

Setup a new terminal running on rosetta 2

Here is how to: link

  1. Install brew on rosetta 2 terminal

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

  1. Install rbenv on rosetta 2

brew install rbenv

  1. Install ruby on rosetta 2 terminal - CFLAGS="-Wno-error=implicit-function-declaration" RUBY_CONFIGURE_OPTS='--with-readline-dir=/usr/local/opt/readline/' rbenv install 2.7.0

(takes a while)

  1. Install libraries and add flags

brew install [email protected]

Brew tells you to do these

export LDFLAGS="-L/usr/local/something"
export CPPFLAGS="-I/usr/local/something"

Last step:

gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=$(brew --prefix [email protected])

from libv8.

marko-avlijas avatar marko-avlijas commented on August 23, 2024

from libv8.

ard35 avatar ard35 commented on August 23, 2024

@dojutsu-user I successfully installed libv8/therubyracer on M1 Macbook Pro today at work.

TL/DR

  • you did not export compiler flags like brew told you after you installed v8
  • you are mixing and matching arm and x86_64 architecture. Compile everything (brew, ruby..) using rosetta terminal.

I am not sure if last point is really necessary but it worked for me after many hours of pain.

What I did was:

  • remove all brew installations & packages, all ruby versions & gems
  • setup rosetta Iterm (finder -> apps, right click on iTerm, Duplicate and Rename to Rosetta iTerm, right click -> Get Info, In General, check the Open using Rosetta check-box.)

Key is to install brew, ruby & everything in rosetta terminal.

Command arch must return i386 if you setup rosetta terminal correctly.

Then installation is normal:

brew install [email protected]

After this step brew will tell you what exports you need. Copy paste them in terminal or therubyracer installation will fail. It looks something like this:

export LDFLAGS="-L/usr/local/something"
export CPPFLAGS="-I/usr/local/something"

Rest is easy.

gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=$(brew --prefix [email protected])

Can confirm this worked for me (M1 Monterey 12.5.1 with ruby v 2.3.3) after days of troubleshooting. Other guides have mentioned to install things normally on arm64 and then install libv8 and therubyracer on i386 (rosetta terminal) but this caused problems. Installing everything solely on i386 works great.

If you do a fresh install for i386, make sure you really clean out all of the old paths from the arm64 installations and use the new paths from the i386 install. You don't want to be mixing paths from different brew installs.

from libv8.

marko-avlijas avatar marko-avlijas commented on August 23, 2024

@Drewberrysteph
I suspect you didn't do exports correctly.

What is output of each of these commands?

echo $LDFLAGS
echo $CPPFLAGS
history | grep export

from libv8.

marko-avlijas avatar marko-avlijas commented on August 23, 2024

from libv8.

TruongDuyIT avatar TruongDuyIT commented on August 23, 2024

I was able to get a successful installation on an M1 macbook running macOS 12.5 by adding the following to my Gemfile:

gem 'libv8-node', '16.10.0.0'
gem 'mini_racer'

Without the libv8-node gem in the gemfile, libv8-node was just being added as a dependency of mini_racer and always pulling the x86_64-darwin version for some reason. When adding the libv8-node gem into the gemfile explicitly, it pulled the correct arm64 version.

Thanks a lot. It work for me.
=> MacOs Monterey 12.6. M2 chip.

from libv8.

lloeki avatar lloeki commented on August 23, 2024

Re 3.16.14.19: read this, move to mini_racer.

@monfresh thanks for the article, I'm sure it helped people! That said you should not rely on v8 under Rosetta 2, v8 does wonky stuff with its JIT that trips it up on odd corner cases (not even counting that downgrading your whole stack to x86_64 is suboptimal and comes with its won set of complexities).

We cannot stress enough moving to mini_racer + libv8-node, which supports Apple Silicon.

Closing.

from libv8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.