【问题标题】:therubyracer error ERROR: While executing gem ... (NoMethodError) undefined method `size' for nil:NilClasstherubyracer 错误错误:执行 gem 时 ... (NoMethodError) 未定义方法“大小”为 nil:NilClass
【发布时间】:2013-10-09 10:56:34
【问题描述】:

在将 therubyracer 与 Ruby 2.0.0.p0 和 Rails 4.0 一起安装时,我收到以下错误

ERROR:  While executing gem ... (NoMethodError)
    undefined method `size' for nil:NilClass

如果我在使用 bundle install 时安装了相同的 gem,则会出现依赖 gem 错误,请参阅下面的日志。

NoMethodError: undefined method `size' for nil:NilClass
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.

请找到我尝试安装的 GIT 的链接 https://github.com/niquola/angularjs-on-rails

【问题讨论】:

  • 总是发布整个堆栈跟踪或链接到它的要点或其他任何内容。
  • 您之前尝试过安装 libv8 吗?什么操作系统,是否安装了 node.js?

标签: ruby-on-rails ruby ruby-on-rails-4


【解决方案1】:

我今天遇到了同样的问题。并解决了。我正在使用 Lubuntu 13.04、RVM 和 Ruby 1.9.3。

可能是你的平台不在rubyracer使用的libv8的支持列表中,需要自己编译gem。

直接来自:https://github.com/cowboyd/libv8

从 git 获取 libv8 源代码,编译它并从以下位置构建 gem:

git clone git://github.com/cowboyd/libv8.git
cd libv8
bundle install
bundle exec rake checkout
bundle exec rake compile
bundle exec rake build

安装gem:

gem install ./pkg/libv8-3.16.14.3.gem

在我的项目文件夹上执行“bundle update”时仍然出现错误,因为 gem 似乎没有被复制到我的 bundle gem 缓存中。

Bundler::GemspecError: Could not read gem at /home/devmachine/.rvm/gems/ruby-1.9.3-p448/cache/libv8-3.16.14.3.gem. It may be corrupted.
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.

所以我在再次运行“bundle update”之前将它复制到了这个文件夹中:

cp /home/devmachine/Downloads/libv8/pkg/libv8-3.16.14.3.gem /home/devmachine/.rvm/gems/ruby-1.9.3-p448/cache

请记住,您应该在执行编译之前安装以下软件包:

  • 混帐
  • git-svn
  • libv8-dev
  • 蟒蛇
  • g++

希望对你有帮助。

- = 更好的解决方案 = -

Actually a case of RTFM.

您不必使用本机扩展构建自己的 gem。您只需要在系统中安装 v8 库即可。之后,您可以将 bundler 配置为使用本机 v8。为此,您应该在系统上安装 V8 引擎。

# Get Google v8 engine from git
git clone git://github.com/v8/v8.git v8 && cd v8
# Install GYP
make dependencies
# I had problems with warnings and strict aliasing. So I ignored and switched them off.
make native werror=no strictaliasing=off

现在您应该可以从系统使用 v8 了:

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

执行此命令后,您可以继续使用通常的“捆绑安装”..

- = 建议的解决方案 = -

忘记 v8 并改用 Node.js:

wget http://nodejs.org/dist/node-latest.tar.gz
tar zxvf node-latest.tar.gz
# cd into extracted directory (e.g. cd node-v0.10.14)
make
make install

从您的项目 Gemfile 中删除“therubyracer”依赖项。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-05
  • 1970-01-01
  • 2015-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多