thoughtbot / dotfiles

A set of vim, zsh, git, and tmux configuration files.
https://thoughtbot.com
Other
7.97k stars 1.87k forks source link

rbenv for Ruby management #628

Closed geoffharcourt closed 5 years ago

geoffharcourt commented 5 years ago

asdf has been a great language manager because it supports a broad list of languages and has the same CLI interface for each language. I think the Nodejs implementation in particular has been great (with some other node version managers I saw shell slowdowns I don't see with asdf).

However, I've missed some important aspects of rbenv while using asdf-ruby, the most important of which is the ability to get install a new version of Ruby in a timely manner after release.

The issue is that asdf-ruby uses ruby-build to build rubies, but each version of asdf-ruby is locked to a version of ruby-build. While ruby-build almost always issues a prompt tag and release with the release of a new Ruby, asdf-ruby has not kept pace, and this is a policy of the plugin, not a limitation of support and resources. This has been troublesome for us when we've needed to make an urgent version updates such as Ruby 2.6.1's fix for a networking bug and Ruby 2.6.2's security patch for Rubygems.

There are some other conveniences of rbenv I miss like rbenv each, but they are less important to me than access to releases. Currently when our team wants to install a new Ruby, we're manually installing it through ruby-build into the proper asdf subfolder, and then manually triggering behavior like default gems installation, etc.

I propose we should keep asdf for Node, Elixir, etc. but go back to rbenv for Ruby management. This would require partially unwinding some of the work done in https://github.com/thoughtbot/dotfiles/pull/534, and we'd likely need similar deprecation notices as used before for the migration, but I think the benefits of being able to quickly download security update-related Ruby releases without delay or a workaround will be worth this pain. I'm happy to do the PR, but wanted to solicit feedback before undertaking this.

composerinteralia commented 5 years ago

Does https://github.com/asdf-vm/asdf-ruby/pull/115 solve the problem for you?

composerinteralia commented 5 years ago

Some folks here have been mentioning that rbenv is painfully slow and recommend switching off it.

mike-burns commented 5 years ago

At risk of sounding Very Mike Burns, this is my ruby-install program:

#!/bin/sh

if [ -z "$SHA256PROG" ]; then
  if command -v sha256sum > /dev/null; then
    SHA256PROG=$(command -v sha256sum)
    SHA256PROG_ARGS=
  elif command -v sha256 > /dev/null; then
    SHA256PROG=$(command -v sha256)
    SHA256PROG_ARGS=-q
  fi
fi

if [ ! -x "$SHA256PROG" ]; then
  echo "no sha256 program; set SHA256PROG"
  exit 1
fi

if [ -z "$1" -o -z "$2" ]; then
  echo "usage: ruby-install tarball-url sha256" >&2
  exit 1
fi

tarball_url="$1"
sha256="$2"
tarball_file=$(basename "$tarball_url")
version=$(echo "$tarball_file" | sed -e 's/^ruby-//' -e 's/\.tar\.gz$//')

curl -LO "$tarball_url" && \
  [ `"$SHA256PROG" $SHA256PROG_ARGS "$tarball_file" | awk '{print $1}'` = "$sha256" ] && \
  tar -zxf "$tarball_file" && \
  cd "ruby-$version" && \
  ./configure --prefix="$HOME/.rubies/ruby-$version" && \
  make && \
  make install && \

  echo "cleanup? [y/N] " && \
  read should_cleanup && \
  [ "$should_cleanup" = "y" ] && \
  rm -rf "ruby-$version" "$tarball_file"

I use it like so:

  1. Visit https://www.ruby-lang.org/en/downloads/releases/ to find the links I need. Pick 2.5.3 for example.
  2. ruby-install https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.3.tar.gz 9828d03852c37c20fa333a0264f2490f07338576734d910ee3fd538c9520846c

That's it.

geoffharcourt commented 5 years ago

If there's not significant appetite to go back to rbenv, I'm going to close this out.