7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cygwin 環境に RugyGems 2.4.1 を入れて gem install 出来なくなった場合の対応

Posted at

Cygwin 環境に RugyGems 2.4.1 を入れて gem install 出来なくなった場合の対応

概要

Cygwin 環境に RugyGems 2.4.1 を入れて gem install 出来なくなった場合の対応について。

問題発生環境

  • Windows7
  • Cygwin(64bit)
  • rbenv + ruby 2.1
  • RubyGems 2.4.1

経緯

Cygwin 環境で RubyGems のバージョンを 2.4.1 に上げたところ、
下記のエラーが発生して、 gem install ができなくなりました。

$ gem i qiita_scouter
Fetching: qiita_scouter-0.0.1.gem (100%)
ERROR:  While executing gem ... (TypeError)
    no implicit conversion of nil into String

対応

RubyGems の GitHub をあさったところ、該当 Issue を発見。

https://github.com/rubygems/rubygems/pull/1000
https://github.com/rubygems/rubygems/pull/1000/files

プルリクエストの内容を rubygems/installer.rb に適用すれば直ります。

  • 修正前
  def windows_stub_script(bindir, bin_file_name)
    ruby = File.basename(Gem.ruby).chomp('"')
    return <<-TEXT
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"#{bindir.tr(File::SEPARATOR, File::ALT_SEPARATOR)}\\#{ruby}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"%~dp0#{ruby}" "%~dpn0" %*
TEXT
  end
  • 修正後
  def windows_stub_script(bindir, bin_file_name)
    ruby = File.basename(Gem.ruby).chomp('"')
    alt_separator = File::ALT_SEPARATOR || File::SEPARATOR
    return <<-TEXT
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"#{bindir.tr(File::SEPARATOR, alt_separator)}\\#{ruby}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"%~dp0#{ruby}" "%~dpn0" %*
TEXT
  end
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?