如何删除无效的字节序列?

时间:2013-06-25 22:16:05

标签: ruby-on-rails ruby encoding rake ascii

这是我的问题:每次我尝试在命令行中使用rake(rake routes,rake db:populate ...)我都会发现这个错误(我添加了--trace):

rake aborted!
rake aborted!
invalid byte sequence in US-ASCII

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/trace_
output.rb:16:in `block in trace_on'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/trace_
output.rb:14:in `map'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/trace_
output.rb:14:in `trace_on'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/applic
ation.rb:340:in `trace'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/applic
ation.rb:187:in `display_error_message'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/applic
ation.rb:174:in `rescue in standard_exception_handling'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/applic
ation.rb:165:in `standard_exception_handling'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/applic
ation.rb:93:in `load_rakefile'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/applic
ation.rb:77:in `block in run'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/applic
ation.rb:165:in `standard_exception_handling'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/applic
ation.rb:75:in `run'

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in
`<top (required)>'

C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'

C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `main'

我把我的C:/RailsInstaller/Ruby.1.9.3/bin/rake:     !#C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe     #     #这个文件是由RubyGems生成的。     #     #应用程序'rake'作为gem的一部分安装,并且     #这个文件是为了方便运行它。     #

require 'rubygems'

version = ">= 0"

if ARGV.first
  str = ARGV.first
  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  if str =~ /\A_(.*)_\z/
    version = $1
    ARGV.shift
  end
end

gem 'rake', version
load Gem.bin_path('rake', 'rake', version)

我不知道这个bug是怎么出现的。我尝试了很多解决方案,同样的问题是“无效字节序列”,但没有任何效果。如果你能帮助我,我将非常感激!提前谢谢

0 个答案:

没有答案