Skip to content

Instantly share code, notes, and snippets.

@shyouhei shyouhei/bug.rb
Created Nov 1, 2011

What would you like to do?
Pathname's raising "invalid sequence"
# -*- coding: utf-8 -*-
require 'pathname'
s1 = File.dirname(__FILE__)
s2 = File.expand_path('ディレクトリ/ファイル', s1)
s3 = File.dirname(s2)
s4 = File.expand_path(s3)
p1 = Pathname(s2)
p2 = Pathname(s4)
p3 = p2.relative_path_from(p1)
zsh % ruby -v bug.rb
ruby 1.9.3p0 (2011-10-30 revision 33569) [x86_64-linux]
/lib/ruby/1.9.1/pathname.rb:45:in `=~': invalid byte sequence in UTF-8 (ArgumentError)
from /lib/ruby/1.9.1/pathname.rb:45:in `chop_basename'
from /lib/ruby/1.9.1/pathname.rb:101:in `cleanpath_aggressive'
from /lib/ruby/1.9.1/pathname.rb:89:in `cleanpath'
from /lib/ruby/1.9.1/pathname.rb:450:in `relative_path_from'
from bug.rb:10:in `<main>'
zsh: exit 1 ruby -v bug.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.