【问题标题】:NoMethodError: undefined method `fetch' for "QLite version 3.x":StringNoMethodError:“QLite 版本 3.x”的未定义方法“获取”:字符串
【发布时间】:2014-06-16 04:25:17
【问题描述】:

当我尝试将我的 Rails 应用程序部署到生产环境时,我看到了这个错误

SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xx: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
NoMethodError: undefined method `fetch' for "QLite version 3.x":String

这个错误是由命令调用的

Command: cd /home/deploy/myapp/releases/20140616034148 && ( RAILS_ENV=production ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )

头文件

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rvm'
set :rvm_ruby_version, '2.1.2'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

部署.rb

lock '3.1.0'
set :application, 'myapp'
set :repo_url, 'git@bitbucket.org:username/myapp.git'
set :deploy_to, '/home/deploy/myapp'
set :branch, "master"
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
       execute :touch, release_path.join('tmp/restart.txt')
    end
  end

生产.rb

set :stage, :production
role :app, %w{deploy@xxx.xxx.xxx.xx}
role :web, %w{deploy@xxx.xxx.xxx.xx}
role :db,  %w{deploy@xxx.xxx.xxx.xx}
set :password, ask('Server password', nil)
server '107.170.187.98', user: 'deploy', password: fetch(:password), roles: %w{web app}
set :bundle_env_variables, { 'NOKOGIRI_USE_SYSTEM_LIBRARIES' => 1 }

我不明白是什么导致了这个问题。有人可以指出我正确的方向吗?

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-4 nginx capistrano


    【解决方案1】:

    检查您在生产服务器上设置的 config/database.yml 文件。它的第一行可能是“QLite version 3.x”——这是因为它曾经是“# SQLite version 3.x”,但最初的“#S”已经不见了。

    要解决此问题,只需将“# S”添加回其前面,或完全删除该行。完成此操作后,您的 Capistrano 部署应该会再次开始工作。


    我猜你将 config/database.yml 文件从别处粘贴到 Vim 实例中;由于完全相同的原因,我遇到了与您完全相同的问题。如果你在粘贴之前没有将 Vim 置于插入模式,它会粘贴整个内容,但会从前面去掉“#S”。

    之所以特别删除这三个是因为这些字母实际上是Vim命令。如果您不在插入模式下,当您粘贴某些内容时,这些命令将运行。这三个字符在粘贴时按顺序执行以下操作:

    • # - 将光标移动到上次搜索的上一个匹配项。由于我们没有搜索任何内容,因此没有任何反应。
    • 空格 - 将光标向右移动一次。由于编辑器中没有内容,因此没有任何反应。
    • S - 删除 S 之前的行数。由于 S 之前没有数字,因此不会删除任何内容。完成后,我们进入插入模式,并粘贴文档的其余部分。

    来源:http://vimdoc.sourceforge.net/htmldoc/

    【讨论】:

    • 谢谢,这正是问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-05
    • 1970-01-01
    相关资源
    最近更新 更多