2

我已经使用 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)

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

谢谢你

4

1 回答 1

2

您的几个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_via(注意和之前的冒号deploy_to

:application如果我们检查包含以下内容的行中发生的事情,您可以看到为什么它可能看起来与您的变量相关:deploy_to:它首先调用deploy_to方法(因为您缺少冒号,它看起来像一个方法调用),并且deploy_to默认为"/u/apps/#{application}"Capistrano源代码

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

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

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

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

于 2013-05-07T09:07:04.547 回答