ruby - 应用程序路径中的 rake 和 utf-8 字符

标签 ruby utf-8 rake

我使用了一个使用 rake 编译的应用程序。问题是如果我将我的应用程序目录设置在包含非 US-ASCII 字符的路径中,编译将失败。

例如:

cd /home/user/Downloads/my_app
rake 

==> 它有效

cd /home/user/Téléchargements/my_app
rake

==> 它不起作用

我的系统是全utf-8

我怎样才能避免这种情况?

有关信息,我尝试编译的应用程序很微妙:

hg clone http://hg.subforge.org/subtle
cd subtle
rake

这里是完整的错误信息:

** Invoke default (first_time)
** Invoke config (first_time)
** Execute config
checking for stdio.h... yes
checking for stdlib.h... yes
checking for stdarg.h... yes
checking for string.h... yes
checking for unistd.h... yes
checking for signal.h... yes
checking for errno.h... yes
checking for assert.h... yes
checking for sys/time.h... yes
checking for sys/types.h... yes
checking for sys/inotify.h... yes
checking for wordexp.h... yes
rake aborted!
invalid byte sequence in US-ASCII
/usr/lib/ruby/1.9.1/mkmf.rb:785:in `[]'
/usr/lib/ruby/1.9.1/mkmf.rb:785:in `checking_for'
/home/silkmoth/Téléchargements/subtle/Rakefile:335:in `block in <top (required)>'
/usr/lib/ruby/1.9.1/rake/task.rb:205:in `call'
/usr/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
/usr/lib/ruby/1.9.1/rake/task.rb:200:in `each'
/usr/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
/usr/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
/usr/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites'
/usr/lib/ruby/1.9.1/rake/task.rb:174:in `each'
/usr/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites'
/usr/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
/usr/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
/usr/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
/usr/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_level'
/usr/lib/ruby/1.9.1/rake/application.rb:94:in `each'
/usr/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
/usr/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
/usr/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
/usr/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/1.9.1/rake/application.rb:63:in `run'
/usr/bin/rake:32:in `<main>'
Tasks: TOP => default => config

最佳答案

问题不在于文件的编码,而在于路径中的非 ascii 符号('Téléchargements')。

显然,第 785 行 mkmf 中的#checking_for 与 rake 相结合发生了异常。作为 Rakefile 的作者,除了向上游报告和/或找到一种完全避免该方法的方法之外,我对此无能为力。

快速修复是使用没有非 ascii 符号的路径,抱歉。

关于ruby - 应用程序路径中的 rake 和 utf-8 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9147861/

相关文章:

ruby-on-rails - RubyXL:如何将多个数据单元格添加到工作表中?

python - 混合使用 UTF-8 和 ASCII 编码?

ruby - 为什么会抽取 Assets :precompile take forever?

ruby-on-rails - 无法加载此类文件 — ruby​​gems.rb

ruby-on-rails - Rails 3 - has_and_belongs_to_many

csv - 如何通过 Pandas 数据框读取包含 utf-8 值的 .csv 文件

windows - 编写 rakefile 以在 Windows 中运行命令的最佳方法是什么?

ruby-on-rails-4 - Rails 控制台不工作(搜索错误的 gem )

mysql - 使用另一个表中的 ID 创建新表条目

php - 将数据库编码修复为 UTF8