pdf-writer-1.1.8 / lib / pdf / writer.rb:712:无效的多字节字符(US-ASCII)

时间:2016-05-24 14:47:32

标签: ruby-on-rails ruby git rubygems

我正在使用ruby version 1.9.3并在启动thin server

时收到错误消息
    /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.12.4/lib/bundler/runtime.rb:100:in `require': /usr/local/lib/ruby/gems/1.9.1/gems/pdf-writer-1.1.8/lib/pdf/writer.rb:712: invalid multibyte char (US-ASCII) (SyntaxError)
/usr/local/lib/ruby/gems/1.9.1/gems/pdf-writer-1.1.8/lib/pdf/writer.rb:712: invalid multibyte char (US-ASCII)
/usr/local/lib/ruby/gems/1.9.1/gems/pdf-writer-1.1.8/lib/pdf/writer.rb:712: syntax error, unexpected $end, expecting keyword_end
    content = "%PDF-#{@version}\n%âãÃÓ\n"
                                    ^
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.12.4/lib/bundler/runtime.rb:100:in `rescue in block in require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.12.4/lib/bundler/runtime.rb:77:in `block in require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.12.4/lib/bundler/runtime.rb:70:in `each'

我从这里得到了解决方案pdf-writer invalid multibyte char (US-ASCII) expecting keyword_end content = "%PDF-#{@version}\n%âãÏÓ\n" Rails 3

我已将gemfile pdf-writer更改为

gem 'pdf-writer', :git => 'git://github.com/metaskills/pdf-writer.git'

现在,当我运行bundler来安装pdf-writer gem时出现timeout错误,如下所示

github.com[0: 192.30.252.123]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)
Retrying git clone 'git://github.com/metaskills/pdf-writer.git' "/usr/local/lib/ruby/gems/1.9.1/cache/bundler/git/pdf-writer-ce9b6a7a72845526358421df666643f35691567f" --bare --no-hardlinks --quiet due to error (4/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'git://github.com/metaskills/pdf-writer.git' "/usr/local/lib/ruby/gems/1.9.1/cache/bundler/git/pdf-writer-ce9b6a7a72845526358421df666643f35691567f" --bare --no-hardlinks --quiet` in directory /apps/hours_report_3/current has failed.
github.com[0: 192.30.252.123]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)
Git error: command `git clone 'git://github.com/metaskills/pdf-writer.git'
"/usr/local/lib/ruby/gems/1.9.1/cache/bundler/git/pdf-writer-ce9b6a7a72845526358421df666643f35691567f" --bare --no-hardlinks --quiet` in directory
/apps/my_dashboard/current has failed.

1 个答案:

答案 0 :(得分:0)

所以这可能是几个不同的问题。对于第一个错误,您可以/usr/local/lib/ruby/gems/1.9.1/gems/pdf-writer-1.1.8/lib/pdf/writer.rb的顶部添加显式编码 -

# encoding: utf-8

这会侵入一个较旧的库并且最好是脆弱的,因为你的Gemfile不能移植到其他机器上。

对于第二个错误,看起来缓存中的现有gem与您尝试安装的远程gem之间可能存在冲突,因为它们具有相同的名称。

您可以尝试在本地卸载它以清除缓存 -

gem uninstall pdf-writer

然后再捆绑 -

bundle install

Ruby 1.9.3February 2015达到了生命的终点,所以这不是一个理想的情况,但考虑到这些限制,这应该可以帮助你。