Skip to content

Instantly share code, notes, and snippets.

@teohm
Created March 26, 2014 04:39
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save teohm/9777017 to your computer and use it in GitHub Desktop.
Save teohm/9777017 to your computer and use it in GitHub Desktop.
A working workaround to run rvmsudo in Capistrano 3.

1. Edit /etc/sudoers

https://rvm.io/integration/sudo

2. Custom execute command

# deploy.rb
  desc "Export Upstart script"
  task :export_upstart do
    on roles(:app) do
      execute [
        "cd #{release_path} &&",
        'export rvmsudo_secure_path=0 && ',
        "#{fetch(:rvm_path)}/bin/rvm #{fetch(:rvm_ruby_version)} do",
        'rvmsudo',
        'bundle exec foreman export -a glkickstart -u ubuntu -p 8787 upstart /etc/init'
      ].join(' ')
    end
  end
  after 'deploy:updated', 'deploy:export_upstart'
@emtee
Copy link

emtee commented Jun 30, 2015

You saved the day. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment