How to fix «Gem::LoadError: You have already activated rake 12.3.0, but your Gemfile requires rake 12.1.0»?

dfediuk@ubuntu:~/discourse/code$ rm -rf tmp log/* && rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- bin/bundle exec bin/rails s -b 0.0.0.0
Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.1, file filtering is supported) listens on 0.0.0.0:1234
bundler: failed to load command: bin/rails (bin/rails)
Gem::LoadError: You have already activated rake 12.3.0, but your Gemfile requires rake 12.1.0. Prepending `bundle exec` to your command may solve this.
  ~/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:313:in `check_for_activated_spec!'
  ~/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:31:in `block in setup'
  ~/.rbenv/versions/2.4.2/lib/ruby/2.4.0/forwardable.rb:229:in `each'
  ~/.rbenv/versions/2.4.2/lib/ruby/2.4.0/forwardable.rb:229:in `each'
  ~/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:26:in `map'
  ~/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:26:in `setup'
  ~/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
  ~/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/setup.rb:10:in `<top (required)>'
  ~/.rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
  ~/.rbenv/versions/2.4.2/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'

Replace the line:

with

rake (12.3.0)

Then run

bundle install
bundle exec rake db:migrate