Sunday, September 28, 2008

rubyscript2exe.rb and 623 Can't modify frozen string (Type Error)

rubyscript2exe.rb and Frozen String error

A tiny bug

Today I bumped into this error in rubyscript2exe.rb:

rubyscript2exe.rb:623:in `replace': can't modify frozen string (TypeError)

I'm using ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-linux] and rubyscript2exe.rb version 0.5.3 (29.05.2007) which is the latest to this date. However the forementioned error occurs when trying to run rubyscript2exe.rb.

Ungoogled

I quickly googled for an answer but was out of luck, so I just jumped in and found the line, just rephrased the line and here is the change, just edit the rubyscript2exe.rb file at line 623, it looks like this:


$0.replace(File.expand_path("./init.rb"))


  $_0 = File.expand_path("./init.rb")
  alias $__0 $0
  alias $0 $_0

This was fixed from a simple '=' assignment I had proposed to the above solution, based on a comment from cowlibob (thanks), he has the modified version up in github, and you can Get it at http://github.com/cowlibob/rubyscript2exe.

Bye!

Hope this works for you, good luck.

Gabriel Medina.