rake db:schema:dump 不工作

Posted

技术标签:

【中文标题】rake db:schema:dump 不工作【英文标题】:rake db:schema:dump not working 【发布时间】:2016-10-02 19:04:57 【问题描述】:

我正在 windows 8 的 windows 平台上学习 ruby​​ on rails。现在我在数据库部分,rake db:schema:dump 命令应该在配置文件夹中创建一个名为 schema.rb 的文件,但这并没有发生。当我输入rake db:schema:dump 时,它会显示rake aborted 和一长串列表。请帮忙。

以下是控制台中显示的内容:

C:\Users\New User\sites2\learning_rails>rake db:schema;dump
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglif
ier'.
Gem Load Error is: Could not find a javascript runtime. See https://github.com/r
ails/execjs for a list of available runtimes.
Backtrace for gem load error is:
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in
 `autodetect'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:
ExecJS>'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (re
quired)>'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/uglifier-3.0.0/lib/uglifier.rb:5:in `requ
ire'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/uglifier-3.0.0/lib/uglifier.rb:5:in `<top
 (required)>'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:
in `require'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:
in `block (2 levels) in require'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:
in `each'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:
in `block in require'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:
in `each'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:
in `require'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler.rb:102:in `req
uire'
C:/Users/New User/sites2/learning_rails/config/application.rb:7:in `<top (requir
ed)>'
C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in
 `require'
C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in
 `require'
C:/Users/New User/sites2/learning_rails/Rakefile:4:in `<top (required)>'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in
 `load'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in
 `load_rakefile'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:689:i
n `raw_load_rakefile'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:94:in
 `block in load_rakefile'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:i
n `standard_exception_handling'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:93:in
 `load_rakefile'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:77:in
 `block in run'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:i
n `standard_exception_handling'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in
 `run'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-11.1.2/bin/rake:33:in `<top (require
d)>'
C:/Ruby22-x64/bin/rake:22:in `load'
C:/Ruby22-x64/bin/rake:22:in `<main>'
Bundler Error Backtrace:
C:/Users/New User/sites2/learning_rails/config/application.rb:7:in `<top (requir
ed)>'
C:/Users/New User/sites2/learning_rails/Rakefile:4:in `<top (required)>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://git
hub.com/rails/execjs for a list of available runtimes.
C:/Users/New User/sites2/learning_rails/config/application.rb:7:in `<top (requir
ed)>'
C:/Users/New User/sites2/learning_rails/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

【问题讨论】:

There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)的可能重复 以后,请将错误作为文本而不是屏幕截图。截图无法搜索或复制,阅读不便。 不,它直到现在才起作用。 【参考方案1】:

安装 nodejs

Uglifier 是 JavaScript 压缩器,所以需要 javascript 运行时尝试安装 nodejs

apt-get install nodejs

brew install nodejs

如果您使用的是 OSX。

【讨论】:

@AmareshDey 你可以从这里下载node.js [nodejs.org/en/download],否则你可以按照这个安装指南[blog.teamtreehouse.com/install-node-js-npm-windows]

以上是关于rake db:schema:dump 不工作的主要内容,如果未能解决你的问题,请参考以下文章

rake db:schema:dump 是不是从迁移或数据库本身重新创建 schema.rb?

rake db rake 任务不工作 Ruby 2.4.0 & Rails 5.0.1

rake db:如果没有版本,迁移不能正常工作

rake assets:precompile RAILS_ENV=production 不能按要求工作

Github 操作工作流 PG::ConnectionBad:无法连接到服务器:运行 bundle exec rake 时没有这样的文件或目录

Rake和Ansible有什么区别?