Forum: Ruby on Rails strange frozen string problem starting rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Da860b8b88763c2aa2bb23e3413dca5a?d=identicon&s=25 mike castleman (Guest)
on 2007-04-24 22:16
hi,

I am experiencing a very strange problem with my Rails installation. I'm
using ruby 1.8.6 on Debian Linux, with edge rails.

Whenever I try to start mongrel, I get an exception about "can't modify
frozen string". I get a similar exception when I try to do "rake
db:migrate". In this case, the exception seems to pop up *after* the
migrations do succesfully run.

The problem seems similar to the one described at
<http://rubyforge.org/forum/message.php?msg_id=20575>, except the user
there is running Windows and I am running Linux.

Most mysteriously, other members of my development team do not
experience this problem.

Here is a stack trace of the exception:

mlc@coconut:~/src/demomcracynow.org$ rake --trace db:migrate
(in /home/mlc/src/democracynow.org)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
rake aborted!
can't modify frozen string
/usr/lib/ruby/1.8/date/format.rb:105:in `chomp!'
/usr/lib/ruby/1.8/date/format.rb:105:in `method_missing'
/usr/lib/ruby/1.8/date/format.rb:963:in `_parse'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb:114:in
`string_to_time'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb:60:in
`type_cast'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb:22:in
`initialize'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:93:in
`initialize'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:354:in
`new'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:354:in
`columns'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:354:in
`each'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:354:in
`columns'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/schema_dumper.rb:68:in
`table'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/schema_dumper.rb:63:in
`tables'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/schema_dumper.rb:54:in
`each'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/schema_dumper.rb:54:in
`tables'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/schema_dumper.rb:23:in
`dump'
/home/mlc/src/democracynow.org/vendor/rails/activerecord/lib/active_record/schema_dumper.rb:17:in
`dump'
/home/mlc/src/democracynow.org/vendor/rails/railties/lib/tasks/databases.rake:24/home/mlc/src/democracynow.org/vendor/rails/railties/lib/tasks/databases.rake:23:in
`open'
/home/mlc/src/democracynow.org/vendor/rails/railties/lib/tasks/databases.rake:23/usr/lib/ruby/1.8/rake.rb:387:in
`call'
/usr/lib/ruby/1.8/rake.rb:387:in `execute'
/usr/lib/ruby/1.8/rake.rb:387:in `each'
/usr/lib/ruby/1.8/rake.rb:387:in `execute'
/usr/lib/ruby/1.8/rake.rb:357:in `invoke'
/usr/lib/ruby/1.8/rake.rb:350:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:350:in `invoke'
/home/mlc/src/democracynow.org/vendor/rails/railties/lib/tasks/databases.rake:5
/usr/lib/ruby/1.8/rake.rb:387:in `call'
/usr/lib/ruby/1.8/rake.rb:387:in `execute'
/usr/lib/ruby/1.8/rake.rb:387:in `each'
/usr/lib/ruby/1.8/rake.rb:387:in `execute'
/usr/lib/ruby/1.8/rake.rb:357:in `invoke'
/usr/lib/ruby/1.8/rake.rb:350:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:350:in `invoke'
/usr/lib/ruby/1.8/rake.rb:1906:in `run'
/usr/lib/ruby/1.8/rake.rb:1906:in `each'
/usr/lib/ruby/1.8/rake.rb:1906:in `run'
/usr/bin/rake:4

Any help would be very greatly appreciated. Let me know if I can provide
any more information.
Da860b8b88763c2aa2bb23e3413dca5a?d=identicon&s=25 mike castleman (Guest)
on 2007-04-25 00:42
mike castleman wrote:
> can't modify frozen string
> /usr/lib/ruby/1.8/date/format.rb:105:in `chomp!'
> /usr/lib/ruby/1.8/date/format.rb:105:in `method_missing'
> /usr/lib/ruby/1.8/date/format.rb:963:in `_parse'


ok, so I managed to work around the problem by patching
/usr/lib/ruby/1.8/date/format.rb as shown below. anyone who can tell me
why this was necessary will be my new hero.



--- format.rb.orig      2007-04-24 18:41:28.820600021 -0400
+++ format.rb   2007-04-24 18:40:50.362196521 -0400
@@ -101,7 +101,7 @@
       end

       def method_missing(t, *args, &block)
-       t = t.to_s
+       t = String.new(t.to_s)
        set = t.chomp!('=')
        t = t.intern
        if set
This topic is locked and can not be replied to.