GemNotFound 在 EC2 纳米实例上的捆绑安装期间,但适用于微型实例
GemNotFound during bundle install on EC2 nano instances, but works on micro instances
我在 Rails 应用程序上有一个 Ruby 使用 Ruby 2.6.5 (rbenv) 和 Rails 5.2
我已经创建了安装脚本来配置 EC2 实例并将应用程序部署到该实例。
它与 t3a.micro
实例一致地工作,但如果我使用配置为使用 t3a.nano
的相同部署脚本(在 t3.nano
上也失败)实例,则始终失败。错误是:
/home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/2.6.0/bundler/spec_set.rb:91:in `block in materialize': Could not find nokogiri-1.10.9 in any of the sources (Bundler::GemNotFound)
from /home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/2.6.0/bundler/spec_set.rb:85:in `map!'
from /home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/2.6.0/bundler/spec_set.rb:85:in `materialize'
...
我可以手动安装 gem:
$ which gem
/home/ubuntu/.rbenv/shims/gem
$ gem install nokogiri
Fetching mini_portile2-2.4.0.gem
Fetching nokogiri-1.10.9.gem
Successfully installed mini_portile2-2.4.0
Building native extensions. This could take a while...
Successfully installed nokogiri-1.10.9
Parsing documentation for mini_portile2-2.4.0
Installing ri documentation for mini_portile2-2.4.0
Parsing documentation for nokogiri-1.10.9
Installing ri documentation for nokogiri-1.10.9
Done installing documentation for mini_portile2, nokogiri after 2 seconds
2 gems installed
$
但是如果我 bundle install
应用程序失败:
...
Running 'compile' for libxml2 2.9.10...
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.8/mkmf.log
extconf failed, uncaught signal 9
Gem files will remain installed in /home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.8 for
inspection.
Results logged to
/home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.8/gem_make.out
An error occurred while installing nokogiri (1.10.8), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.8' --source 'https://rubygems.org/'` succeeds before bundling.
知道发生了什么或如何解决它吗?为什么 bundle install
与 gem install
的区别在于关心我是在 micro
还是 nano
ec2 实例上?
如果您想测试自己,项目在 github: https://github.com/mawise/simpleblog 您必须更改 deploymentscripts/deploy-aws.rb
以引用不同的实例类型。
(我知道一些日志引用 1.10.8
和其他 1.10.9
,我看到另一个 post 表明 1.10.9
有问题所以我尝试了较低版本结果相同。)
我遇到过这个问题。很可能您的 EC2 实例在编译 gem 时 运行 内存不足,并且无法安装所有 gem。 t3a.nano 实例有 0.5 GB 的内存,而 t3a.micro 有 1.0 GB。
我通过简单地创建一个交换文件在我的应用程序中解决了这个问题。这是一个弹性 beanstalk 应用程序,但您可以根据自己的应用程序调整它。
# run as root:
dd if=/dev/zero of=/var/swapfile bs=1M count=512
chmod 600 /var/swapfile
mkswap /var/swapfile
swapon /var/swapfile
echo "/var/swapfile none swap sw 0 0" >> /etc/fstab
我在 Rails 应用程序上有一个 Ruby 使用 Ruby 2.6.5 (rbenv) 和 Rails 5.2
我已经创建了安装脚本来配置 EC2 实例并将应用程序部署到该实例。
它与 t3a.micro
实例一致地工作,但如果我使用配置为使用 t3a.nano
的相同部署脚本(在 t3.nano
上也失败)实例,则始终失败。错误是:
/home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/2.6.0/bundler/spec_set.rb:91:in `block in materialize': Could not find nokogiri-1.10.9 in any of the sources (Bundler::GemNotFound)
from /home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/2.6.0/bundler/spec_set.rb:85:in `map!'
from /home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/2.6.0/bundler/spec_set.rb:85:in `materialize'
...
我可以手动安装 gem:
$ which gem
/home/ubuntu/.rbenv/shims/gem
$ gem install nokogiri
Fetching mini_portile2-2.4.0.gem
Fetching nokogiri-1.10.9.gem
Successfully installed mini_portile2-2.4.0
Building native extensions. This could take a while...
Successfully installed nokogiri-1.10.9
Parsing documentation for mini_portile2-2.4.0
Installing ri documentation for mini_portile2-2.4.0
Parsing documentation for nokogiri-1.10.9
Installing ri documentation for nokogiri-1.10.9
Done installing documentation for mini_portile2, nokogiri after 2 seconds
2 gems installed
$
但是如果我 bundle install
应用程序失败:
...
Running 'compile' for libxml2 2.9.10...
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.8/mkmf.log
extconf failed, uncaught signal 9
Gem files will remain installed in /home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.8 for
inspection.
Results logged to
/home/ubuntu/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.8/gem_make.out
An error occurred while installing nokogiri (1.10.8), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.8' --source 'https://rubygems.org/'` succeeds before bundling.
知道发生了什么或如何解决它吗?为什么 bundle install
与 gem install
的区别在于关心我是在 micro
还是 nano
ec2 实例上?
如果您想测试自己,项目在 github: https://github.com/mawise/simpleblog 您必须更改 deploymentscripts/deploy-aws.rb
以引用不同的实例类型。
(我知道一些日志引用 1.10.8
和其他 1.10.9
,我看到另一个 post 表明 1.10.9
有问题所以我尝试了较低版本结果相同。)
我遇到过这个问题。很可能您的 EC2 实例在编译 gem 时 运行 内存不足,并且无法安装所有 gem。 t3a.nano 实例有 0.5 GB 的内存,而 t3a.micro 有 1.0 GB。
我通过简单地创建一个交换文件在我的应用程序中解决了这个问题。这是一个弹性 beanstalk 应用程序,但您可以根据自己的应用程序调整它。
# run as root:
dd if=/dev/zero of=/var/swapfile bs=1M count=512
chmod 600 /var/swapfile
mkswap /var/swapfile
swapon /var/swapfile
echo "/var/swapfile none swap sw 0 0" >> /etc/fstab