Skip to content
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

After upgrade to 1.2.1 got "anonymous block parameter is also used within block" #284

Closed
elct9620 opened this issue Jan 16, 2025 · 3 comments

Comments

@elct9620
Copy link

Describe the bug

When running in AWS Lambda (Local), this error is raised, but the local test bundle exec cucumber works correctly.

/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/plugins/monitoring.rb:35: anonymous block parameter is also used within block

To Reproduce

Source Code:
https://github.com/elct9620/blog-notifier/tree/dbb704d7b5714eb5d9c6878e642f1ace989ac611

Run this shortcut to reproduce it

make invoke-Fetcher

The full error message output is

{
  "errorMessage": "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/plugins/monitoring.rb:35: anonymous block parameter is also used within block",
  "errorType": "Init<SyntaxError>",
  "stackTrace": [
    "/var/lang/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'",
    "/var/lang/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'",
    "/opt/ruby/3.3.0/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:26:in `require'",
    "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/plugins.rb:65:in `<module:Plugins>'",
    "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/plugins.rb:5:in `<module:System>'",
    "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/plugins.rb:4:in `<module:Dry>'",
    "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/plugins.rb:3:in `<top (required)>'",
    "/var/lang/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'",
    "/var/lang/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'",
    "/opt/ruby/3.3.0/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:26:in `require'",
    "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/container.rb:56:in `<class:Container>'",
    "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/container.rb:54:in `<module:System>'",
    "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/container.rb:10:in `<module:Dry>'",
    "/opt/ruby/3.3.0/gems/dry-system-1.2.1/lib/dry/system/container.rb:9:in `<top (required)>'",
    "/var/lang/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'",
    "/var/lang/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'",
    "/opt/ruby/3.3.0/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:26:in `require'",
    "/var/task/config/app.rb:12:in `<top (required)>'",
    "/var/task/config/lambda.rb:5:in `require_relative'",
    "/var/task/config/lambda.rb:5:in `<top (required)>'",
    "/var/lang/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'",
    "/var/lang/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'",
    "/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric.rb:48:in `run'",
    "/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric.rb:221:in `bootstrap_handler'",
    "/var/runtime/gems/aws_lambda_ric-3.0.0/lib/aws_lambda_ric.rb:203:in `start'",
    "/var/runtime/index.rb:4:in `<main>'"
  ]
}

Expected behavior

The Lambda Function should execute correctly with feed list.

My environment

  • Affects my production application: YES
  • Ruby version: 3.3.6 (Local) / 3.3.0 (Lambda)
  • OS: Linux
@flash-gordon
Copy link
Member

@elct9620 it's a bug in ruby 3.3.0, see https://bugs.ruby-lang.org/issues/20090 You'll need to upgrade to 3.3.1 or higher

@elct9620
Copy link
Author

Thanks for your information.

I find the root cause is aws-sam-cli use public.ecr.aws/lambda/ruby:3.3-preview which does not update to 3.3.1 or higher but public.ecr.aws/lambda/ruby:3.3 is 3.3.5 that sam local invoke cannot work correctly.

lsegal added a commit to qltysh/qlty that referenced this issue Jan 23, 2025
Currently the `reek` plugin is failing for customers. The stack trace
for these customers looks like this:

