使用Capistrano部署RVM时sudo出现问题

时间:2012-03-29 18:46:58

标签: ruby-on-rails ruby rvm capistrano

我想使用Capistrano在我的服务器中部署我的应用程序 我有deploy.rb文件,其中包含以下内容:

set :user, "deploy"
set :use_sudo, true
set :deploy_to, "/webapps/#{application}"
#set :deploy_via, :remote_cache #Using this option avoids to do a full repository clone


#RVM
set :rvm_type, :system  #System Wide installation
set :rvm_ruby_string, 'ree@K2'
set :rvm_install_shell, :bash

before 'deploy:setup','rvm:install_rvm'
before 'deploy:setup', 'rvm:install_ruby'

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "touch #{File.join(current_path,'tmp','restart.txt')}"
   end
 end

当我设置root用户,安装RVM(系统范围安装)甚至Ruby Enterprise时,一切正常,但是当我运行'cap deploy:setup'设置use_sudo选项并部署时用户,得到这个:

$ cap deploy:setup
  * executing `deploy:setup'
    triggering before callbacks for `deploy:setup'
  * executing `rvm:install_rvm'
  * executing "bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)"
    servers: ["myserver.com"]
Password: 
    [myserver.com] executing command
    [myserver.com] bash -c 'bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)'
*** [err :: myserver.com] bash: line 304: /usr/local/rvm/RELEASE: Permission denied
    command finished in 564ms
failed: "bash -c 'bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)'" on myserver.com

我需要做些什么来完成这项工作?我是否必须在sudoers文件中调整一些设置?

2 个答案:

答案 0 :(得分:2)

请使用1.1.0进行测试:

gem install rvm-capistrano

答案 1 :(得分:0)

实际上不需要创建新用户。 rvm 将在您的主目录中创建一个目录:~/.rvm,并在其中安装所有内容。这意味着您将拥有所有正确的权限。无需以root身份运行,您不需要使用sudo 所以试着改变

set :use_sudo, true

到此:

set :use_sudo, false

并重新开始

  

cap deploy:setup

相关问题