Project

General

Profile

Actions

Bug #7881

closed

Windows でパスに日本語を含むスクリプトからの require が失敗する

Added by 5.5 (5 5) about 11 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3p385 (2013-02-06) [i386-mingw32]
[ruby-dev:47042]

Description

=begin
Windows でパスに日本語を含むスクリプトからの require が失敗します。

Ruby 1.9.3 の p374,p385 でこの現象が起こりますが,p125 では起こりません。
p286 あたりから起こるようになったと思います。

【再現手順】
(1) d:/テスト というフォルダーを作る。
(2) d:/テスト/a.rb を下記のように書く。
(3) d:/テスト/b.rb を下記のように書く。
(4) cd /テスト
(5) ruby a.rb

a.rb の内容:

encoding: utf-8

require "./b"

b.rb の内容

encoding: utf-8

puts "No problem."

これで,

cannot load such file -- ./b (LoadError)

が出ます。

  • フォルダー名を「テスト」から「test」に変えると正常に動作します。
  • a.rb のスクリプトエンコーディングを CP932 に変えると正常に動作します。
  • require "./b" を require "./b".encode("CP932") に変えると正常に動作します。
  • 標準添付ライブラリーや gem はふつうに require できます。

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0