[ROR] Ruby on Rails “cannot load such file – [package]” 해결 방법

왜그런진 잘 모르겠지만 오늘 업데이트 이후에 rails 서버 시작 시 에러가 발생합니다. 내용을 보자니.. mime/types를 찾을 수 없다고 하네요.

#> rails s => Booting Thin => Rails 4.2.9 application starting in development on http://localhost:3000 => Run rails server -h for more startup options => Ctrl-C to shutdown server /usr/lib/ruby/vendor_ruby/active_support/core_ext/load_error.rb:2: warning: already initialized constant LoadError::REGEXPS /usr/share/rubygems-integration/all/gems/activesupport-4.2.9/lib/active_support/core_ext/load_error.rb:2: warning: previous definition of REGEXPS was here /usr/lib/ruby/vendor_ruby/active_support/core_ext/load_error.rb:28: warning: already initialized constant MissingSourceFile /usr/share/rubygems-integration/all/gems/activesupport-4.2.9/lib/active_support/core_ext/load_error.rb:28: warning: previous definition of MissingSourceFile was here Exiting /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in require': cannot load such file -- mime/types (LoadError) from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in block in require’ from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:240:in load_dependency' from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in require’ from /usr/lib/ruby/vendor_ruby/mail.rb:15:in `rescue in '

분명 깔려있는데..

#> gem list | grep mime mime (0.4.4) mime-types (3.1) mime-types-data (3.2016.0521, 3.2015.1120) mime_type (0.0.1) mimemagic (0.3.2)

조금 고민하다가.. 설마하고 Gemfile 봤는데, mime-types가 없더군요.. rails에선 기본으로 추가해지 않았지만 실행할땐 필요로 하는.. 뭐 이런 상황이 있는지.. 추가해주면 잘 실행됩니다.

#> vim Gemfile [+] gem ‘mime-types’

#> rails s => Booting Thin => Rails 4.2.9 application starting in development on http://localhost:3000 => Run rails server -h for more startup options => Ctrl-C to shutdown server /usr/lib/ruby/vendor_ruby/active_support/core_ext/load_error.rb:2: warning: already initialized constant LoadError::REGEXPS /usr/share/rubygems-integration/all/gems/activesupport-4.2.9/lib/active_support/core_ext/load_error.rb:2: warning: previous definition of REGEXPS was here /usr/lib/ruby/vendor_ruby/active_support/core_ext/load_error.rb:28: warning: already initialized constant MissingSourceFile /usr/share/rubygems-integration/all/gems/activesupport-4.2.9/lib/active_support/core_ext/load_error.rb:28: warning: previous definition of MissingSourceFile was here Thin web server (v1.6.3 codename Protein Powder) Maximum connections set to 1024 Listening on localhost:3000, CTRL+C to stop

Conclusion

아마 mime-types 말고도 비슷한 에러를 겪는 분들이 있을거란 생각이 듭니다. rails 내 Gemfile에 빠져있을 수 있으니 꼭 확인해보시고, 없다면 추가하면 좋을 것 같습니다. (물론 gem이 설치되어 있는데도 발생할 때)