Bug #5447
closedRails can't create a new app when a folder with accented letter is in the path
Description
On OS X Lion 10.7.2
With ruby 1.9.3-RC1 and ruby 1.9.3-head
rvm install 1.9.3-head
rvm --create 1.9.3-head@rails3.1.1
rvm --default use 1.9.3-head@rails3.1.1
gem install rails
cd Documents/EMC/Émilie/rails/
rails new test_app
fails with error
/Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/actions.rb:117:in gsub': invalid multibyte character: /\/Users\/billgates\/Documents\/EMC\/E\xCC\x81milie\/rails\/test_app/ (RegexpError) from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/actions.rb:117:in
relative_to_original_destination_root'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:87:in destination=' from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:37:in
initialize'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:15:in new' from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:15:in
empty_directory'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/railties-3.1.1/lib/rails/generators/app_base.rb:103:in create_root' from (eval):1:in
create_root'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/task.rb:22:in run' from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in
invoke_task'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in block in invoke_all' from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
each'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in map' from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
invoke_all'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/group.rb:226:in dispatch' from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/thor-0.14.6/lib/thor/base.rb:389:in
start'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/railties-3.1.1/lib/rails/commands/application.rb:31:in <top (required)>' from /Users/billgates/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require'
from /Users/billgates/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/railties-3.1.1/lib/rails/cli.rb:15:in
<top (required)>'
from /Users/billgates/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' from /Users/billgates/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/gems/rails-3.1.1/bin/rails:7:in <top (required)>' from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/bin/rails:19:in
load'
from /Users/billgates/.rvm/gems/ruby-1.9.3-head@rails3.1.1/bin/rails:19:in `'
There is no such problem with:
- ruby 1.9.2 - ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0],
- Apple's system ruby ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
Yours
Updated by naruse (Yui NARUSE) about 13 years ago
- Status changed from Open to Third Party's Issue
It's thor's bug.
Updated by gnal-ybur (Joël Brogniart) about 13 years ago
It's not a thor's bug. It's perhaps an issue related to the way ruby 1.9.3 is configured on Mac OS X. The issue is still there with ruby 1.9.3-p0.
Here is a sample test to see the problem (without using Thor).
In OS X' Finder create a folder with accented letter in name (i.e. Émilie), create a sub folder in this folder (i.e. toto).
in terminal, cd to the "toto" folder and then irb.
With ruby 1.9.2p290
d1 = Dir.getwd
=> "/Users/billgates/Documents/tests/E\314\201milie/toto"
d2 = File.expand_path(File.dirname(d1))
=> "/Users/billgates/Documents/tests/E\314\201milie"
d1.gsub(d2, '.')
=> "./toto"
With ruby 1.9.3-p0
ruby-1.9.3-p0 :001 > d1 = Dir.getwd
=> "/Users/billgates/Documents/tests/Émilie/toto"
ruby-1.9.3-p0 :002 > d2 = File.expand_path(File.dirname(d1))
=> "/Users/billgates/Documents/tests/Émilie"
ruby-1.9.3-p0 :003 > d1.gsub(d2, '.')
RegexpError: invalid multibyte character: //Users/billgates/Documents/tests/E\xCC\x81milie/
from (irb):3:in gsub' from (irb):3 from /Users/billgates/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in
'
Yours
Updated by naruse (Yui NARUSE) about 13 years ago
- Status changed from Third Party's Issue to Closed
Your research show the problem is derived an issue fixed by r33603,
and the change will be backported by #5533.
So it will be fixed on next patch release of 1.9.3.
Thanks,
Updated by gnal-ybur (Joël Brogniart) about 13 years ago
The problem seem to be related to File.expand_path.
With ruby 1.9.3-p0:
ruby-1.9.3-p0 :001 > d1 = Dir.getwd
=> "/Users/brogniar/Documents/tests/Émilie/toto"
ruby-1.9.3-p0 :002 > d2 = File.dirname(d1)
=> "/Users/brogniar/Documents/tests/Émilie"
ruby-1.9.3-p0 :003 > d3 = File.expand_path(d2)
=> "/Users/brogniar/Documents/tests/Émilie"
ruby-1.9.3-p0 :004 > d4 = d1.gsub(d2, '.')
=> "./toto"
ruby-1.9.3-p0 :005 > d4 = d1.gsub(d3, '.')
RegexpError: invalid multibyte character: //Users/brogniar/Documents/tests/E\xCC\x81milie/
from (irb):5:in gsub' from (irb):5 from /Users/brogniar/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in
'
Yours
Updated by gnal-ybur (Joël Brogniart) about 13 years ago
Oops, we where writing at the same time. Thanks for your response.