使用捆绑安装时出现弃用警告

DEPRECATION WARNING while using bundle install

所以我正在尝试进行捆绑安装。但它抛出以下错误。这里有什么问题?

bundle exec rake db:create:all
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:66)
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:67)
rake aborted!
Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file - 
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Could not load database configuration. No such file - 
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)

之前我曾尝试过以下方法:

rake db:create:all
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/runtime.rb:34:in `block in setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/runtime.rb:19:in `setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler.rb:122:in `setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/setup.rb:7:in `<top (required)>'
/home/project/config/boot.rb:4:in `<top (required)>'
/home/project/config/application.rb:1:in `<top (required)>'
/home/project/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/project/config/boot.rb:4:in `<top (required)>'
/home/project/config/application.rb:1:in `<top (required)>'
/home/project/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
$  bundle exec rake db:create:all
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:66)
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:67)
rake aborted!
Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file - 
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Could not load database configuration. No such file - 
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)

您的项目目录中似乎没有 config/database.yml 文件。

为什么我这么认为?关注我...

Could not load database configuration. No such file - /home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'

好的,让我们看一下这段代码中有错误的地方:

yaml = Pathname.new(paths["config/database"].existent.first || "")
config = if yaml.exist?
  require "yaml"
  require "erb"
  YAML.load(ERB.new(yaml.read).result) || {}
elsif ENV['DATABASE_URL']
  # Value from ENV['DATABASE_URL'] is set to default database connection
  # by Active Record.
  {}
else
  raise "Could not load database configuration. No such file - #{yaml}"
end

如您所见 - 如果没有这样的文件或 ENV 变量,则 rails 会抛出错误。

您正在尝试 运行 "rake db:create:all" 这将创建您的数据库,但作为错误状态 - 似乎您没有 config/database.yml 文件。它是一个配置文件,告诉 rails 如何连接到您的数据库。您可以阅读更多相关信息 here.

如果您真的想 运行 捆绑安装,只需使用 "bundle install" 命令即可。这将安装您的 Gemfile 中列出的所有 gem。

如果您遇到 rake 版本冲突的问题,请查看 this 堆栈溢出问题。