Capistrano生产部署 - > rbenv

时间:2015-06-22 21:10:43

标签: ruby-on-rails ruby ubuntu capistrano capistrano3

我想我已经在我的机器上正确设置了Capistrano3,它应该连接到我的服务器。当我运行cap production deploy(在我的机器上)时,我收到以下错误信息:

DEBUG [2959f403] Running /usr/bin/env [ -d ~/.rbenv/versions/2.1.2 ] as [user@myIP]
DEBUG [2959f403] Command: [ -d ~/.rbenv/versions/2.1.2 ]
DEBUG [2959f403] Finished in 0.420 seconds with exit status 1 (failed).
ERROR rbenv: 2.1.2 is not installed or not found in ~/.rbenv/versions/2.1.2
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [user@myIP]: exit

SystemExit: exit

Tasks: TOP => rbenv:validate
(See full trace by running task with --trace)

在我的机器上(iMac):

$ ruby -v
ruby 2.1.2p95
$ rbenv -v
rbenv 0.4.0
$ which rebind
/usr/local/bin/rbenv

在我的服务器上(ubuntu)

$ ruby -v
ruby 2.1.2p95
$ rbenv -v
rbenv 0.4.0-151-g83ac0fb
$ which rebind
/home/[user]/.rbenv/bin/rbenv

任何想法如何解决这个问题?

**来自评论的更多信息**

deploy.rb

# config valid only for current version of Capistrano
lock '3.4.0'

set :application, [app name]
set :repo_url, [repo location]
set :repository, [repo location]

set :scm, :git
set :deploy_user, [user]
set :user, [user]

set :use_sudo, false
set :rails_env, "production"
set :deploy_via, :copy

# setup rvm.

# how many old releases do we want to keep
set :keep_releases, 5

# files we want symlinking to specific entries in shared.
set :linked_files, %w{config/database.yml config/application.yml}

# dirs we want symlinking to shared
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# what specs should be run before deployment is allowed to
# continue, see lib/capistrano/tasks/run_tests.cap
set :tests, []

# which config files should be copied by deploy:setup_config
# see documentation in lib/capistrano/tasks/setup_config.cap
# for details of operations
set(:config_files, %w(
  nginx.conf
  database.example.yml
  log_rotation
  monit
  unicorn.rb
  unicorn_init.sh
))

# which config files should be made executable after copying
# by deploy:setup_config
set(:executable_config_files, %w(
  unicorn_init.sh
))

# files which need to be symlinked to other parts of the
# filesystem. For example nginx virtualhosts, log rotation
# init scripts etc.
set(:symlinks, [
  {
    source: "nginx.conf",
    link: "/etc/nginx/sites-enabled/#{fetch(:full_app_name)}"
  },
  {
    source: "unicorn_init.sh",
    link: "/etc/init.d/unicorn_#{fetch(:full_app_name)}"
  },
  {
    source: "log_rotation",
   link: "/etc/logrotate.d/#{fetch(:full_app_name)}"
  },
  {
    source: "monit",
    link: "/etc/monit/conf.d/#{fetch(:full_app_name)}.conf"
  }
])

namespace :deploy do
  # make sure we're deploying what we think we're deploying
  before :deploy, "deploy:check_revision"
  # only allow a deploy with passing tests to deployed
  before :deploy, "deploy:run_tests"
  # compile assets locally then rsync

  after :finishing, 'deploy:cleanup'

  after 'deploy:publishing', 'deploy:restart'
end

服务器

$ ls /home/[user]/.rbenv/versions/
[blank... ]
$

1 个答案:

答案 0 :(得分:0)

如果/home/[user]/.rbenv/versions是服务器上的空目录,那么您没有安装任何版本的ruby。

尝试在服务器上运行rbenv install 2.1.2。您可能需要先安装ruby-build插件。