我在使用capistrano将我的网站部署到我的EC2实例时遇到问题。捆绑安装,宝石安装therubyracer(和libv8)与各种宝石版本都工作正常。捆绑仅在封顶部署时失败。我尝试卸载并重新安装某些宝石(在我的本地主机和EC2实例上),以及许多其他建议,但似乎没有任何工作。
我正在使用Rails 4和Capistrano 2.15
我的错误来自
cap deploy
是
servers: ["ip address"]
[ip address] executing command
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 extconf.rb
checking for main() in -lpthread... yes
Warning! Unable to load libv8 ~> 3.16.14.
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib64
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby2.0
--with-pthreadlib
--without-pthreadlib
--enable-debug
--disable-debug
/usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- libv8 (LoadError)
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from extconf.rb:29:in `<main>'
相关的Gemfile摘录:
gem 'therubyracer', '~> 0.12.1'
gem 'libv8', '~> 3.16.14.3', :platform => :ruby
最后,建议的mkmf.log文件包含以下代码:
have_library: checking for main() in -lpthread... -------------------- yes
"gcc -o conftest -I/usr/include/ruby/2.0 -I/usr/include/ruby/2.0/ruby/backward -I/usr/include/ruby/2.0 -I. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC conftest.c -L. -L/usr/lib64 -L. -fstack-protector -rdynamic -Wl,-export-dynamic -m64 -L/usr/lib64/ruby/2.0 -lruby -lpthread -lrt -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -o conftest -I/usr/include/ruby/2.0 -I/usr/include/ruby/2.0/ruby/backward -I/usr/include/ruby/2.0 -I. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC conftest.c -L. -L/usr/lib64 -L. -fstack-protector -rdynamic -Wl,-export-dynamic -m64 -L/usr/lib64/ruby/2.0 -lruby -lpthread -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:5:57: error: ‘main’ undeclared (first use in this function)
int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
^
conftest.c:5:57: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:5:32: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
6: int main(int argc, char **argv)
7: {
8: if (argc > 1000000) {
9: printf("%p", &t);
10: }
11:
12: return 0;
13: }
/* end */
"gcc -o conftest -I/usr/include/ruby/2.0 -I/usr/include/ruby/2.0/ruby/backward -I/usr/include/ruby/2.0 -I. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC conftest.c -L. -L/usr/lib64 -L. -fstack-protector -rdynamic -Wl,-export-dynamic -m64 -L/usr/lib64/ruby/2.0 -lruby -lpthread -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:5:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
int t(void) { main(); return 0; }
^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int t(void) { main(); return 0; }
6: int main(int argc, char **argv)
7: {
8: if (argc > 1000000) {
9: printf("%p", &t);
10: }
11:
12: return 0;
13: }
/* end */