Projects

Ticket #783 (closed defect: fixed)

Opened 19 months ago

Last modified 14 months ago

Patch for builder.rb error: invalid byte sequence in US-ASCII

Reported by: slewsys@… Owned by: lsansonetti@…
Priority: major Milestone: MacRuby 0.8
Component: MacRuby Keywords:
Cc:

Description

As of MacRuby subversion Revision: 4343, following build instructions per ./README.rdoc fails with error message "invalid byte sequence in US-ASCII". This is a known issue with Ruby 1.9 which can be resolved by adding an argument to IO.open/read. In the case of MacRuby's builder.rb, changing File.read(src) to File.read(src, { :mode => "rb" }) resolves the issue. Patch follows:

Index: rakelib/builder/builder.rb
===================================================================
--- rakelib/builder/builder.rb  (revision 4343)
+++ rakelib/builder/builder.rb  (working copy)
@@ -142,7 +142,7 @@
   end
   
   def locate_headers(cont, src)
-    txt = File.read(src)
+    txt = File.read(src, { :mode => "rb" })
     txt.scan(/#include\s+\"([^"]+)\"/).flatten.each do |header|
       p = header_path(header)
       if p and !cont.include?(p)

Change History

follow-up: ↓ 2   Changed 19 months ago by martinlagardette@…

What is your configuration exactly? On 64bits 10.6.4 I was able to build & install r4343 without issue.

in reply to: ↑ 1   Changed 19 months ago by slewsys@…

Replying to martinlagardette@…:

What is your configuration exactly? On 64bits 10.6.4 I was able to build & install r4343 without issue.

I am on 10.6.4, but I also have Ruby 1.9 in my path. Although MacRuby derives from Ruby 1.9, I'm assuming that builder.rb was written for /usr/bin/ruby, which is version 1.8, thus the patch.

  Changed 19 months ago by lsansonetti@…

  • milestone MacRuby 0.7 deleted

Unfortunately this patch will break 1.8 rake since IO.open does not accept a hash argument. I am wondering if we couldn't use a magic comment here for 1.9.

  Changed 14 months ago by eloy.de.enige@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to MacRuby 0.8

@Laurent: Nope, that won't work. The magic encoding is only about the bytes in the source file, not about data read from IO. After discussing a few permutations, we decided that setting the proper external encoding is the best thing to do, this will work on all rubies and will make sure that any future File.read statements will work.

I've tested that I can build on 1.8 and 1.9 with r4976.

Note: See TracTickets for help on using tickets.