palkan / anyway_config

Configuration library for Ruby gems and applications
MIT License
778 stars 52 forks source link

Gem generate warnings with ruby 3.3 about usage of it #153

Closed le0pard closed 3 weeks ago

le0pard commented 1 month ago

What did you do?

Install gem with ruby 3.3.5

What did you expect to happen?

No warnings.

What actually happened?

Have warnings about it usage:

#18 141.2 /app/vendor/bundle/ruby/3.3.0/gems/anyway_config-2.6.4/lib/anyway/type_casting.rb:37: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it
#18 141.2 /app/vendor/bundle/ruby/3.3.0/gems/anyway_config-2.6.4/lib/anyway/config.rb:157: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it
#18 141.2 /app/vendor/bundle/ruby/3.3.0/gems/anyway_config-2.6.4/lib/anyway/config.rb:383: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it
#18 141.2 /app/vendor/bundle/ruby/3.3.0/gems/anyway_config-2.6.4/lib/anyway/tracing.rb:32: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it
#18 141.2 /app/vendor/bundle/ruby/3.3.0/gems/anyway_config-2.6.4/lib/anyway/tracing.rb:87: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it
#18 141.2 /app/vendor/bundle/ruby/3.3.0/gems/anyway_config-2.6.4/lib/anyway/auto_cast.rb:16: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it
#18 141.2 /app/vendor/bundle/ruby/3.3.0/gems/anyway_config-2.6.4/lib/anyway/auto_cast.rb:18: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it

Additional context

Environment

Ruby Version: 3.3.5

Framework Version (Rails, whatever): 7.1

Anyway Config Version: 2.6.4

palkan commented 1 month ago

How do you load the gem? You must load it via the require "anyway_config" to setup the load path properly (so the Ruby 3.4+ files are not loaded in Ruby 3.3).

Does the following command work for you as below?

$ ruby -v
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin23]

$ TEST_FOO__BAR=1 ruby -ranyway_config -e "puts Anyway::Config.for(:test)"

{"foo"=>{"bar"=>1}}
le0pard commented 1 month ago

It is not after load, it is output in docker environment after bundle install command

palkan commented 1 month ago

Hm, do you run something like bootsnap precompile then? (Or whatever else trying to read Ruby files)

le0pard commented 1 month ago

yes, this is command in docker:

RUN bundle install && \
    rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
    bundle exec bootsnap precompile --gemfile

so yes, it can be warning from bootsnap command. But generated by this gem

palkan commented 3 weeks ago

Well, bootsnap precompile is a static tool, so there is hardly anything we can do here. Since the compiled file is not used in production, it's safe to disable warnings (to reduce the noise). Try something like `RUBYOPT=-W0".