Gen*_*_ID 26 ruby windows sinatra
我尝试安装宝石' sinatra-websocket ',但是当我跑步时gem install sinatra-websocket,我收到了这个错误......
ERROR: Failed to build gem native extension
... 随着 ...
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>'
Run Code Online (Sandbox Code Playgroud)
这是mkmf文件的C:\Ruby193\lib\ruby\gems\1.9.1\gems\thin-1.6.3\ext\thin_parser样子:
"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 */
Run Code Online (Sandbox Code Playgroud)
我正在使用Windows 7.
为什么我收到错误?有一条线说"无法创建Makefile ......",但这是相关的吗?
小智 111
这对我有用:
sudo xcode-select -switch /
Ale*_*hin 31
你运行:
xcode-select --install
Run Code Online (Sandbox Code Playgroud)
要安装Xcode Developer工具?
lvn*_*dry 25
尝试了之前的所有答案,但没有一个有效。
这样做了:
brew install cocoapods
Run Code Online (Sandbox Code Playgroud)
Dou*_*ion 23
我在 Ubuntu 18.04 上遇到了同样的问题。Ubuntu 上的修复是安装ubuntu-dev-tools软件包:
$ sudo apt-get install ubuntu-dev-tools
Run Code Online (Sandbox Code Playgroud)
Cer*_*eal 17
听起来你错过了红宝石的devtools.
你可以在这里找到它们:http://rubyinstaller.org/downloads/只需向下滚动到"开发套件".
下载并提取到您想要的任何地方.在命令提示符下打开文件夹并运行ruby dk.rb init.这将创建一个详细说明ruby安装的配置文件.在继续确认ruby安装的路径是否正确之前,请检查此配置文件.
现在跑ruby dk.rb install.这将安装开发套件.
重新启动命令提示符,并尝试再次安装gem.
Gow*_*nan 14
如果您使用的是 Mac 并且最近升级了 Xcode 工具,请运行以下命令:
sudo xcode-select --install
sudo xcodebuild -license
Run Code Online (Sandbox Code Playgroud)
我的问题是我更新到了 macOS Big Sur,不知何故,命令行工具已经过时了。
我知道这一点,因为当我尝试运行时brew install rbenv,我收到了这个错误:
Error: Your Command Line Tools (CLT) does not support macOS 11.
It is either outdated or was modified.
Please update your Command Line Tools (CLT) or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
softwareupdate --all --install --force
If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Alternatively, manually download them from:
https://developer.apple.com/download/more/.
Run Code Online (Sandbox Code Playgroud)
所以我跑了
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Run Code Online (Sandbox Code Playgroud)
完成后,gem安装成功。
这个解决方案救了我:
homebrew通过终端安装。
homebrew安装成功后,在终端输入
' $ brew install cocoapods'
终于完成了!
更新:您可以homebrew通过以下命令安装:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Run Code Online (Sandbox Code Playgroud)
我在MacOS Mojave(10.14.1)上遇到了这个问题。通过Homebrew安装最新的ruby并设置一些env变量为我解决了它:
export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
Run Code Online (Sandbox Code Playgroud)
如果您使用的是Mac OS 10.14(Mojave),请尝试
cd /Library/Developer/CommandLineTools/Packages/;
open macOS_SDK_headers_for_macOS_10.14.pkg
Run Code Online (Sandbox Code Playgroud)
归功于Roy Huang参考:https : //stackoverflow.com/a/55732339/1598551
小智 5
这是我针对 mac OSX 的解决方案:
在终端应用程序中:
步骤1:通过以下脚本确保您已经安装了Xcode开发工具:
xcode-select --install
第 2 步:通过脚本升级你的 ruby:
brew install ruby
第 3 步:再试一次。
| 归档时间: |
|
| 查看次数: |
38882 次 |
| 最近记录: |