Skip to content

`gsub!': can't modify frozen String (FrozenError) causing changelog generator exiting with error code 1 #977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kian2attari opened this issue Aug 11, 2021 · 5 comments · Fixed by #981

Comments

@kian2attari
Copy link

Describe the bug

Recent runs of the action have suddenly started failing with the following error:

Screen Shot 2021-08-10 at 8 28 35 PM

Screen Shot 2021-08-10 at 8 28 02 PM

For reference, here is the error text:

/Users/runner/hostedtoolcache/Ruby/2.6.8/x64/lib/ruby/gems/2.6.0/gems/github_changelog_generator-1.16.4/lib/github_changelog_generator/generator/generator.rb:160:in `gsub!': can't modify frozen String (FrozenError)
Associating PRs with tags: 9/188
	from /Users/runner/hostedtoolcache/Ruby/2.6.8/x64/lib/ruby/gems/2.6.0/gems/github_changelog_generator-1.16.4/lib/github_changelog_generator/generator/generator.rb:160:in `remove_old_fixed_string'
Associating PRs with tags: 10/188
	from /Users/runner/hostedtoolcache/Ruby/2.6.8/x64/lib/ruby/gems/2.6.0/gems/github_changelog_generator-1.16.4/lib/github_changelog_generator/generator/generator.rb:63:in `block in compound_changelog'
Associating PRs with tags: 11/188
	from /Users/runner/hostedtoolcache/Ruby/2.6.8/x64/lib/ruby/gems/2.6.0/gems/async-1.30.1/lib/async/task.rb:260:in `block in make_fiber'

This is my partial config file, it was working perfectly

          unreleased-label=New features since previous release **${{ env.LATEST_RELEASE_TAG }}**
          output=CHANGELOG.md
          configure-sections={"enhancements":{"prefix":"###  🚀  Enhancements:","labels":["enhancement"]},"bugs":{"prefix":"###  🐛  Bug fixes:","labels":["bug"]},"security":{"prefix":"###  🔒  Security:","labels":["security"]},"documentation":{"prefix":"###  📜  Documentation:","labels":["documentation"]},"tests":{"prefix":"###  🧪  Tests:","labels":["tests"]}}
          compare-link=true
          unreleased-only=true
          date-format=%m/%d/%Y
          header-label=<!-- Changelog -->
          pr-label=### ➕  Other merged pull requests 
          issues=false
          issues-wo-labels=false

To Reproduce
Steps to reproduce the behavior:
This is currently happening on a private repo but I'll update this once I have a test repo running with the issue

@olleolleolle
Copy link
Collaborator

Yes, this is a bug, but MAYBE you can work around it by disabling the --enable-frozen-string-literal option, perhaps by:

RUBYOPT=--disable-frozen-string-literal

@kian2attari
Copy link
Author

kian2attari commented Aug 11, 2021

Thanks for the suggestion!
Unfortunately, it doesn't seem like setting the RUBYOPT worked on the gem :/ Unless I'm doing something wrong here.

I tried setting it both inline with the gem install and github_changelog_generator, and setting exporting the value globally beforehand but I still get the same error.

          export RUBYOPT="--disable-frozen-string-literal"
          RUBYOPT="--disable-frozen-string-literal" gem install github_changelog_generator
          RUBYOPT="--disable-frozen-string-literal" github_changelog_generator --config-file configfile

I'll keep working and push up a PR if I figure it out

@kian2attari
Copy link
Author

kian2attari commented Aug 11, 2021

The issue only appears if you set unreleased-only to true. I suspect this issue is connected to #971.

@olleolleolle
Copy link
Collaborator

@kian2attari This issue is a defect that GitHub Changelog Generator expects strings to be mutable, when they may be immutable, in its own code. There were issues in dependent gems, too, but this project has a few of these problems.

o-orand added a commit to orange-cloudfoundry/cf-ops-automation that referenced this issue Aug 26, 2021
add github token on each call, as it seems env var is not automatically used anymore.
temporary disable `unrelease-only` on acceptance test due to github-changelog-generator/github-changelog-generator#977
o-orand added a commit to orange-cloudfoundry/cf-ops-automation that referenced this issue Aug 26, 2021
add github token on each call, as it seems env var is not automatically used anymore.
temporary disable `unrelease-only` on acceptance test due to github-changelog-generator/github-changelog-generator#977
adangel added a commit to adangel/github-changelog-generator that referenced this issue Sep 18, 2021
@adangel
Copy link
Contributor

adangel commented Sep 18, 2021

For me, this happened with --unreleased-only and when there where no closed issues/pull requests after the last release.
See #981 for a fix.

My stacktrace was:

Traceback (most recent call last):
        3: from /home/andreas/PMD/source/m2e-code-quality/vendor/bundle/ruby/2.7.0/gems/async-1.30.1/lib/async/task.rb:260:in `block in make_fiber'
        2: from /home/andreas/PMD/source/m2e-code-quality/vendor/bundle/ruby/2.7.0/gems/github_changelog_generator-1.16.4/lib/github_changelog_generator/generator/generator.rb:63:in `block in compound_changelog'
        1: from /home/andreas/PMD/source/m2e-code-quality/vendor/bundle/ruby/2.7.0/gems/github_changelog_generator-1.16.4/lib/github_changelog_generator/generator/generator.rb:160:in `remove_old_fixed_string'
/home/andreas/PMD/source/m2e-code-quality/vendor/bundle/ruby/2.7.0/gems/github_changelog_generator-1.16.4/lib/github_changelog_generator/generator/generator.rb:160:in `gsub!': can't modify frozen String: "" (FrozenError)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants