ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "h.shirosaki (Hiroshi Shirosaki)" <h.shirosaki@gmail•com>
To: ruby-dev@ruby-lang.org (ruby developers list)
Subject: [ruby-dev:47133] [ruby-trunk - Bug #7881] Windows でパスに日本語を含むスクリプトからの require が失敗する
Date: Tue, 5 Mar 2013 14:54:55 +0900	[thread overview]
Message-ID: <redmine.journal-37295.20130305145454@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-7881.20130219113737@ruby-lang.org


Issue #7881 has been updated by h.shirosaki (Hiroshi Shirosaki).


=begin

たとえば、下記のようなコードを書いたときに、current directoryのパスが日本語を含んでいても
Encoding::CompatibilityError にならずに動く、という利点はあるのではないでしょうか。

expand_pathの結果がfilesystem encodingに変わる可能性があれば、日本語の引数に.encode('filesystem')をつけるなどしておかないといけません。

 # coding: euc-jp
 
 expand = File.expand_path('あ')
 p [expand, expand.encoding]
 path = File.join(expand, "あああ")
 p [path, path.encoding]


あと、報告のあったrequire "./b" に関しては require_relative "b" でも動作するようです。

=end
----------------------------------------
Bug #7881: Windows でパスに日本語を含むスクリプトからの require が失敗する
https://bugs.ruby-lang.org/issues/7881#change-37295

Author: 5.5 (5 5)
Status: Assigned
Priority: Normal
Assignee: h.shirosaki (Hiroshi Shirosaki)
Category: core
Target version: next minor
ruby -v: ruby 1.9.3p385 (2013-02-06) [i386-mingw32]


=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



-- 
http://bugs.ruby-lang.org/

  parent reply	other threads:[~2013-03-05  6:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-7881.20130219113737@ruby-lang.org>
2013-02-21 23:53 ` [ruby-dev:47064] [ruby-trunk - Bug #7881] Windows でパスに日本語を含むスクリプトからの require が失敗する ko1 (Koichi Sasada)
2013-02-25  6:16 ` [ruby-dev:47107] [ruby-trunk - Bug #7881][Assigned] " usa (Usaku NAKAMURA)
2013-02-27 10:03 ` [ruby-dev:47121] [ruby-trunk - Bug #7881] " h.shirosaki (Hiroshi Shirosaki)
2013-02-27 10:39 ` [ruby-dev:47122] " usa (Usaku NAKAMURA)
2013-02-27 11:38 ` [ruby-dev:47123] " h.shirosaki (Hiroshi Shirosaki)
2013-02-28  8:55   ` [ruby-dev:47125] " U.Nakamura
2013-03-03 13:50 ` [ruby-dev:47130] " nagachika (Tomoyuki Chikanaga)
2013-03-05  5:54 ` h.shirosaki (Hiroshi Shirosaki) [this message]
2019-08-08 20:54 ` [ruby-dev:50830] [Ruby master Bug#7881] " merch-redmine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-37295.20130305145454@ruby-lang.org \
    --to=ruby-dev@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).