2013-02-12 30 views
5

Khi tôi cố gắng chạy 'bó cài đặt', tôi nhận được một lỗi lạ: "chuỗi byte không hợp lệ trong US-ASCII (ArgumentError)"bó cài đặt báo lỗi "không hợp lệ byte chuỗi trong US-ASCII (ArgumentError)"

$ bundle install 
    Updating git://github.com/devton/catarse_paypal_express.git 
    Unfortunately, a fatal error has occurred. Please see the Bundler 
    troubleshooting documentation at http://bit.ly/bundler-issues. Thanks! 
    /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler.rb:294:in `block in load_gemspec_uncached': invalid byte sequence in US-ASCII (ArgumentError) 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler.rb:291:in `chdir' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler.rb:291:in `load_gemspec_uncached' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler.rb:282:in `load_gemspec' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/source.rb:411:in `block in load_spec_files' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/source.rb:410:in `each' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/source.rb:410:in `load_spec_files' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/source.rb:799:in `load_spec_files' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/source.rb:381:in `local_specs' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/source.rb:774:in `specs' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/definition.rb:491:in `block in converge_locked_specs' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/definition.rb:480:in `each' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/definition.rb:480:in `converge_locked_specs' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/definition.rb:166:in `resolve' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/definition.rb:113:in `specs' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/definition.rb:108:in `resolve_remotely!' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/installer.rb:81:in `run' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/installer.rb:14:in `install' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/cli.rb:230:in `install' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/vendor/thor/task.rb:27:in `run' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/vendor/thor.rb:275:in `dispatch' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/vendor/thor/base.rb:408:in `start' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/bin/bundle:14:in `block in <top (required)>' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/friendly_errors.rb:4:in `with_friendly_errors' 
     from /Users/.../.rvm/gems/[email protected]/gems/bundler-1.2.3/bin/bundle:14:in `<top (required)>' 
     from /Users/.../.rvm/gems/[email protected]/bin/bundle:19:in `load' 
     from /Users/.../.rvm/gems/[email protected]/bin/bundle:19:in `<main>' 
     from /Users/.../.rvm/gems/[email protected]/bin/ruby_noexec_wrapper:14:in `eval' 
     from /Users/.../.rvm/gems/[email protected]/bin/ruby_noexec_wrapper:14:in `<main>' 

tôi đã tìm cách giải quyết này (mà làm việc cho tôi):

if RUBY_VERSION =~ /1.9/ 
    Encoding.default_external = Encoding::UTF_8 
    Encoding.default_internal = Encoding::UTF_8 
end 

Nhưng tôi nghĩ rằng sau này nó gây ra một lỗi khác nhau vì vậy tôi không muốn sử dụng nó và chỉ cần cố gắng hiểu những gì thực sự sai ở đây. Tôi biết chắc chắn mã này cùng hoạt động trên một hệ thống khác nhau ...

Trả lời

15

Là một workaround bạn có thể đặt utf8 miền địa phương trong hệ thống của bạn:

export LANG="C.UTF-8" 
export LC_ALL="C.UTF-8" 

Thông tin thêm về việc này là here

+0

Đó là điều - Tôi không muốn giải quyết vấn đề, tôi muốn hiểu lý do của vấn đề và giải quyết nó. – Rizon

+1

Nếu không xem tập tin chính xác (tốt, gemspec trong trường hợp này) Tôi không thể nói chắc chắn nhưng nguyên nhân có khả năng nhất là tệp được mã hóa bằng utf8 nhưng Ruby đang cố gắng đọc tệp và giả sử nó được mã hóa bằng ASCII. Bạn không thể giải quyết vấn đề này như vậy và phương pháp tốt nhất để giải quyết vấn đề này là sử dụng giải pháp thay thế cho ruby ​​giả định mặc định là utf8. – Tomdarkness

+0

@Rizon Tôi đã cập nhật câu trả lời bằng liên kết đến vấn đề của trình phát –

Các vấn đề liên quan