Skip to content

Ruby 3.4 frozen string literal deprecation warnings #112

@PhilMeyr

Description

@PhilMeyr

Description

When using inky-rb with Ruby 3.4, deprecation warnings are emitted about frozen string literals.

Warning message

lib/inky/component_factory.rb:137: warning: literal string will be frozen in the future

Environment

  • Ruby version: 3.4.x
  • inky-rb version: 1.4.2.1

Root cause

In Ruby 3.4, string literals will be frozen by default in the future. The code at line 137 of lib/inky/component_factory.rb modifies a string literal in place, which triggers this deprecation warning.

Suggested fix

Replace in-place string modification with a new string allocation, for example:

  • Use string interpolation instead of prepend/<<
  • Use dup before modifying the string
  • Use +'' to create a mutable copy

This is similar to the fix applied in other gems like marcel (rails/marcel#140).

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