I upgraded the project to Rails 5. When I run rspec
I get a warning
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead.
From module, you can access the original method using super.
(called from <top (required)> at /home/alex/projects/myproject/config/application.rb:13)
The failing line in application.rb is:
Bundler.require(*Rails.groups)
How do I find out what is causing this deprecation warning and how to get rid of the error?
Install (unless already installed) ack and run in the terminal:
ack alias_method_chain /Users/username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.1/gems/
It will indicate all places where alias_method_chain
is used (files and code lines).
99% chance it is used in some of your gems.
See my answer for a list of things you can do about it.
In OSX, you can use:
grep -Ir alias_method_chain `bundle show rails`/..
And that will list all of the gems that use alias_method_chain
If the Gemfile is too large I would recommend to use the_silver_searcher to search for deprecated alias_method_chain because it is faster
ag alias_method_chain /path/to/gemset
I have gepgems
bash helper function to not type /path/to/gemset every time
grepgems alias_method_chain
To use it add the following function to your .bash_profile (or somewhere else in the dotfiles you like)
function grepgems() {
ag $1 $GEM_HOME"/gems"
}
Solution for docker :
docker exec -it [CONTAINER_NAME] /bin/bash
apt-get install silversearcher-ag
ag alias_method_chain $GEM_HOME"/gems"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With