【发布时间】:2021-08-13 21:06:46
【问题描述】:
我正在我的新 Apple Silicon 机器上安装 ruby on rails,以正确安装 v8 和 therubyracer。 As abundantly documented,为了能够执行基本的 rails 命令,我正在解决一些问题。
我一直使用this Github thread 作为我的参考点。我使用 arch -x86_64 安装了 v8@3.15 以使用安装在 Rosetta 终端上的 Homebrew。之后我安装了我需要的特定 gem:
arch -x86_64 gem install libv8 -v '3.16.14.19' -- --with-system-v8
arch -x86_64 gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/v8@3.15
之后我返回我的常规终端。然后我运行 bundle install 然后 rails s (或任何 rails 命令),我看到以下错误:
dlopen(/Users/myuser/.rvm/gems/ruby-2.6.3@myproject/gems/therubyracer-0.12.3/lib/v8/init.bundle, 9): no suitable image found. Did find: (LoadError)
/Users/myuser/.rvm/gems/ruby-2.6.3@myproject/gems/therubyracer-0.12.3/lib/v8/init.bundle: mach-o, but wrong architecture
/Users/myuser/.rvm/gems/ruby-2.6.3@myproject/gems/therubyracer-0.12.3/lib/v8/init.bundle: mach-o, but wrong architecture - /Users/myuser/.rvm/gems/ruby-2.6.3@myproject/gems/therubyracer-0.12.3/lib/v8/init.bundle
如果我从 Rosetta 终端运行它,我会看到同样的错误。我还没有找到任何能让我更接近诊断此错误的东西。这很困难,因为如果我在没有 arch -x86_64 的情况下安装相同的 gem,我会看到一组 errors described here。
我有两个版本的 Homebrew:一个链接到 Rosetta 终端,一个用于本地 Apple Silicon。我一直小心翼翼地使用 Rosetta Terminal Homebrew 来安装 v8 和本地 Apple Silicon Homebrew。
非常感谢您的时间和精力。我很乐意在必要时提供更多背景信息。谢谢。
【问题讨论】:
-
你确定你真的需要 therubyracer 或 libv8 吗?在现代版本的 Rails 中,资产管道实际上并不需要 therubyracer,而且它更容易为 JS 运行时安装 Node。例如,Heroku 不鼓励将 therubyracer 用作记忆猪。
-
可能不需要 therubyracer,但目前远离它并不是优先事项。感谢您指出有关 Heroku 的一些信息。
-
@Atticus 试试this.
-
@Chandan 我有但无济于事。
标签: ruby-on-rails rubygems apple-m1 therubyracer libv8