GNOME Bugzilla – Bug 673523
create-reference.rb fails because of encoding issues with ruby 1.9.x
Last modified: 2012-04-05 16:50:49 UTC
Created attachment 211316 [details] [review] modify create-reference.rb to handle UTF-8 encoding for ruby 1.9.x I'm building gegl-0.2.0 on x86_64-sun-solaris2.10 with the no-cost Oracle Studio 12.3 compiler toolchain. I have ruby 1.9.3p125 installed. When tools/create-reference.rb is run as part of a make target, it fails with: gmake[2]: Entering directory `/local/src/RPM/BUILD/gegl-0.2.0/docs' ../tools/create-reference.rb \ ../gegl/gegl.h \ ../gegl/gegl-version.h \ ../gegl/buffer/gegl-buffer.h \ ../gegl/gegl-utils.h \ ../gegl/property-types/gegl-color.h\ ../gegl/gegl-matrix.h \ ../gegl/property-types/gegl-path.h\ ../gegl/property-types/gegl-curve.h\ api.html ../tools/create-reference.rb:331:in `block (2 levels) in <main>': invalid byte sequence in US-ASCII (ArgumentError) from ../tools/create-reference.rb:325:in `foreach' from ../tools/create-reference.rb:325:in `block in <main>' from ../tools/create-reference.rb:318:in `times' from ../tools/create-reference.rb:318:in `<main>' ../gegl/gegl.h gmake[2]: *** [api.html] Error 1 This is happening because ruby 1.9.x apparently changed how ruby handles the defaults for encoding for the files it reads. This is discussed in a number of places on the web, such as http://www.ruby-forum.com/topic/178706 http://nuclearsquid.com/writings/ruby-1-9-encodings/ but the upshot is that to work with ruby 1.9.x, some minor tweaks are necessary to some ruby scripts. Since the files that create-reference.rb reads are UTF-8, the easy fix is to just tell create-reference.rb to expect UTF-8. Patch is attached. Note that I have not tested this patch with ruby 1.8.x, but I believe that it is innocuous for 1.8.x. If it turns out that it causes problems, I can submit a new patch that wraps the Encoding calls with a test for ruby version.
It seems like it needs to be wrapped,. with ruby 1.8.7 I get: pippin@blade:~/src/gegl/tools$ ./create-reference.rb ./create-reference.rb:3: uninitialized constant Encoding (NameError)
Created attachment 211403 [details] [review] updated patch that only sets Encoding for ruby 1.9.x and later Sorry about that, updated patch that tests RUBY_VERSION before setting Encoding is now attached.
commit 809642a08787638d9682149de25d36ee273902ff Author: Øyvind Kolås <pippin@gimp.org> Date: Thu Apr 5 18:49:54 2012 +0200 tools/create-reference.rb: fix utf8 handling for ruby >= 1.9.x A patch from Tim Mooney, fixing bug #673523