安装unf_ext时,Bundle安装失败。 "安装unf_ext时无法分配内存错误"

时间:2016-04-06 16:53:27

标签: ruby-on-rails ruby bundler

我的远程服务器上发生了这个错误。

虽然这在当地环境中无法复制。

使用原生扩展安装unf_ext 0.0.7.2

Gem :: Ext :: BuildError:错误:无法构建gem原生扩展。

/home/ubuntu/.rbenv/versions/2.1.2/bin/ruby extconf.rb

无法分配内存 - /home/ubuntu/.rbenv/versions/2.1.2/bin/ruby extconf.rb 2>& 1

Gem files will remain installed in /home/ubuntu/switch-web/shared/bundle/ruby/2.1.0/gems/unf_ext-0.0.7.2 for inspection.
Results logged to /home/ubuntu/switch-web/shared/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0-static/unf_ext-0.0.7.2/gem_make.out
An error occurred while installing unf_ext (0.0.7.2), and Bundler cannot
continue.
Make sure that `gem install unf_ext -v '0.0.7.2'` succeeds before bundling.

我已经检查了我的服务器的ram空间,它仍然相当不错(2gb免费)。

2 个答案:

答案 0 :(得分:1)

我通过升级服务器来修复此问题,增加了内存。

答案 1 :(得分:1)

很老的问题,但我可以建议一个替代答案。如果服务器没有交换分区,则可以临时创建并启用交换文件,而不用升级服务器资源(并可能会增加成本):

以root身份运行:

# create a 512 Mb file
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

# assign the correct permissions
chown root:root /swapfile1
chmod 0600 /swapfile1

# initialize the file as a swap file
mkswap /swapfile1

# enable swap
swapon /swapfile1

构建完成后,您可以禁用交换文件并将其删除:

swapoff /swapfile1
rm /swapfile1