【问题标题】:Argument error while deploying rails app via capistrano to bluehost通过 capistrano 将 rails 应用程序部署到 bluehost 时出现参数错误
【发布时间】:2013-04-30 22:30:03
【问题描述】:

我已经使用 rails 构建了一个示例应用程序,并尝试使用 capistrano 将其部署到 bluehost。 但我没有这样做。我按照http://vasil-y.com/2012/08/21/rails-capistrano-git-bluehost/中提到的说明进行操作

这是我的 config/deploy.rb 的内容:

require 'bundler/capistrano'

set :application, "rails_scaffold"

# BlueHost SSH user
set :user, "username"

# App Domain
set :domain, "example.com"

# We don't need sudo on BlueHost
set :use_sudo, false

# git is our SCM
set :scm, :git

# master is our default git branch
set :branch, "master"

# Use local git repository
set :repository,  "#{domain}:/home/#{user}/rails_apps/#{application}"
set :local_repository, "."

# Checkout, compress and send a local copy
set deploy_via, :copy
set deploy_to, "/home/#{user}/rails_apps/#{application}"

# We have all components of the app on the same server
server domain, :app, :web, :db, :primary => true

namespace :deploy do
  task :start do ; end
  task :stop do ; end

  # Touch tmp/restart.txt to tell Phusion Passenger about new version
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{File.join(current_path, 'tmp', 'restart.txt')}"
  end
end

# Clean-up old releases
after "deploy:restart", "deploy:cleanup" 

但是当我运行 cap deploy:setup 命令时,出现以下错误:

/home/swaroop/.rvm/gems/ruby-1.9.3-p362/gems/capistrano-2.14.2/lib/capistrano/configuration/variables.rb:22:in `set': invalid variable `/u/apps/rails_scaffold' (variables must begin with an underscore, or a lower-case letter) (ArgumentError)

它表示应用程序名称必须以下划线或小写字母开头。我的应用程序名称看起来是有效的。 我在这里做错了什么?

谢谢

【问题讨论】:

    标签: ruby git ruby-on-rails-3.2 capistrano


    【解决方案1】:

    您的几个set 调用的参数不是符号:

    set deploy_via, :copy
    set deploy_to, "/home/#{user}/rails_apps/#{application}"
    

    应该是:

    set :deploy_via, :copy
    set :deploy_to, "/home/#{user}/rails_apps/#{application}"
    

    (注意deploy_viadeploy_to之前的冒号)

    如果我们检查包含:deploy_to 的行中发生的情况,您可以看到为什么它看起来与您的:application 变量相关:它首先调用deploy_to 方法(因为您缺少冒号,它看起来像一个方法调用),而deploy_toCapistrano source code 中默认为"/u/apps/#{application}"

    _cset(:deploy_to) { "/u/apps/#{application}" }
    

    真的,您的代码正在有效地尝试运行它:

    set "/u/apps/#{application}", "/home/#{user}/rails_apps/#{application}"
    

    "/u/apps/#{application}" 在 Capistrano 中不是有效的变量名。在这些行中添加冒号应该可以解决它。

    【讨论】:

    • 感谢您的回复。一定会试试这个。
    猜你喜欢
    • 2011-07-12
    • 2012-12-16
    • 1970-01-01
    • 2013-03-15
    • 1970-01-01
    • 2012-03-22
    • 2019-04-27
    • 1970-01-01
    • 2019-04-05
    相关资源
    最近更新 更多