```
2025-01-22T18:03:07Z INFO [T13] qlty_check::tool (47.8 MB): Setting up tool reek@Some("6.3.0"). Logging to /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3-install.log
2025-01-22T18:03:20Z ERROR [T13] qlty_check::tool (47.8 MB): Failed to get version for package "reek": Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "<internal:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require': \n/home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types/sum.rb:33: anonymous block parameter is also used within block (SyntaxError)\n\tfrom <internal:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:26:in `require'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types/builder.rb:28:in `|'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types/builder.rb:53:in `optional'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types/core.rb:79:in `block in <module:Types>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types/core.rb:78:in `each_key'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types/core.rb:78:in `<module:Types>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types/core.rb:4:in `<module:Dry>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types/core.rb:3:in `<top (required)>'\n\tfrom <internal:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'\n\tfrom <internal:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:34:in `require'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-types-1.8.1/lib/dry/types.rb:258:in `<top (required)>'\n\tfrom <internal:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'\n\tfrom <internal:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:34:in `require'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/dry-schema-1.13.4/lib/dry/schema.rb:8:in `<top (required)>'\n\tfrom <internal:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'\n\tfrom <internal:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/configuration/schema.rb:3:in `<top (required)>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/configuration/schema_validator.rb:4:in `require_relative'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/configuration/schema_validator.rb:4:in `<top (required)>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/configuration/configuration_file_finder.rb:5:in `require_relative'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/configuration/configuration_file_finder.rb:5:in `<top (required)>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/configuration/app_configuration.rb:4:in `require_relative'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/configuration/app_configuration.rb:4:in `<top (required)>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/detector_repository.rb:5:in `require_relative'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/detector_repository.rb:5:in `<top (required)>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/examiner.rb:4:in `require_relative'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek/examiner.rb:4:in `<top (required)>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek.rb:7:in `require_relative'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/lib/reek.rb:7:in `<top (required)>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/bin/reek:9:in `require_relative'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/gems/reek-6.3.0/bin/reek:9:in `<top (required)>'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/bin/reek:25:in `load'\n\tfrom /home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/bin/reek:25:in `<main>'\n" } {"LD_LIBRARY_PATH": "/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib", "PKG_CONFIG_PATH": "/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/pkgconfig", "GEM_HOME": "/home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3", "HOME": "/home/runner", "PATH": "/home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3/bin:/home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin", "GEM_PATH": "/home/runner/.qlty/cache/tools/reek/6.3.0-fb49277b68e3", "RUBYLIB": "/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/site_ruby/3.3.0:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/site_ruby/3.3.0/x86_64-linux:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/site_ruby:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/vendor_ruby/3.3.0:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/vendor_ruby/3.3.0/x86_64-linux:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/vendor_ruby:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/3.3.0/x86_64-linux:/home/runner/.qlty/cache/tools/ruby/3.3.0-bbe397d161fc/lib/ruby/"}
2025-01-22T18:03:20Z ERROR [T13] qlty_check::tool (47.8 MB): Failed to set up reek@Some("6.3.0"): Failed to get version for package "reek": (command sh -c "reek --version" exited with code 1)
2025-01-22T18:03:20Z ERROR [T1] qlty (8.7 MB): Command failed: qlty build
❌ Error installing reek@6.3.0.
```

Initially this was very confusing since there were no CLI upgrades
between when it was working and when it suddenly stopped working ...

In digging into it, we discovered that:

- the reek gem [depends on
dry-schema](https://github.com/troessner/reek/blob/master/reek.gemspec#L35)
- dry-schema [depends on
dry-types](https://github.com/dry-rb/dry-schema/blob/main/dry-schema.gemspec#L44)
version `~1.8`
- dry-types recently [upgraded to 1.8.1 from
1.8.0](https://github.com/dry-rb/dry-types/releases/tag/v1.8.1)

Because of the dependency chain, this upgrade was picked up and changed
the behavior of the plugin.

The upgrade apparently [exposed a
bug](https://bugs.ruby-lang.org/issues/20090) in Ruby 3.3.0 that it
previously hadn't run into. (h/t
dry-rb/dry-system#284 (comment)).

This PR bumps the version of ruby to the latest on the 3.3.x line
(`3.3.7`).

However, I'm currently unable to install this locally via qlty and
cannot verify that it does indeed fix the bug. `Reek` runs tests on
3.3.6, so that is also a fairly safe alternative (bug also does not
install locally for me).

---------

Co-authored-by: Loren Segal <loren@codeclimate.com>
Co-authored-by: Loren Segal <lsegal@soen.ca>
@flash-gordon
Copy link
Member

FYI I've pushed 1.2.2 that has a compatible syntax

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

No branches or pull requests

2 participants