2015-01-04 19 views
9

Tôi đã cố gắng cài đặt các viên ngọc 'sinatra-websocket', nhưng khi tôi chạy gem install sinatra-websocket, tôi đã nhận lỗi này ...Gem lỗi cài đặt: Bạn phải cài đặt các công cụ phát triển đầu tiên

ERROR: Failed to build gem native extension

... cùng với ...

C:/Ruby193/bin/ruby.exe extconf.rb 
checking for main() in -lc... *** 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-thin_parser-dir 
    --without-thin_parser-dir 
    --with-thin_parser-include 
    --without-thin_parser-include=${thin_parser-dir}/include 
    --with-thin_parser-lib 
    --without-thin_parser-lib=${thin_parser-dir}/lib 
    --with-clib 
    --without-clib 
C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:476:in `try_link' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:619:in `try_func' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:840:in `have_library' 
    from extconf.rb:4:in `<main>' 

đây là những gì các tập tin mkmf trong C:\Ruby193\lib\ruby\gems\1.9.1\gems\thin-1.6.3\ext\thin_parser trông giống như:

"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. -march=i486 -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 */ 

Tôi đang sử dụng Windows 7.

Tại sao tôi gặp lỗi? Có một dòng tuyên bố "không thể tạo Makefile ...", nhưng có liên quan không?

+0

Tệp mkmf.log có thể được tìm thấy trong thư mục cài đặt của gem. – Emanuel

+0

@ siaw23 Tôi đã thêm nội dung của tệp –

+0

Bạn đã cài đặt trình biên dịch C chưa? – iain

Trả lời

20

Bạn đã chạy:

xcode-select --install 

Để cài đặt các công cụ Xcode Developer?

+14

Tôi không nghĩ rằng "công cụ phát triển" đang được tham chiếu trong lỗi có liên quan đến xcode, đặc biệt khi xem xét việc này là trên Windows. –

+3

Công việc này cho tôi trên mac (mavericks). cảm ơn – Liko

+0

Tôi đã chuyển sang một máy tính mới và quên các công cụ dòng lệnh xcode như là một cài đặt riêng biệt cho XCode. Điều này đã giúp cảm ơn. Tôi đã đấu tranh với 'gem install puma' –

10

Có vẻ như bạn đang bỏ lỡ các công cụ tìm kiếm cho ruby.

Bạn có thể tải chúng tại đây: http://rubyinstaller.org/downloads/ chỉ cần cuộn xuống "Bộ công cụ phát triển".

Tải xuống và trích xuất ở mọi nơi bạn muốn. Mở thư mục trong dấu nhắc lệnh và chạy ruby dk.rb init. Điều này sẽ tạo ra một tập tin cấu hình chi tiết cài đặt ruby ​​của bạn. Kiểm tra tệp cấu hình này trước khi tiếp tục để xác nhận đường dẫn đến cài đặt ruby ​​của bạn là chính xác.

Bây giờ chạy ruby dk.rb install. Điều này sẽ cài đặt bộ phát triển.

Khởi động lại dấu nhắc lệnh và thử cài đặt lại đá quý.

Các vấn đề liên quan