ruby 无法安装 gem - make 未被识别为内部或外部命令可操作的程序或批处理文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27239491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot install gem - make is not recognized as an internal or external command operable program or batch file
提问by stack1
I wanted to install the rspec-rails gem with ruby 1.9.3 on windows 7. I got some errors saying that some json libraries could not be installed. So, I used the instructions below to solve it. Source = The 'json' native gem requires installed build tools
我想在 Windows 7 上安装带有 ruby 1.9.3 的 rspec-rails gem。我收到一些错误,说无法安装某些 json 库。所以,我使用下面的说明来解决它。Source = 'json' 本机 gem 需要安装构建工具
- Download [Ruby 1.9.3][2] from [rubyinstaller.org][3]
- Download DevKit file from [rubyinstaller.org][3]
- For Ruby 1.9.3 use [DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe][4]
- Extract DevKit to path C:\Ruby193\DevKit
- Run
cd C:\Ruby193\DevKit - Run
ruby dk.rb init - Run
ruby dk.rb review - Run
ruby dk.rb install
- 从 [rubyinstaller.org][3] 下载 [Ruby 1.9.3][2]
- 从 [rubyinstaller.org][3] 下载 DevKit 文件
- 对于 Ruby 1.9.3 使用 [DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe][4]
- 将 DevKit 解压到路径 C:\Ruby193\DevKit
- 跑
cd C:\Ruby193\DevKit - 跑
ruby dk.rb init - 跑
ruby dk.rb review - 跑
ruby dk.rb install
To return to the problem at hand, you should be able to install JSON (or otherwise test that your DevKit successfully installed) by running the following commands which will perform an install of the JSON gem and then use it:
回到手头的问题,您应该能够通过运行以下命令来安装 JSON(或以其他方式测试您的 DevKit 是否成功安装),该命令将执行 JSON gem 的安装,然后使用它:
gem install json --platform=ruby
ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect"
When I execute the above first step, I get the error -
当我执行上述第一步时,出现错误 -
C:\Ruby193\DevKit>gem install json --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
'make' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
Gem 文件将保留安装在 C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 中以供检查。结果记录到 C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
I am trying to solve the above error now -
我现在正在尝试解决上述错误 -
'make' is not recognized as an internal or external command, operable program or batch file.using make is not recognized as an internal or external command - Qt SDK - Windows
'make' is not recognized as an internal or external command, operable program or batch file.使用make 不被识别为内部或外部命令 - Qt SDK - Windows
If someone already knows how to fix this, then please help me. I have been struggling to install gems and I am failing for so many days. I am wondering if ruby is so difficult.
如果有人已经知道如何解决这个问题,请帮助我。我一直在努力安装 gems 并且我失败了这么多天。我想知道ruby是不是这么难。
The DOSKEY approach failed !!!
DOSKEY 方法失败了!!!
I did this - Install Mingw and installed all its developer tools and base stuff. Then added C:\MinGW\bin to environment variables to find mingw32-make.exe. Then, I ran the DOSKEY make=mingw32-makefollowed by the ruby command. I got the same error. I am guessing that the ruby code is spawning off a hidden cmd window and thats why the command is not working. DOSKEY is valid only in the cmd window in which you run it.
我这样做了 - 安装 Mingw 并安装了它的所有开发工具和基础东西。然后在环境变量中添加C:\MinGW\bin,找到mingw32-make.exe。然后,我运行DOSKEY make=mingw32-make了 ruby 命令。我得到了同样的错误。我猜测 ruby 代码是从隐藏的 cmd 窗口中生成的,这就是该命令不起作用的原因。DOSKEY 仅在您运行它的 cmd 窗口中有效。
Next step - Not so nice, but, I'll change mingw32-make.exeto make.exe and see.
下一步 - 不太好,但是,我将更mingw32-make.exe改为 make.exe 并查看。
Failed again with a new error -
再次失败,出现新错误 -
Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb creating Makefilemake generating generator-i386-mingw32.def compiling generator.c In file included from generator.c:1:0: ../fbuffer/fbuffer.h:5:18: fatal error: ruby.h: No such file or directory #include "ruby.h" ^ compilation terminated. Makefile:204: recipe for target 'generator.o' failed make: *** [generator.o] Error 1
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
暂时增强 PATH 以包含 DevKit... 构建本机扩展。这可能需要一段时间... 错误:安装 json 时出错:错误:无法构建 gem 本机扩展。
C:/Ruby193/bin/ruby.exe extconf.rb creating Makefile生成generator-i386-mingw32.def编译generator.c在generator.c包含的文件中:1:0:../fbuffer/fbuffer.h:5:18:致命错误:ruby.h:没有那个文件或目录#include "ruby.h" ^ 编译终止。Makefile:204: 目标 'generator.o' 的配方失败 make: *** [generator.o] 错误 1
Gem 文件将保留安装在 C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 中以供检查。结果记录到 C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
What do I do now ?
现在我该怎么做 ?
采纳答案by Saifis
I have tried to setup ruby on rails on a windows system, although there are one click installers that install ruby itself and rails, many of the gems rely on a posix based operating system to be compiled, thus making it near impossible to do actual work on windows.
我曾尝试在 windows 系统上安装 ruby on rails,虽然有安装 ruby 本身和 rails 的一键安装程序,但许多 gems 依赖于基于 posix 的操作系统来编译,因此几乎不可能进行实际工作在窗户上。
My advise would be to get yourself a linux system, perhaps unbuntu on your system and dual boot, or get a virtual pc software, like this one, or any of the other options, and try installing ruby from there.
我的建议是让自己的Linux系统,也许你的系统和双启动关于unbuntu,或者得到一个虚拟PC软件,像这样的一个,或任何其他选项,并尝试从那里安装Ruby。
回答by Kalyan
Most of the Ruby gems are developed for Unix and require some extra tools to make it work on Windows.
大多数 Ruby gem 是为 Unix 开发的,需要一些额外的工具才能在 Windows 上运行。
In order to install those gem in Windows, you need Ruby DEVELOPMENT KITfrom the downloadlink (choose the correct installer based on your Ruby version).
为了在 Windows 中安装这些 gem,您需要来自下载链接的Ruby DEVELOPMENT KIT(根据您的 Ruby 版本选择正确的安装程序)。
Extract the installation to some permanent location. In my system, it is C:\RubyDevKit.
将安装解压到某个永久位置。在我的系统中,它是 C:\RubyDevKit。
Open command prompt and cd to the extracted location and execute the following commands
打开命令提示符并 cd 到提取的位置并执行以下命令
cd C:\RubyDevKit
ruby dk.rb init
ruby dk.rb install
devkitvars.bat
The lastcommand is what I missed initially and took sometime to figure out. Now try installing your gem; it worked for me.
在最后的命令是我错过了最初并把某个弄清楚。现在尝试安装您的 gem;它对我有用。
Additional Information
附加信息
The Ruby Development Kit has a component called MinGW which is used to run Unix command on Windows.
Ruby 开发工具包有一个名为 MinGW 的组件,用于在 Windows 上运行 Unix 命令。
The below error, in my case, was Ruby Development Kit not added to the system path variable
就我而言,以下错误是 Ruby Development Kit 未添加到系统路径变量中
make 'make' is not recognized as an internal or external command, operable program or batch file.
make 'make' 不是内部或外部命令,也不是可运行的程序或批处理文件。
The command devkitvars.batadds the Development Kit to the system path.
该命令devkitvars.bat将开发工具包添加到系统路径。
回答by Fahad
Ruby installation wizard asks you "Add Ruby executables to your PATH", for me, easy solution is to uninstall ruby and install again, this time checking the check box "Add Ruby executables to your PATH"
Ruby 安装向导会询问您“将 Ruby 可执行文件添加到您的 PATH”,对我来说,简单的解决方案是卸载 ruby 并再次安装,这次选中复选框“将 Ruby 可执行文件添加到您的 PATH”
回答by Rujoota Shah
Try installing gnuwin-32 make and then change environment variable PATH to point to C:\Program Files (x86)\GnuWin32\bin
尝试安装 gnuwin-32 make 然后将环境变量 PATH 更改为指向 C:\Program Files (x86)\GnuWin32\bin
回答by friek108
With the latest version of Ruby 2.4.2, the dev kit is included in the installation so you don't need to follow the separate install instructions. Just uninstall existing ruby and reinstall the new one here https://rubyinstaller.org/downloads/.
对于最新版本的 Ruby 2.4.2,开发工具包包含在安装中,因此您无需遵循单独的安装说明。只需卸载现有的 ruby 并在此处重新安装新的https://rubyinstaller.org/downloads/。
Once finished, it'll open up a command prompt on which you need to select option 3 to include the dev kit. However, at the time of writing it's so buggy and you may or may not have issues installing.
完成后,它将打开一个命令提示符,您需要在其中选择选项 3 以包含开发工具包。但是,在撰写本文时,它有很多问题,您可能会或可能不会遇到安装问题。


