【发布时间】:2016-02-19 02:28:22
【问题描述】:
这是我在控制台中的代码和输出:
root@a:/home/rails/car_main# bundle install
You have requested:
rails = 4.2
The bundle currently has rails locked at 4.0.2.
Try running `bundle update rails`
这是我所做的并输出:
root@a:/home/rails/car_main# bundle update rails
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies............
Using rake 10.5.0
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4 (was 4.7.5)
Using thread_safe 0.3.5
Using builder 3.2.2 (was 3.1.4)
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4 (was 1.5.5)
Using mime-types 2.99 (was 1.25.1)
Using arel 6.0.3 (was 4.0.2)
Installing bcrypt 3.1.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/bcrypt-3.1.10/ext/mri
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-e5ct6z.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-e5ct6z.rb extconf.rb 2>&1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/bcrypt-3.1.10 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/bcrypt-3.1.10/gem_make.out
Installing bcrypt-ruby 3.1.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/bcrypt-ruby-3.1.2/ext/mri
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-e88mem.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-e88mem.rb extconf.rb 2>&1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/bcrypt-ruby-3.1.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/bcrypt-ruby-3.1.2/gem_make.out
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using thor 0.19.1
Using bundler 1.11.2
Using hike 1.2.3
Using multi_json 1.11.2
Using tilt 1.4.1
Using sass 3.4.21
Using will_paginate 3.0.4
Installing ffi 1.9.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/ffi-1.9.10/ext/ffi_c
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-u62vla.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-u62vla.rb extconf.rb 2>&1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/ffi-1.9.10 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.10/gem_make.out
Using diff-lcs 1.2.5
Installing unf_ext 0.0.7.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/unf_ext-0.0.7.1/ext/unf_ext
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-1n8ty2l.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-1n8ty2l.rb extconf.rb 2>&1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/unf_ext-0.0.7.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.1/gem_make.out
Using ffaker 2.1.0
在此之后,当我键入 bundle install 时,我仍然收到错误
好的。我用内存做什么?我以 5 美元的价格使用数字海洋水滴,我的网站非常简单。 我在这个问题中做了这里的建议: https://askubuntu.com/questions/253466/why-am-i-frequently-getting-this-cannot-allocate-memory-error 这是输出:
root@a:/home/rails/car_main# ps --sort -rss -eo rss,pid,command | head
RSS PID COMMAND
75920 1538 unicorn worker[0] -D -c /etc/unicorn.conf -E production
74176 1541 unicorn worker[1] -D -c /etc/unicorn.conf -E production
73988 1543 unicorn worker[2] -D -c /etc/unicorn.conf -E production
73828 1546 unicorn worker[3] -D -c /etc/unicorn.conf -E production
11972 1057 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
10464 1535 unicorn master -D -c /etc/unicorn.conf -E production
7508 4037 postgres: rails rails_project_production 127.0.0.1(56865) idle
6788 1630 -bash
5732 1563 postgres: rails rails_project_production 127.0.0.1(56745) idle
更新2:
我按照 cmets 链接中的建议打印此内容
root@a:/home/rails/car_main# sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
问题依然存在。
我现在会尝试停止 postgres
Update 3 我试图停止并启动 postgres(我不确定我是否在 Google 上搜索过如何正确执行此操作,所以这里是代码和输出:
root@a:/usr/bin# /etc/init.d/postgresql stop
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "ru_RU.UTF-8",
LC_MONETARY = "ru_RU.UTF-8",
LC_ADDRESS = "ru_RU.UTF-8",
LC_TELEPHONE = "ru_RU.UTF-8",
LC_NAME = "ru_RU.UTF-8",
LC_MEASUREMENT = "ru_RU.UTF-8",
LC_IDENTIFICATION = "ru_RU.UTF-8",
LC_NUMERIC = "ru_RU.UTF-8",
LC_PAPER = "ru_RU.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
* Stopping PostgreSQL 9.3 database server [ OK ]
root@a:/usr/bin# /etc/init.d/postgresql start
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "ru_RU.UTF-8",
LC_MONETARY = "ru_RU.UTF-8",
LC_ADDRESS = "ru_RU.UTF-8",
LC_TELEPHONE = "ru_RU.UTF-8",
LC_NAME = "ru_RU.UTF-8",
LC_MEASUREMENT = "ru_RU.UTF-8",
LC_IDENTIFICATION = "ru_RU.UTF-8",
LC_NUMERIC = "ru_RU.UTF-8",
LC_PAPER = "ru_RU.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
* Starting PostgreSQL 9.3 database server * perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "ru_RU.UTF-8",
LC_MONETARY = "ru_RU.UTF-8",
LC_ADDRESS = "ru_RU.UTF-8",
LC_TELEPHONE = "ru_RU.UTF-8",
LC_NAME = "ru_RU.UTF-8",
LC_MEASUREMENT = "ru_RU.UTF-8",
LC_IDENTIFICATION = "ru_RU.UTF-8",
LC_NUMERIC = "ru_RU.UTF-8",
LC_PAPER = "ru_RU.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
The PostgreSQL server failed to start. Please check the log output:
2016-02-18 12:42:32 EST FATAL: could not map anonymous shared memory: Cannot allocate memory
2016-02-18 12:42:32 EST HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space. To reduce the request size (currently 147783680 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
更新 4: 我打印 htop:这是输出: 我应该杀死哪些进程?
更新 5:
我又跑了一次bundle update 然后我遇到了一些错误并提示安装捆绑程序,所以我安装了它
root@a:/home/rails/car_main# apt-get install bundler
然后我再次进行了捆绑更新:
root@a:/home/rails/car_main# bundle update
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler (LoadError)
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/bin/bundle:7:in `<main>'
更新 6: 所以我再次运行捆绑更新,它给了我一个无法安装 sqlite3 的错误并建议手动安装它所以我这样做了,这是输出:
root@a:/home/rails/car_main# gem install sqlite3 -v '1.3.8'
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/gems/sqlite3-1.3.8/ext/sqlite3
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-26242-ueiluc.rb extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... yes
checking for sqlite3_enable_load_extension()... yes
checking for sqlite3_load_extension()... yes
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.8/mkmf.log
current directory: /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/gems/sqlite3-1.3.8/ext/sqlite3
make "DESTDIR=" clean
current directory: /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/gems/sqlite3-1.3.8/ext/sqlite3
make "DESTDIR="
compiling database.c
compiling backup.c
compiling exception.c
compiling statement.c
statement.c: In function ‘bind_param’:
statement.c:261:7: warning: implicit declaration of function ‘RBIGNUM’ [-Wimplicit-function-declaration]
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
In file included from statement.c:1:0:
./sqlite3_ruby.h:16:34: error: invalid type argument of ‘->’ (have ‘int’)
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
^
statement.c:261:11: note: in expansion of macro ‘RBIGNUM_LEN’
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
statement.c:261:32: error: ‘SIZEOF_BDIGITS’ undeclared (first use in this function)
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
statement.c:261:32: note: each undeclared identifier is reported only once for each function it appears in
statement.c: In function ‘reset_bang’:
statement.c:293:7: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
int status;
^
statement.c: In function ‘clear_bindings’:
statement.c:313:7: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
int status;
^
make: *** [statement.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/gems/sqlite3-1.3.8 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.8/gem_make.out
我将删除 gemfile 中的 sqlite 版本,希望对您有所帮助
【问题讨论】:
-
为什么要downwote?我错过了什么?我打印命令得到一个错误。做了我想做的事,得到了奇怪的输出,并在这里问了一个问题,提供了详细信息。谁不赞成我解释这个问题有什么问题?
-
引用您的堆栈跟踪:
Cannot allocate memory -
@mymlyn 好的,请查看更新
-
如果我不得不猜测会与不知道 gcc 在哪里有关:stackoverflow.com/questions/6119153/…
-
此时您似乎没有更多可以杀死的进程了,并且您几乎可以在 droplet 上获得所有可用的 RAM。再次尝试
bundle update rails,看看它是否有效。如果没有,最简单的解决方案是获得更多 RAM;否则,您也许可以使用编译器标志来调整 gcc 以在编译时使用更少的内存。
标签: ruby-on-rails