Windows 上的 Gem 更新 - 坏了吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/134581/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:18:29  来源:igfitidea点击:

Gem update on Windows - is it broken?

windowsrubyrubygems

提问by Charles Roper

This is a follow-up to this question.

这是这个问题的后续。

When I issue the gem updatecommand on Windows, whenever it gets to a gem whose latest version DOESN'T have Windows binaries, it'll attempt to build the native extension which will, of course, fail. For example:

当我gem update在 Windows 上发出命令时,只要它到达一个最新版本没有 Windows 二进制文件的 gem,它就会尝试构建本机扩展,这当然会失败。例如:

Updating sqlite3-ruby
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
  ERROR: Failed to build gem native extension.

c:/ruby/bin/ruby.exe extconf.rb update
checking for fdatasync() in rt.lib... no
checking for sqlite3.h... no

nmake
'nmake' is not recognized as an internal or external command,
operable program or batch file.

The old pre-1.x behavior of asking for the required platform at least made updating possible. Now I can't update at all unless I uninstall the troublesome gems (currently sqlite3-ruby and hpricot), run the update, then re-install the gems using the --version switch.

要求所需平台的旧 1.x 之前的行为至少使更新成为可能。现在我根本无法更新,除非我卸载麻烦的 gems(当前是 sqlite3-ruby 和 hpricot),运行更新,然后使用 --version 开关重新安装 gems。

Does anyone have a solution to this conundrum or are we stuck with it?

有没有人有解决这个难题的方法,或者我们是否被它困住了?



Note:

笔记:

$ gem -v
1.2.0

$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]


Note (26 September 2008):I just updated to gems 1.3.0 and this problem persists.

注意(2008 年 9 月 26 日):我刚刚更新到 gems 1.3.0 并且这个问题仍然存在。

Note (18 November 2008):Just updated to gems 1.3.1 and the problem persists.

注意(2008 年 11 月 18 日):刚刚更新到 gems 1.3.1 并且问题仍然存在。

Note (28 April 2009):The latest version of Gems (1.3.2) now skips any gems where building of native extensions fails during update; in other words, the problem is fixed. Hooray!

注意(2009 年 4 月 28 日):最新版本的 Gems ( 1.3.2) 现在会跳过任何在更新期间构建本机扩展失败的 gem;换言之,问题已解决。万岁!

采纳答案by Charles Roper

Gems, as of version 1.3.2, will now skip gems that fail to build, so update Rubygems to the latest version and the problem discussed here should be solved.

Gems,从1.3.2 版本开始,现在将跳过无法构建的 gem,因此将 Rubygems 更新到最新版本,这里讨论的问题应该得到解决。

gem update --system

The following solution is now deprecated, but I leave it here for the record.

以下解决方案现已弃用,但我将其留在这里以作记录。

I started a thread on this issueon the Ruby Forum (it's a front end to the mailing list). There's some interesting discussion; it's worth a read. There's even a very hacky solution to this problem on there:

我在 Ruby 论坛(它是邮件列表的前端)上就这个问题发起了一个讨论。有一些有趣的讨论;值得一读。甚至有一个非常hacky的解决方案来解决这个问题:

`gem.bat outdated`.split(/\n/).map{|z|z.scan(/^[^[:space:]]+/)}.flatten.each{|z| `gem.bat update #{z}`}

It calls the gem outdatedcommand and builds a list of all of the outdated gems. It then iterates over the list and calls gem updatefor each individual outdated gem. If one fails, it just moves onto the next.

它调用gem outdated命令并构建所有过时 gem 的列表。然后它遍历列表并调用gem update每个单独的过时 gem。如果一个失败,它只会移动到下一个。

回答by hectorsq

It seems that we are stuck. I have found herethat there is no mswin32 gem for the last version (1.2.4), I tried to install it on my computer and got the same problem.

似乎我们被困住了。我在这里发现最后一个版本 (1.2.4) 没有 mswin32 gem,我尝试在我的计算机上安装它并遇到同样的问题。

Installing the previous version works fine:

安装以前的版本工作正常:

gem install sqlite3-ruby --version '1.2.3'

回答by AMIC MING

Execute the below command and it should work:

执行以下命令,它应该可以工作:

gem install sqlite3-ruby --platform=mswin32

回答by Alan Hecht

Looking at the RubyForge file listfor sqlite3-ruby reveals that version 1.2.3 has gems that were built using Visual Studio 6 and MinGW (sqlite3-ruby-1.2.3-mswin32.gem & sqlite3-ruby-1.2.3-x86-mingw32.gem). However, version 1.2.4 doesn't not have any such pre-built gems.

查看 sqlite3-ruby的RubyForge 文件列表显示 1.2.3 版具有使用 Visual Studio 6 和 MinGW 构建的 gem(sqlite3-ruby-1.2.3-mswin32.gem & sqlite3-ruby-1.2.3-x86- mingw32.gem)。但是,版本 1.2.4 没有任何此类预构建的 gem。

If you have Visual Studio 6 or MinGWinstalled and have the compiler environment variables set up (at least for Visual Studio 6 but not sure about MinGW), the gem should build during installation. I'm not sure if the gems will build under newer versions of Visual Studio.

如果您安装了 Visual Studio 6 或MinGW并设置了编译器环境变量(至少对于 Visual Studio 6 但不确定 MinGW),gem 应该在安装期间构建。我不确定 gems 是否会在较新版本的 Visual Studio 下构建。