After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 673523 - create-reference.rb fails because of encoding issues with ruby 1.9.x
create-reference.rb fails because of encoding issues with ruby 1.9.x
Status: RESOLVED FIXED
Product: GEGL
Classification: Other
Component: build
0.2.0
Other All
: Normal normal
: ---
Assigned To: Default Gegl Component Owner
Default Gegl Component Owner
Depends on:
Blocks:
 
 
Reported: 2012-04-04 17:41 UTC by Tim Mooney
Modified: 2012-04-05 16:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
modify create-reference.rb to handle UTF-8 encoding for ruby 1.9.x (373 bytes, patch)
2012-04-04 17:41 UTC, Tim Mooney
none Details | Review
updated patch that only sets Encoding for ruby 1.9.x and later (453 bytes, patch)
2012-04-05 16:35 UTC, Tim Mooney
none Details | Review

Description Tim Mooney 2012-04-04 17:41:16 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.
Comment 1 Øyvind Kolås (pippin) 2012-04-05 14:43:26 UTC
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)
Comment 2 Tim Mooney 2012-04-05 16:35:11 UTC
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.
Comment 3 Øyvind Kolås (pippin) 2012-04-05 16:50:49 UTC
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