由于缺少 Mime JSON,rake 任务无法启动
rake task does not launch for lack of Mime JSON
在本地安装存储库并为 rails 4.0 应用程序捆绑后,数据库创建
rake db:create
命令失败返回以下错误:
uninitialized constant Mime::JSON
从 application.rb 这一特定行调用
Bundler.require(:default, Rails.env)
这一行前面是:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
我怎样才能正确处理抽成?
**更新**
根据请求,完整堆栈跟踪如下。我确实通过删除 jbuilder gem.
设法避免了错误
NameError: uninitialized constant Mime::JSON
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder/jbuilder_template.rb:110:in `<class:JbuilderHandler>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder/jbuilder_template.rb:108:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder.rb:358:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
/Volumes/Mo/r/uelcom/config/application.rb:7:in `<top (required)>'
/Volumes/Mo/r/uelcom/Rakefile:8:in `require'
/Volumes/Mo/r/uelcom/Rakefile:8:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/bin/rake:23:in `load'
/Users/deploy/.rbenv/versions/2.6.1/bin/rake:23:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/bin/bundle:23:in `load'
/Users/deploy/.rbenv/versions/2.6.1/bin/bundle:23:in `<main>'
您似乎使用的是 rails 5 或更高版本。
从 rails 版本 5 或更高版本开始,通过 Mime::JSON
访问 Mime 类型已被弃用,我们需要以 Mime[:json]
访问它
请找到以下相同的参考资料 - Release Note and Pull request
Deprecated accessing mime types via constants (eg. Mime::HTML). Use the subscript operator with a symbol instead (eg. Mime[:html])
根据您提供的异常的回溯,gem jbuilder
导致了问题,它以 Mime::JSON
的形式访问 Mime 类型,这已被弃用。
请在 gem jbuilder - Jubilder - Github.
上找到导致错误的行的参考
您使用的是旧版本jbuilder(1.5.3)
,请将此gem升级到最新版本再试试
试试下面的版本:
Gemfile
gem 'jbuilder', '~> 2.10'
在本地安装存储库并为 rails 4.0 应用程序捆绑后,数据库创建
rake db:create
命令失败返回以下错误:
uninitialized constant Mime::JSON
从 application.rb 这一特定行调用
Bundler.require(:default, Rails.env)
这一行前面是:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
我怎样才能正确处理抽成?
**更新** 根据请求,完整堆栈跟踪如下。我确实通过删除 jbuilder gem.
设法避免了错误NameError: uninitialized constant Mime::JSON
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder/jbuilder_template.rb:110:in `<class:JbuilderHandler>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder/jbuilder_template.rb:108:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jbuilder-1.5.3/lib/jbuilder.rb:358:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
/Volumes/Mo/r/uelcom/config/application.rb:7:in `<top (required)>'
/Volumes/Mo/r/uelcom/Rakefile:8:in `require'
/Volumes/Mo/r/uelcom/Rakefile:8:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/bin/rake:23:in `load'
/Users/deploy/.rbenv/versions/2.6.1/bin/rake:23:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/bin/bundle:23:in `load'
/Users/deploy/.rbenv/versions/2.6.1/bin/bundle:23:in `<main>'
您似乎使用的是 rails 5 或更高版本。
从 rails 版本 5 或更高版本开始,通过 Mime::JSON
访问 Mime 类型已被弃用,我们需要以 Mime[:json]
请找到以下相同的参考资料 - Release Note and Pull request
Deprecated accessing mime types via constants (eg. Mime::HTML). Use the subscript operator with a symbol instead (eg. Mime[:html])
根据您提供的异常的回溯,gem jbuilder
导致了问题,它以 Mime::JSON
的形式访问 Mime 类型,这已被弃用。
请在 gem jbuilder - Jubilder - Github.
上找到导致错误的行的参考您使用的是旧版本jbuilder(1.5.3)
,请将此gem升级到最新版本再试试
试试下面的版本:
Gemfile
gem 'jbuilder', '~> 2.10'