简体   繁体   English

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

[英]Bundle install fails when install unf_ext. “Cannot allocate memory error when installing unf_ext”

I have this bug that happens on my remote server. 我在远程服务器上发生了这个错误。

Though this isn't replicable in my local environment. 虽然这在我的本地环境中无法复制。

Installing unf_ext 0.0.7.2 with native extensions 使用本机扩展安装unf_ext 0.0.7.2

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. Gem :: Ext :: BuildError:错误:无法构建gem原生扩展。

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

Cannot allocate memory - /home/ubuntu/.rbenv/versions/2.1.2/bin/ruby extconf.rb 2>&1 无法分配内存 - /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.

I've checked the ram space for my server and it's still pretty decent (2gb free). 我已经检查了我的服务器的ram空间,它仍然相当不错(2gb免费)。

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

Pretty old question, but I can suggest an alternative answer. 很老的问题,但我可以建议一个替代的答案。 Instead of upgrading the server resources (and possibly costs), if the server does not have a swap partition you could temporarily create and enable a swap file: 如果服务器没有交换分区,您可以临时创建并启用交换文件,而不是升级服务器资源(可能还有成本):

Run as root: 以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

Once the build is complete, you can disable the swap file and delete it: 构建完成后,您可以禁用交换文件并将其删除:

swapoff /swapfile1
rm /swapfile1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM