193

我做了一个rails项目,

rails new test_bootstrap.

成功了。

移动到项目目录并添加了宝石

gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"

并运行

bundle install

之后,我有这个错误。

Installing libv8 (3.16.14.3)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
creating Makefile
지정된 경로를 찾을 수 없습니다.                                                          지정된 경로를 찾을 수
없습니다.                                                          지정된 경로를 찾을 수 없습니다.

c:/RailsInstaller/Ruby1.9.3/lib/ruby/ge
ms/1.9.1/gems/libv8-3.16.14.3/ext/libv8/builder.rb:58:in `setup_python!': libv8 requires
python 2 to be installed in order to build, but it is currently not available (RuntimeErr
or) from c:/RailsInstaller/Ruby1.9.
3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/builder.rb:42:in `block in build_lib
v8/builder.rb:42:in `block in build_libv8!'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib
v8/builder.rb:40:in `chdir'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib
v8/builder.rb:40:in `build_libv8!'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib
v8/location.rb:24:in `install!'
        from extconf.rb:7:in `<main>'                                                    


Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/l
ibv8-3.16.14.3 for inspection.
Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ex
t/libv8/gem_make.out
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot
continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.

对不起一些韩国人。它说,它找不到选择的路径或类似的东西。

我试图运行这个命令

gem install libv8 -v '3.16.14.3' 

抛出同样的错误。

4

18 回答 18

630

试试这个:

gem install libv8 -v '3.16.14.3' -- --with-system-v8

注意: 因为 libv8 是 ruby​​racer 使用的 V8 引擎的接口,所以您可能需要使用 libv8,即使您已经安装了 V8。如果您希望使用自己的 V8 安装,而不是为您构建它,请使用该--with-system-v8选项。

有关更多信息,您可以查看 github 上的 libv8文档

于 2013-10-30T04:47:22.067 回答
160

如何解决 libv8/therubyracer 问题

我遇到了类似的问题,在安装 libv8 后,安装 therubyracer 时出错。这是我的解决方案:

$ gem install libv8 -v '3.16.14.3' -- --with-system-v8
   
$ bundle install

-- 查看安装 therubyracer 的错误 --

$ gem uninstall libv8

$ brew install v8

$ gem install therubyracer

$ bundle install

-- 查看安装 libv8 的错误 --

$ gem install libv8 -v '3.16.14.3' -- --with-system-v8
于 2015-04-17T16:56:46.040 回答
53

我尝试了上面列出的解决方案命令,它看起来非常适合安装单个 gem,但对于捆绑器用户 - 你应该使用 bundle config

利用

bundle config build.libv8 --with-system-v8 

bundle config build.therubyracer --with-system-v8

配置捆绑器以获取安装特定 gem 时要使用的参数

于 2016-04-14T14:15:35.557 回答
50

使用自制软件可以帮助我解决这个错误。

brew tap homebrew/versions
brew install v8-315

gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315

bundle install

见于 ruby​​racer Github 问题。

对于 homebrew 的新版本,因为 homebrew/versions 已被删除:

brew install v8@3.15

gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8@3.15

bundle install

@gorner 的建议(谢谢)

于 2016-04-03T17:00:57.933 回答
7

我不认为你需要therubyracer在 Windows 上使用 gem。它是一个使用 V8 引擎的 javascript 运行时。因此,它正在尝试安装libv8.

您可以安全地从 Gemfile 中删除 gem。

Rails 很乐意使用它可以找到的任何运行时。execjsnodejs都是可能的选项。

Microsoft 已经在 windows 上嵌入了用于 javascript 的 JScript 运行时,Rails 使用它。看到这个了解更多

于 2013-10-30T04:24:21.037 回答
6

解决问题的其他解决方法是在 Gemfile 中将它们分开

group :production do
 gem 'libv8', '~> 3.11.8.3'
 gem 'therubyracer', :platform => :ruby
end

然后运行 ​​bundle 命令:bundle install --without production

于 2014-03-22T15:32:46.637 回答
3

我也无法安装这个 gem 而不是使用

--with-system-v8

曾经尝试进行捆绑更新,这对我来说很好

于 2016-07-20T16:40:26.800 回答
3

在github上找到了这个

假设您已尝试上述步骤,通过 brew 安装了 v8-315 和 v8。

brew unlink v8
brew link --force v8-315
gem install therubyracer -v '0.12.2' -- --with-system-v8
于 2019-09-14T10:45:03.023 回答
2

这对我行得通。把它放在你的 Gemfile

宝石'libv8','〜> 3.16.14.7'

于 2015-01-12T15:11:42.307 回答
1

2020 年 12 月,我们在 Debian 10 虚拟机以及我们本地的 Debian 10 桌面上遇到了编译错误——出乎意料。

Bundle 尝试编译失败 Installing libv8 3.16.14.19 with native extensions

错误日志说:

IOError: [Errno 2] No such file or directory: '/home/username/application/shared/bundle/ruby/2.6.0/gems/libv8-7.3.492.27.1/vendor/build/config/gclient_args.gni'
Running: gclient root
Running: gclient config --spec 'solutions = [
  {
    "url": "https://chromium.googlesource.com/v8/v8.git",
    "managed": False,
    "name": "v8",
    "deps_file": "DEPS",
    "custom_deps": {},
  },
]
'
Running: gclient sync --with_branch_heads
Subprocess failed with return code 1.

我们检查了Google v8 Repo上的标签,发现请求的标签7.3.492.27.1似乎在 Google Repo 上不可用:

libv8 did not install properly, expected binary v8 archive '/home/.../gyp
/libv8_snapshot.a'to exist, but it was not found 
(Libv8::Location::Vendor::ArchiveNotFound)

我们唯一的解决方案是therubyracer从 Gemfile 中完全删除 :-(

于 2020-12-11T09:01:10.323 回答
1

我在本地尝试了以下命令,效果很好:

brew install v8@3.15
gem install libv8 -v 'YOUR_VERSION' -- --with-system-v8
gem install therubyracer -v 'YOUR_VERSION' -- --with-v8-dir=/usr/local/opt/v8@3.15
bundle install
于 2020-06-23T10:25:05.037 回答
1

therubyracer我的问题根本与libv8gem 无关,正如@rishav-bhardwaj 指出的--with-system-v8那样并没有解决问题,而是我不得不执行

bundle update

然后

bundle install

最后

Bundle complete!

错误消失了!

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. An error occurred while installing libv8 (3.16.14.7), and Bundler cannot continue. Make sure that `gem install libv8 -v '3.16.14.7'` succeeds before bundling.

于 2017-03-17T17:15:40.253 回答
1

就我而言,我通过 'mini_racer', '~> 0.2.6' 在我的 Gemfile 中要求解决了这种情况

然后捆绑安装命令起作用了。

于 2019-12-26T11:48:04.890 回答
1

我使用以下方法解决了这个问题:

gem install libv8 -v '3.16.14.19' -- --with-system-v8

于 2021-01-07T16:10:20.063 回答
0

尝试

gem "therubyracer", "~> 0.10.2" 到 Gemfile

并且它将安装依赖的 gem libv8 (3.3.10.4) 并且构建 gem 原生扩展失败的问题得到了解决。

于 2014-08-07T05:30:34.617 回答
0

我觉得这与 libv8 关系不大,而与 therubyracer 关系更大。

在 Rails 应用程序上运行捆绑安装时,我收到了同样的错误。如果您遇到过类似的情况,请尝试在 bundle 之外安装 gem,如下所示:

gem install therubyracer

然后运行捆绑安装。我希望这也适用于你。

于 2017-07-28T14:28:41.210 回答
0

libv8我在使用and时也遇到了问题mini_racer。解决了这个问题

brew install v8

bundle update libv8 mini_racer

使用最新版本mini_racer 0.2.10libv8 7.3.492.27工作就像一个魅力。

于 2020-05-10T18:15:24.273 回答
0

3.16.14.7使用以下命令解决了 libv8问题:

gem install libv8 -v '3.16.14.7' -- --with-system-v8

然后bundle install顺利完成。

于 2017-07-28T11:29:25.990 回答