Skip to content

too many arguments for format string, seemingly only when ruby -d #227

@zenspider

Description

@zenspider

On rails boot we've got a bunch of stuff loading and normally everything works fine. HOWEVER, whenever I try to debug something by running rails boot via ruby -d (aka $DEBUG = true), rails bootstrap blows out thusly:

GEMS/moneta-1.5.1/lib/moneta/transformer.rb:359:in `%': too many arguments for format string (ArgumentError)
	from GEMS/moneta-1.5.1/lib/moneta/transformer.rb:359:in `block in compile_transformer'
	from GEMS/moneta-1.5.1/lib/moneta/transformer.rb:348:in `each'
	from GEMS/moneta-1.5.1/lib/moneta/transformer.rb:348:in `compile_transformer'
	from GEMS/moneta-1.5.1/lib/moneta/transformer.rb:65:in `compile'
	from GEMS/moneta-1.5.1/lib/moneta/transformer.rb:38:in `new'
	from GEMS/moneta-1.5.1/lib/moneta/builder.rb:65:in `new_proxy'
	from GEMS/moneta-1.5.1/lib/moneta/builder.rb:25:in `block in build'
	from GEMS/moneta-1.5.1/lib/moneta/builder.rb:23:in `each'
	from GEMS/moneta-1.5.1/lib/moneta/builder.rb:23:in `inject'
	from GEMS/moneta-1.5.1/lib/moneta/builder.rb:23:in `build'
	from GEMS/moneta-1.5.1/lib/moneta.rb:167:in `build'
	from GEMS/moneta-1.5.1/lib/moneta.rb:145:in `new'
... lots

I don't know if debug mode is changing the args going to that string format, or if debug mode is disabling something that's swallowing this exception and it is happening all the time.

I've doped the run to print out the format string:

# normal run:
{:CODE=>"::Marshal.dump(%s)"}
{:CODE=>"(options[:prefix] || @prefix)+%s"}
{:CODE=>"%s.sub(@prefix, '')"}
{:CODE=>"::Marshal.load(%s)"}
{:CODE=>"%s.start_with?(@prefix)"}
{:CODE=>"::Marshal.load(%s)"}
{:CODE=>"(::Marshal.load(key.start_with?(@prefix)) rescue '')"}
{:CODE=>"::Marshal.dump(%s)"}
{:CODE=>"::Marshal.load(%s)"}

vs:

# debug run:
{:CODE=>"::Marshal.dump(%s)"}
{:CODE=>"(options[:prefix] || @prefix)+%s"}
{:CODE=>"%s.sub(@prefix, '')"}
{:CODE=>"::Marshal.load(%s)"}
{:CODE=>"%s.start_with?(@prefix)"}
{:CODE=>"::Marshal.load(%s)"}
{:CODE=>"(::Marshal.load(key.start_with?(@prefix)) rescue '')"}

So I think since the last marshal line doesn't have %s on both sides, I suspect someone is swallowing that exception.

It LOOKS like this is being hit:

      def compile_prefix(name:, transformer:, value:)
        return unless [:encode, :serialize].include?(transformer[0])

        load_val, = compile_transformer([name], value, 1)
        "(#{load_val} rescue '')"
      end

and the result of that doesn't have a %s and gets passed to format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions