Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbenv:install task? #83

Open
murb opened this issue Nov 28, 2018 · 0 comments
Open

rbenv:install task? #83

murb opened this issue Nov 28, 2018 · 0 comments

Comments

@murb
Copy link

murb commented Nov 28, 2018

Because of the nth time installing rbenv manually I wrote the following lines, which adds cap #{env} rbenv:install to the list of available tasks. It may relate to this request (never tried the 2.x version): #51

namespace :rbenv do
  desc 'Install rbenv'
  task :install do
    on roles(:web) do
      begin
        execute "git clone https://github.com/rbenv/rbenv.git #{fetch(:rbenv_path)}"
      rescue SSHKit::Command::Failed
        puts "rbenv already installed, updating..."
        execute "cd #{fetch(:rbenv_path)} && git pull"
      end        
      # execute "~/.rbenv/bin/rbenv init"
      execute "mkdir -p #{fetch(:rbenv_path)}/plugins"
      begin
        execute "git clone https://github.com/rbenv/ruby-build.git #{fetch(:rbenv_path)}/plugins/ruby-build"
      rescue SSHKit::Command::Failed
        puts "rbenv/ruby-build plugin already installed, updating..."
        execute "cd #{fetch(:rbenv_path)}/plugins/ruby-build && git pull"
      end   
      rbenv_ruby = File.read('.ruby-version').strip
      execute "#{fetch(:rbenv_path)}/bin/rbenv install -s #{fetch(:rbenv_ruby)||rbenv_ruby}"
      execute "#{fetch(:rbenv_path)}/bin/rbenv global #{fetch(:rbenv_ruby)||rbenv_ruby}"
      execute "#{fetch(:rbenv_path)}/shims/gem install bundler --no-document"
      if fetch(:rbenv_ruby).nil?
        puts "\nPlease uncomment the line `# set :rbenv_ruby, File.read('.ruby-version').strip` to enable capistrano rbenv"
      end
    end
  end
end

I'm happy to prepare a pull request...

evazion added a commit to danbooru/danbooru that referenced this issue Aug 14, 2019
Upgrade procedure:

    $ echo 2.6.3 > .ruby-version

    # upgrade ruby-build to know about the latest ruby versions.
    # see also: github.com/rkh/rbenv-update
    $ cd ~/.rbenv/plugins/ruby-build && git pull

    # install the version of ruby specified in .ruby-version.
    # see also: github.com/capistrano/rbenv/issues/83
    $ rbenv install --skip-existing

    # update the shell to use the latest version of ruby by default.
    $ rbenv global 2.6.3

    # update rubygems and bundler
    $ gem update --system

    # update the lockfile to use the latest version of bundler
    $ bundle update --bundler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant