Rake gives a pile of warnings, but eventually works - ruby-on-rails

I don't know what the hell happened to my app, it's probably since running bundle install lately, but each rake command is preceded by a pile of warnings. e.g, running rake db:migrate (My project is under /railsProjects/matal-x):
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:3: warning: already initialized constant Rake::VERSION
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:3: warning: previous definition of VERSION was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: already initialized constant Rake::Version::MAJOR
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: previous definition of MAJOR was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: already initialized constant Rake::Version::MINOR
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: previous definition of MINOR was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: already initialized constant Rake::Version::BUILD
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: previous definition of BUILD was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: already initialized constant Rake::Version::OTHER
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:6: warning: previous definition of OTHER was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:8: warning: already initialized constant Rake::Version::NUMBERS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/version.rb:8: warning: previous definition of NUMBERS was here
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/linked_list.rb:110: warning: already initialized constant Rake::LinkedList::EMPTY
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/linked_list.rb:110: warning: previous definition of EMPTY was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/scope.rb:41: warning: already initialized constant Rake::Scope::EMPTY
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/scope.rb:41: warning: previous definition of EMPTY was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_utils.rb:10: warning: already initialized constant FileUtils::RUBY
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_utils.rb:10: warning: previous definition of RUBY was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_utils.rb:109: warning: already initialized constant FileUtils::LN_SUPPORTED
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_utils.rb:109: warning: previous definition of LN_SUPPORTED was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_utils_ext.rb:17: warning: already initialized constant Rake::FileUtilsExt::DEFAULT
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_utils_ext.rb:17: warning: previous definition of DEFAULT was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:44: warning: already initialized constant Rake::FileList::ARRAY_METHODS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:44: warning: previous definition of ARRAY_METHODS was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:47: warning: already initialized constant Rake::FileList::MUST_DEFINE
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:47: warning: previous definition of MUST_DEFINE was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:51: warning: already initialized constant Rake::FileList::MUST_NOT_DEFINE
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:51: warning: previous definition of MUST_NOT_DEFINE was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:55: warning: already initialized constant Rake::FileList::SPECIAL_RETURN
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:55: warning: previous definition of SPECIAL_RETURN was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:61: warning: already initialized constant Rake::FileList::DELEGATING_METHODS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:61: warning: previous definition of DELEGATING_METHODS was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:86: warning: already initialized constant Rake::FileList::GLOB_PATTERN
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:86: warning: previous definition of GLOB_PATTERN was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:381: warning: already initialized constant Rake::FileList::DEFAULT_IGNORE_PATTERNS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:381: warning: previous definition of DEFAULT_IGNORE_PATTERNS was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:387: warning: already initialized constant Rake::FileList::DEFAULT_IGNORE_PROCS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/file_list.rb:387: warning: previous definition of DEFAULT_IGNORE_PROCS was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/promise.rb:12: warning: already initialized constant Rake::Promise::NOT_SET
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/promise.rb:12: warning: previous definition of NOT_SET was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:13: warning: already initialized constant Rake::CommandLineOptionError
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:13: warning: previous definition of CommandLineOptionError was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:41: warning: already initialized constant Rake::Application::DEFAULT_RAKEFILES
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:41: warning: previous definition of DEFAULT_RAKEFILES was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/task_arguments.rb:108: warning: already initialized constant Rake::EMPTY_TASK_ARGS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/task_arguments.rb:108: warning: previous definition of EMPTY_TASK_ARGS was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/invocation_chain.rb:55: warning: already initialized constant Rake::InvocationChain::EMPTY
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/invocation_chain.rb:55: warning: previous definition of EMPTY was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/early_time.rb:21: warning: already initialized constant Rake::EARLY
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/early_time.rb:21: warning: previous definition of EARLY was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/late_time.rb:17: warning: already initialized constant Rake::LATE
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/late_time.rb:17: warning: previous definition of LATE was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:4: warning: already initialized constant Rake::Backtrace::SYS_KEYS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:4: warning: previous definition of SYS_KEYS was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:5: warning: already initialized constant Rake::Backtrace::SYS_PATHS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:5: warning: previous definition of SYS_PATHS was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:8: warning: already initialized constant Rake::Backtrace::SUPPRESSED_PATHS
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:8: warning: previous definition of SUPPRESSED_PATHS was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:12: warning: already initialized constant Rake::Backtrace::SUPPRESSED_PATHS_RE
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:12: warning: previous definition of SUPPRESSED_PATHS_RE was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:16: warning: already initialized constant Rake::Backtrace::SUPPRESS_PATTERN
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake/backtrace.rb:16: warning: previous definition of SUPPRESS_PATTERN was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake.rb:70: warning: already initialized constant FileList
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake.rb:70: warning: previous definition of FileList was here
/home/guy/railsProjects/matal-x/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake.rb:71: warning: already initialized constant RakeFileUtils
/home/guy/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-12.3.0/lib/rake.rb:71: warning: previous definition of RakeFileUtils was here
eventually the command is being run (e.i the column is being added to the table) but this is very strange.
I run Rails 4.2.5 over ruby 2.1.1 (using rbenv), so I'm a bit surprised to see gems being installed under 2.1.0, but I'm not sure this has anything to do with my problem since I haven't updated my ruby version for a long time.
I've already tried removing rake using gem uninstall and then reinstalling, even got to desperately trying gem clean and now nothing works. When I try running bundle install or bundle update it doesnt' do anything, even though I delete Gemfile.lock.
Any Ideas? reverting to an older commit means about two weeks of work getting lost or at least re-written.

