Already initialized constant warnings after Rails 4.2 upgrade - ruby-on-rails

After upgrading a simple Rails 4.1.8 application to Rails 4.2.0, I see lots of warnings about already initialized constants coming out of the PostgreSQL adapter:
/path/to/my/torquebox-3.1.1/jruby/lib/ruby/gems/shared/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql/array_parser.rb:6 warning: already initialized constant DOUBLE_QUOTE
/path/to/my/torquebox-3.1.1/jruby/lib/ruby/gems/shared/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql/array_parser.rb:7 warning: already initialized constant BACKSLASH
/path/to/my/torquebox-3.1.1/jruby/lib/ruby/gems/shared/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql/array_parser.rb:8 warning: already initialized constant COMMA
/path/to/my/torquebox-3.1.1/jruby/lib/ruby/gems/shared/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql/array_parser.rb:9 warning: already initialized constant BRACKET_OPEN
/path/to/my/torquebox-3.1.1/jruby/lib/ruby/gems/shared/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql/array_parser.rb:10 warning: already initialized constant BRACKET_CLOSE
Is this expected or does it indicate a problem with the new version of Rails (presumably running under JRuby)? Any way to properly fix these warnings (other than just silencing them)?

It is caused by the activerecord-jdbc-adapter gem which includes some of the core AR functionality, since it supports multiple AR releases from a single AR-JDBC gem release.
Due changes in ActiveRecord's PostgreSQL adapter support it seems to double load ArrayParser. Please note that supporting Rails 4.2 requires work here and/or here.

Known issue with very little discussion referenced here: https://github.com/jruby/jruby/issues/2286 .
When it is solved there may be an update at that location.

Related

Add Hotwire to existing Rails 6.1 app using sprockets

I'm trying to upgrade an existing Rails 6.1 with sprockets app to use stimulus. I installed
gem 'importmap-rails'
gem 'hotwire-rails'
The javascript_importmap_tags causes this error in Firefox Developer Tools:
Uncaught TypeError: Error resolving module specifier “application”. Relative module specifiers must start with “./”, “../” or “/”.
Should this work alongside sprockets?
I have importmap-rails (0.7.6), stimulus-rails (0.4.2)
Error can be safely ignored I believe.
Update: I can confirm that this error can safely be ignored, it doesn't cause any issues. Obviously this is not the ideal "solution", hence the downvote I guess, so if anyone knows a better answer and posts it that will be great and I will mark it as the accepted answer.

DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper

I'm trying to understand the deprecation warning:
DEPRECATION WARNING: Initialization autoloaded the constants
ActionText::ContentHelper and ActionText::TagHelper.
Being able to do this is deprecated. Autoloading during initialization is
going
to be an error condition in future versions of Rails.
Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload
ActionText::ContentHelper, for example,
the expected changes won't be reflected in that stale Module object.
These autoloaded constants have been unloaded.
In order to autoload safely at boot time, please wrap your code in a reloader
callback this way:
Rails.application.reloader.to_prepare do
# Autoload classes and modules needed at boot time here.
end
That block runs when the application boots, and every time there is a reload.
For historical reasons, it may run twice, so it has to be idempotent.
Check the "Autoloading and Reloading Constants" guide to learn more about how
Rails autoloads and reloads.
(called from <top (required)> at
/home/keith/development/pciapp/config/environment.rb:5)
What does this deprecation warning mean and how do I resolve it?
A bit of sleuthing revealed two sources of this deprecation warning in my Rails 6.1 app.
I referenced ActionMailer::Base in a couple of initializers. Based on the suggestion in the Rails Guides (https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration), I decided to move all those references to environment.rb.
The same deprecation error was also apparently being generated by the mailgun-ruby gem v 1.2.3. It appears the deprecation warning has been fixed in v 1.2.4.
it was an issue in rails 6.0.0 https://github.com/rails/rails/issues/36546 updating to rails 6.0.1 should fix this

Rails test throwing Deprecation Warning over attr_encrypted

Rails test is throwing a deprecation warning over a gem (attr_encrypted) which is already updated to the latest version. It reads:
DEPRECATION WARNING: <custom_attribute_name> is not an attribute known to Active Record. This behavior is deprecated and will be removed in
the next version of Rails. If you'd like <custom_attribute_name> to be managed by Active Record, add attribute :<custom_attribute_name> to your class.
Not sure what it is asking me to do... it must be declared using attr_encrypted.
The deprecation warning is something the attr_encrypted gem needs to fix, but it seems there is a workaround by adding the attribute call as mentioned in the warning.
See https://github.com/attr-encrypted/attr_encrypted/issues/260

Deprecation warning when using Compass Rails

I am using the Compass gem for Rails. After installing it, I've used some mixins that come with Compass. I am getting a deprecation warning in the console:
DEPRECATION WARNING on line 87 of /usr/local/rvm/gems/ruby-2.3.0/gems/compass-core-1.0.3/stylesheets/compass/css3/_deprecated-support.scss: #{} interpolation near operators will be simplified
in a future version of Sass. To preserve the current behavior, use quotes:
unquote('"$moz-"#{$experimental-support-for-mozilla} "$webkit-"#{$experimental-support-for-webkit} "$opera-"#{$experimental-support-for-opera} "$microsoft-"#{$experimental-support-for-microsoft} "$khtml-"#{$experimental-support-for-khtml}')
You can use the sass-convert command to automatically fix most cases.
I am having trouble finding a fix for this online. What does this warning mean and what can I do to fix it?
Apparently this is a bug in the gem. Workaround until fix is pushed to gem here: https://github.com/Compass/compass/pull/2088

Deprecation Warning for Squeel load_core_extensions

in one of my applications I get the annoying deprecation warning of squeel all the time.
DEPRECATION WARNING: Core extensions are deprecated and will be removed in Squeel 2.0. (called from app/config/initializers/configurations/squeel_init.rb:13:in `block in <top (required)>')
It is produced by this line:
config.load_core_extensions :hash, :symbol
We are running * squeel (1.2.3).
Any ideas how to avoid this message?
Thanks!
I want to say that the reason why you are getting the WORKING is to let you know that if you upgrade your gem to squeel (2.0) the Core Extensions will not work.
I think if you upgrade your gem to squeel (2.0) you will have to remove that line.
I hope that you have test in place to see where you need to upgrade your app.
Deprecation is an attribute applied to a computer software feature,
characteristic, or practice to indicate that it should be avoided
(often because it is being superseded).

Resources