【问题标题】:DB creation in rails using the rake command使用 rake 命令在 Rails 中创建数据库
【发布时间】:2016-04-05 13:16:54
【问题描述】:

我正在尝试创建一个测试数据库。 我使用了以下命令:

  rake db:schema:create

还尝试了各种版本的代码,例如

sudo bundle exec rake db:create

我不断收到同样的错误:

rake aborted!
LoadError: no such file to load -- bundler/setup
/home/eshel/test/test_db/config/boot.rb:4:in `<top>'
/home/eshel/test/test_db/config/application.rb:1:in `<top>'
/home/eshel/test/test_db/config/application.rb:1:in `<top>'
/home/eshel/test/test_db/Rakefile:1:in `(root)'
/home/eshel/test/test_db/Rakefile:5:in `(root)'
(See full trace by running task with --trace)

尝试多次安装捆绑包,但到目前为止没有任何效果。

我错过了什么?

【问题讨论】:

  • 你安装了bundler吗?
  • 捆绑安装工作正常吗?
  • 运行gem install bundler 并重试。 旁注:在您了解sudo 的用途之前,请不要使用sudo
  • 是的,我使用了这个命令:sudo bundle install
  • @Eshel:请指定您正在使用的 Rails 版本。

标签: ruby-on-rails ruby ubuntu rubygems rakefile


【解决方案1】:

尝试以下方法:

gem install bundler
bundle install
rake db:create

【讨论】:

  • 它给了我这一行:捆绑完成! 13 个 Gemfile 依赖项,现在安装了 51 个 gem。捆绑的 gem 安装在 /home/eshel/main_server 中。如果我想要他们在不同的地方有关系吗?除了 main_server 文件夹?
  • 这可能是我正在运行的 jruby 和 ruby​​ 版本的问题吗?我无法将 jruby 和 ruby​​ 版本设置为 rvm 列表中出现的版本
  • 尝试使用bundle exec rake db:create
  • 尝试使用最新版本的 rvm 安装 ruby​​,然后重新安装 rails 并执行上述命令
  • 谢谢!我的应用程序使用的 ruby​​ 和 jruby 版本不匹配,在我解决之后,上面的命令成功了 :) 感谢您的帮助
猜你喜欢
  • 2012-11-24
  • 2010-11-28
  • 2018-04-12
  • 2016-02-17
  • 1970-01-01
  • 2012-09-18
  • 1970-01-01
  • 1970-01-01
  • 2023-03-17
相关资源
最近更新 更多