Instead of running rake, try bin/rake (assuming you're starting in your project's root directory). If bin/rake is gone for some reason, you could create a new Rails project elsewhere and copying it from there.
On Rails 5, you could also run rails test (or bin/rails test).
I think it may have something to do with recent versions of bundler which made some breaking changes. You might be able to revert bundler to 1.15.x as well (but I haven't tested this).

Related

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

I just tried to update my gem library with command gem update and updating finished smooth.
After that I updated version of my rails project in Gemfile from 6.0.1 to 6.0.3 and after running rails s I got a list of warnings:
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/fileutils/version.rb:4: warning: already initialized constant FileUtils::VERSION
/home/zire/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/fileutils-1.4.1/lib/fileutils.rb:105: warning: previous definition of VERSION was here
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_AIO_LISTIO_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_AIO_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_AIO_PRIO_DELTA_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_ARG_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_ATEXIT_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_BC_BASE_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_BC_DIM_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_BC_SCALE_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_BC_STRING_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_CHILD_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_CLK_TCK
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_COLL_WEIGHTS_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_DELAYTIMER_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_EXPR_NEST_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_HOST_NAME_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_IOV_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_LINE_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_LOGIN_NAME_MAX
/home/zire/.rbenv/versions/2.6.4/lib/ruby/2.6.0/x86_64-linux/etc.so: warning: already initialized constant Etc::SC_NGROUPS_MAX
First line issue I fixed with uninstalling fileutilis with gem uninstall fileutils and running gem update --default
Now I have problem with rest of warning lines. Is there any solution there?
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.

Rails: Why do I get "warning: already initialized constant JSON::VERSION" when running rake cucumber?

I've just set up a Linux Mint box for rails development with rvm. I went ahead and generated a Rails 5 app, set up the mysql connection, added the cucumber-rails gem and then tried to run:
rake cucumber
For some reason, I was met with:
/usr/bin/ruby2.3 -S bundle exec cucumber --profile default
/usr/lib/ruby/vendor_ruby/json/version.rb:3: warning: already initialized constant JSON::VERSION
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:3: warning: previous definition of VERSION was here
/usr/lib/ruby/vendor_ruby/json/version.rb:4: warning: already initialized constant JSON::VERSION_ARRAY
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:4: warning: previous definition of VERSION_ARRAY was here
/usr/lib/ruby/vendor_ruby/json/version.rb:5: warning: already initialized constant JSON::VERSION_MAJOR
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:5: warning: previous definition of VERSION_MAJOR was here
/usr/lib/ruby/vendor_ruby/json/version.rb:6: warning: already initialized constant JSON::VERSION_MINOR
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:6: warning: previous definition of VERSION_MINOR was here
/usr/lib/ruby/vendor_ruby/json/version.rb:7: warning: already initialized constant JSON::VERSION_BUILD
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:7: warning: previous definition of VERSION_BUILD was here
/usr/lib/ruby/vendor_ruby/json/common.rb:99: warning: already initialized constant JSON::NaN
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/common.rb:99: warning: previous definition of NaN was here
/usr/lib/ruby/vendor_ruby/json/common.rb:101: warning: already initialized constant JSON::Infinity
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/common.rb:101: warning: previous definition of Infinity was here
/usr/lib/ruby/vendor_ruby/json/common.rb:103: warning: already initialized constant JSON::MinusInfinity
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/common.rb:103: warning: previous definition of MinusInfinity was here
/usr/lib/ruby/vendor_ruby/json/common.rb:128: warning: already initialized constant JSON::UnparserError
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/common.rb:128: warning: previous definition of UnparserError was here
This is, to my knowledge, a fairly plain vanilla installation, so I cannot understand what I've done to earn these warnings. Do I somehow have conflicting gems in place? If so, how do I resolve this?
I managed to get rid of the JSON warnings by:
bundle clean --force
bundle
The json gem that came with your version of Ruby is a little outdated. If you want to get rid of these warnings, you have to include a more up to date version of it in your Gemfile:
gem 'json', '>= 2.0.0'
Then run bundle install.
redshift5's answer worked for me. Just to add more context.
I had this same issue while working on an application with Rails 6.
I was getting warnings like this:
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:4: warning: already initialized constant JSON::VERSION
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:4: warning: previous definition of VERSION was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:5: warning: already initialized constant JSON::VERSION_ARRAY
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:5: warning: previous definition of VERSION_ARRAY was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:6: warning: already initialized constant JSON::VERSION_MAJOR
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:6: warning: previous definition of VERSION_MAJOR was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:7: warning: already initialized constant JSON::VERSION_MINOR
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:7: warning: previous definition of VERSION_MINOR was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:8: warning: already initialized constant JSON::VERSION_BUILD
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:8: warning: previous definition of VERSION_BUILD was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:100: warning: already initialized constant JSON::NaN
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:130: warning: previous definition of NaN was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:102: warning: already initialized constant JSON::Infinity
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:132: warning: previous definition of Infinity was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:104: warning: already initialized constant JSON::MinusInfinity
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:134: warning: previous definition of MinusInfinity was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:129: warning: already initialized constant JSON::UnparserError
Things I tried:
I tried removing my Gemfile.lock file and trying to do a fresh bundle install but that did not fix it.
I tried to uninstall all gem versions of puma and jsonapi-serializer from my computer and reinstalling them, but that did not fix it.
Here's how I fixed:
First I ran the command below to force clean up unused gems in the bundler directory even if --path is set:
bundle clean --force
Next, I ran the command below to reinstall my gems for the project:
bundle install
OR
bundle update
OR
bundle update --force
That's all.
I hope this helps.

How to resolve BigDecimal 'already initialised constant' warnings on 'mailcatcher' cmd?

Every time I start mailcatcher I'm shown 'already initialised constant' warnings. Can anyone advise how to resolve the issue? Thanks. Update below.
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::BASE
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::EXCEPTION_ALL
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::EXCEPTION_NaN
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::EXCEPTION_INFINITY
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::EXCEPTION_UNDERFLOW
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::EXCEPTION_OVERFLOW
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::EXCEPTION_ZERODIVIDE
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::ROUND_MODE
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::ROUND_UP
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::ROUND_DOWN
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::ROUND_HALF_UP
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::ROUND_HALF_DOWN
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::ROUND_CEILING
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::ROUND_FLOOR
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::ROUND_HALF_EVEN
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::SIGN_NaN
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::SIGN_POSITIVE_ZERO
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::SIGN_NEGATIVE_ZERO
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::SIGN_POSITIVE_FINITE
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::SIGN_NEGATIVE_FINITE
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::SIGN_POSITIVE_INFINITE
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::SIGN_NEGATIVE_INFINITE
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::INFINITY
/Users/james/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-13/2.1.0/bigdecimal-1.2.7/bigdecimal.bundle: warning: already initialized constant BigDecimal::NAN
Update: I've uninstalled gem bigdecimal and installed gem bigdecimal, no change. I've then specified gem 'bigdecimal', ~> 1.1, still no change. Not much around on searches for this error. I'm running Ruby 2.1.5 and Rails 4.2.1.
It may be a problem with the bigdecimal gem. Try forcing v1.1 in your Gemfile:
gem 'bigdecimal', '~> 1.1'
From this answer.

in rails warning: already initialized constant

/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/i686-linux/psych.so: warning: already initialized constant ANY
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/i686-linux/psych.so: warning: already initialized constant UTF8
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/i686-linux/psych.so: warning: already initialized constant UTF16LE
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/i686-linux/psych.so: warning: already initialized constant UTF16BE
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:12: warning: already initialized constant ANY
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:15: warning: already initialized constant UTF8
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:18: warning: already initialized constant UTF16LE
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:21: warning: already initialized constant UTF16BE
i got this error when i strated my rails server for the first time after creating a new rails project. could anyone help me out of this
The fix for me was simply to do gem uninstall psych.
Perhaps the solution described on this gist will help:
rvm use 1.9.3
gem uninstall psych
gem install psych

rails3 rake db:migrate error

Helo,
I am trying to run rake db:migrate for my rails 3 application using mysql2 gem.
But it ended up with below error.
Do you have any idea?
Thanks
WARNING: This version of mysql2 (0.3.7) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/version.rb:9: warning: already initialized constant VERSION
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake.rb:26: warning: already initialized constant RAKEVERSION
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/early_time.rb:17: warning: already initialized constant EARLY
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/application.rb:28: warning: already initialized constant DEFAULT_RAKEFILES
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/invocation_chain.rb:49: warning: already initialized constant EMPTY
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/dsl_definition.rb:143: warning: already initialized constant Commands
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:44: warning: already initialized constant ARRAY_METHODS
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:47: warning: already initialized constant MUST_DEFINE
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:51: warning: already initialized constant MUST_NOT_DEFINE
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:55: warning: already initialized constant SPECIAL_RETURN
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:61: warning: already initialized constant DELEGATING_METHODS
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:364: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake/file_list.rb:370: warning: already initialized constant DEFAULT_IGNORE_PROCS
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake.rb:64: warning: already initialized constant FileList
/Users/Sako/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-0.9.2/lib/rake.rb:65: warning: already initialized constant RakeFileUtils
rake aborted!
stack level too deep
The answer is in the error message:
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
Just fix the mysql version in your gemfile :)
check GemFile and just edit the rails version from 3.0.0 to 3.1.0 and don't care about mysql version, keep it 0.3.7, you don't have to downgrade it

Resources