Rails 5.2.0 with Ruby 2.5.1 Console - 'Warning:' 'Already' Initialized Constant Fileutils::Version

Running rails s after gem update returns list of warnings - warning: already initialized constant Etc::SC_AIO_LISTIO_MAX

I found solution after running bundle update command I also run bundle clean --force and on the next run of rails s command all warnings disappears.

warning: already initialized constant within config/routes.rb

There are a number of reasons why this error may be happening, but a fix would be to not declare the constant. Not sure it you're using DistributionSlug::MATCH_REGEX elsewhere in your code, but if you aren't, you can do:

class DistributionSlugConstraint
def self.matches?(request)
request.fullpath =~ /B[a-zA-Z1-9_]{5}/
end
end

If you are using it elsewhere in your code you could make it a class method and call that instead of the constant. Another route to go might be to declare it as a configuration in application.rb

I've seen this kind of thing pop up when using a multi-threaded app server like puma, or in Sidekiq jobs. Hard to say more without knowing more about your infrastructure.

Strange Heroku CLI errors / warnings - 'already initialized constant'

Update your plugins with 'heroku plugins:update'

Your pgbackups one is out of date.

how to get rid of ruby's warning: already initialized constant

The easy way:

v, $VERBOSE = $VERBOSE, nil
# code goes here
$VERBOSE = v


Related Topics



Leave a reply



Submit