2 desc "Ruby version manager"
3 homepage "https://rbenv.org"
4 url "https://github.com/rbenv/rbenv/archive/refs/tags/v1.3.2.tar.gz"
5 sha256 "e2104f6472d7a8477409c46d4de39562b4d01899148a3dbed73c1d99a0b4bb2a"
7 head "https://github.com/rbenv/rbenv.git", branch: "master"
10 sha256 cellar: :any_skip_relocation, all: "8158fb1f059c1316523b2cc9074c5c041b3944828dc3b76cb032f893e754f013"
13 depends_on "ruby-build"
15 uses_from_macos "ruby" => :test
18 # Build an `:all` bottle.
19 inreplace "libexec/rbenv", "/usr/local", HOMEBREW_PREFIX
22 # Record exact git revision for `rbenv --version` output
23 git_revision = Utils.git_short_head
24 inreplace "libexec/rbenv---version", /^(version=)"([^"]+)"/,
25 %Q(\\1"\\2-g#{git_revision}")
28 zsh_completion.install "completions/_rbenv" => "_rbenv"
29 prefix.install ["bin", "completions", "libexec", "rbenv.d"]
30 man1.install "share/man/man1/rbenv.1"
34 # Create a fake ruby version and executable.
35 rbenv_root = Pathname(shell_output("#{bin}/rbenv root").strip)
36 ruby_bin = rbenv_root/"versions/1.2.3/bin"
37 foo_script = ruby_bin/"foo"
38 foo_script.write "echo hello"
39 chmod "+x", foo_script
41 # Test versions. The second `rbenv` call is a shell function; do not add a `bin` prefix.
42 versions = shell_output("eval \"$(#{bin}/rbenv init -)\" && rbenv versions").split("\n")
43 assert_equal 2, versions.length
44 assert_match(/\* system/, versions[0])
45 assert_equal(" 1.2.3", versions[1])
48 system bin/"rbenv", "rehash"
49 refute_match "Cellar", (rbenv_root/"shims/foo").read
50 # The second `rbenv` call is a shell function; do not add a `bin` prefix.
51 assert_equal "hello", shell_output("eval \"$(#{bin}/rbenv init -)\" && rbenv shell 1.2.3 && foo").chomp