9
votes

I am using ruby version 1.9.3 and getting error when I start 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'

I got solution from here pdf-writer invalid multibyte char (US-ASCII) expecting keyword_end content = "%PDF-#{@version}\n%âãÏÓ\n" Rails 3

I have changed my gemfile pdf-writer to

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

Now when I run bundler to install the pdf-writer gem I get timeout error as below

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
it seems the filename was in UTF-8 but interpreted as ASCII, but ruby unsupported ASII in such way, so how sis you generated the content line?Малъ Скрылевъ
I am just starting thin server and getting this logged in thin logveer7
change to gem 'pdf-writer', github: 'metaskills/pdf-writer'Малъ Скрылевъ
@МалъСкрылевъ : When I change it to as suggested above I still get timeout error github.com[0: 192.30.252.121]: errno=Connection timed out fatal: unable to connect a socket (Connection timed out) veer7
that is internet error.... try to clone git repo manyallyМалъ Скрылевъ

1 Answers

0
votes

So this might be a couple different issues. For the 1st error, you could add explicit encoding to the top of /usr/local/lib/ruby/gems/1.9.1/gems/pdf-writer-1.1.8/lib/pdf/writer.rb-

# encoding: utf-8

This would be hacking into an older library and brittle at best, as your Gemfile would not be portable to other machines.

For the 2nd error, it looks like there might be a conflict between the existing gem in cache and the remote one that you are attempting to install, since they have the same name.

You could try uninstalling it locally to clear the cache-

gem uninstall pdf-writer

And then bundle it again-

bundle install

Ruby 1.9.3 reached end of life in February 2015, so this is not an ideal situation, but given the constraints, this should get you going.