安装therubyracer宝石出现错误

5

我是Ruby的新手。当我尝试“gem install therubyracer”时,出现以下错误:

C:\Users\Desktop>gem install therubyracer
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
        ERROR: Failed to build gem native extension.

    C:/Ruby193/bin/ruby.exe extconf.rb
checking for main() in -lpthread... no
*** extconf.rb failed ***
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}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby193/bin/ruby
        --with-pthreadlib
        --without-pthreadlib
        --enable-debug
        --disable-debug
C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `initialize': No such file or directory - C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/.location.yml (Errno::ENOENT)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `open'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/location.rb:15:in `load!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/lib/libv8.rb:6:in `configure_makefile'
        from extconf.rb:32:in `<main>'


Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.0/ext/v8/gem_make.out

C:\Users\Desktop>

我尝试在Google和Stackoverflow的一些类似帖子中搜索,但都没有解决这个问题。

mkmf.log


(注:mkmf.log是一个文件名,无需翻译)
have_library: checking for main() in -lpthread... -------------------- no

"gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby193/lib -L.      -lmsvcrt-ruby191  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby193/lib -L.      -lmsvcrt-ruby191 -lpthread  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:7:53: error: 'main' undeclared (first use in this function)
conftest.c:7:53: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

"gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby193/lib -L.      -lmsvcrt-ruby191 -lpthread  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:7:1: warning: implicit declaration of function 'main'
conftest.c:10:6: warning: 'argc' is used uninitialized in this function
conftest.c:7:5: note: 'argc' was declared here
c:/devkit193/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lpthread
collect2: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: int t() { main(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

嗯...你有检查mkmf.log文件吗?我们能看一下吗? - Dan Grahn
我包含了我的mkmf.log文件。 - user2803152
这似乎是一个mingw32的问题。我对此没有太多经验。尝试手动安装它。 - Dan Grahn
可能是 therubyracer gem 在 Windows 上的问题 的重复。 - Brad Werth
我查看了那些帖子,但是没有一个能够解决我的问题。 - user2803152
请原谅我,但我不明白您的问题是什么...您正在尝试在不支持它的系统上构建一个您不需要的 gem。您想要实现什么目标? - Brad Werth
4个回答

9

这对我解决了问题:

gem uninstall libv8
gem install therubyracer

Source:


4

对于我的情况:

gem install libv8 -v '3.16.14.15' -- --with-system-v8
gem install therubyracer -v '0.12.1' -- --with-v8-dir=/usr/local/Cellar/v8@3.15/3.15.11.18_1

1

您不需要它(我也认为它不受支持)。只需将您的Gemfile更改为以下内容:gem 'therubyracer',platforms::ruby并重新运行bundler。


0

我想最简单的方法就是使用宝石的最新版本。所以我更新了我的Gemfile文件,将其指向最新版本,如下所示:

gem "therubyracer", "~> 0.10.2"

然后我成功地安装了这个宝石。

如果你想手动安装这个宝石,可以使用以下命令:

gem install therubyracer --version "~> 0.10.2"


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接