You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/home/runner/work/reponame/reponame/vendor/bundle/ruby/3.4.0/gems/froala-editor-sdk-4.5.0/lib/froala-editor-sdk/s3.rb:34: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
The OpenSSL line is the line in question:
# Builds a HMAC-SHA256 digest using key and data
# Params:
# +key+:: Key to use for creating the digest
# +data+:: Data to be used for creating the digest
def self.sign(key, data)
OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, key, data.force_encoding(Encoding::UTF_8))
end
I don't feel qualified to submit a PR to fix it, but here's the Claude suggested fix in case it's helpful. I haven't tested it.
Here's why this warning appears:
In Ruby 3.4 (and fully implemented in future versions), all string literals will be automatically frozen by default.
In this line, OpenSSL::HMAC.digest() is being called with a string object that's being modified with force_encoding(Encoding::UTF_8).
The warning appears because the OpenSSL library might be attempting to modify the string that's passed to it, but in future Ruby versions, this string will be frozen (immutable), causing potential errors.
The most likely issue is that OpenSSL::HMAC.digest might be trying to modify the input string in place, but when strings are frozen, they can't be modified.
To fix this issue, you could:
Create a mutable copy of the string before passing it to the method:
This warning is part of Ruby's transition toward making all string literals frozen by default for performance reasons, which has been a gradual process across several Ruby versions.
The text was updated successfully, but these errors were encountered:
kanejamison
changed the title
Frozen String Literal Mutation in S3.rb
Frozen string literal mutation causes deprecation warning in s3.rb on Ruby 3.4
Mar 4, 2025
Hey there,
After upgrading to Ruby 3.4 and the 4.5 version of Froala we get the following frozen string literal warnings from /lib/froala-editor-sdk/s3.rb:
/home/runner/work/reponame/reponame/vendor/bundle/ruby/3.4.0/gems/froala-editor-sdk-4.5.0/lib/froala-editor-sdk/s3.rb:34: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
The OpenSSL line is the line in question:
I don't feel qualified to submit a PR to fix it, but here's the Claude suggested fix in case it's helpful. I haven't tested it.
The text was updated successfully, but these errors were encountered: