I'm currently experiencing an issue with my new rails application, more specifically:
- Rails 5.2.0
- Ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
- rvm 1.29.4 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
When I run rails c
, it produces a warning links to fileutils gem as the following:
`/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/fileutils.rb:90:` `warning:` `already` initialized constant FileUtils::VERSION
/usr/local/lib/ruby/gems/2.5.0/gems/fileutils-1.1.0/lib/fileutils.rb:92: warning: previous definition of VERSION was here
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/fileutils.rb:1188: warning: already initialized constant FileUtils::Entry_::S_IF_DOOR
/usr/local/lib/ruby/gems/2.5.0/gems/fileutils-1.1.0/lib/fileutils.rb:1267: warning: previous definition of S_IF_DOOR was here
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/fileutils.rb:1446: warning: already initialized constant FileUtils::Entry_::DIRECTORY_TERM
/usr/local/lib/ruby/gems/2.5.0/gems/fileutils-1.1.0/lib/fileutils.rb:1541: warning: previous definition of DIRECTORY_TERM was here
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/fileutils.rb:1448: warning: already initialized constant FileUtils::Entry_::SYSCASE
/usr/local/lib/ruby/gems/2.5.0/gems/fileutils-1.1.0/lib/fileutils.rb:1543: warning: previous definition of SYSCASE was here
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/fileutils.rb:1501: warning: already initialized constant FileUtils::OPT_TABLE
/usr/local/lib/ruby/gems/2.5.0/gems/fileutils-1.1.0/lib/fileutils.rb:1596: warning: previous definition of OPT_TABLE was here
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/fileutils.rb:1555: warning: already initialized constant FileUtils::LOW_METHODS
/usr/local/lib/ruby/gems/2.5.0/gems/fileutils-1.1.0/lib/fileutils.rb:1650: warning: previous definition of LOW_METHODS was here
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/fileutils.rb:1562: warning: already initialized constant FileUtils::METHODS
/usr/local/lib/ruby/gems/2.5.0/gems/fileutils-1.1.0/lib/fileutils.rb:1657: warning: previous definition of METHODS was here
I follow all the step as outlined in this guideline http://railsapps.github.io/installrubyonrails-mac.html
.
You can replicate the issue by just following the guideline or with the following steps:
- rvm install ruby-2.5.1
- rails new app
- cd app
- gem update
- bundle update
After observing and working around, I've found that the default version of fileutils come with Ruby 2.5.* is 1.0.2 and the gem update
command installs a another newer version 1.1.0. Therefore, there are two versions of fileutils
are loaded when I run the rails c
.
To deal with this issue, I append --default
option to the gem update
command.
gem update --default
As a result, I got two default versions which can be seen by running gem list | grep fileutils
. This is the only way I can get rid the warning.
mac: gem list | grep fileutils
fileutils (default: 1.1.0, default: 1.0.2)
I write this question with, kind of, answer just to share with someone who may experience the same issue. I spent hours to sort it out as I couldn't find any helps on the internet.
Note: the same issue happens when I use rbenv
instead of rvm
on macOS Sierra.
Please let me know if anyone has a better approach to deal with such an issue.
Cheers,