Skip to content

Commit 2df9fb9

Browse files
committed
install.sh
1 parent 05c810c commit 2df9fb9

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@
1010
</head>
1111
<body>
1212
<h1>rbenv - the Ruby version manager</h1>
13+
<div class="sectionbody">
14+
<p>rbenv is a version manager tool for the Ruby programming language on Unix-like systems. It is useful for switching between multiple Ruby versions on the same machine and for ensuring that each project you are working on always runs on the correct Ruby version.</p>
15+
<p>For more information, see <a href="https://github.com/rbenv/rbenv#readme">github.com/rbenv/rbenv</a></p>
16+
</div>
17+
<h2 id="install">Installation</h2>
18+
<div class="sectionbody">
19+
<p>To install rbenv and ruby-build on a system with either <a href="https://brew.sh/">Homebrew</a> or git, paste this into your terminal:</p>
20+
<pre><code>curl -fsSL https://rbenv.org/install.sh | bash</code></pre>
21+
</div>
1322
<h2 id="manuals">Manuals</h2>
1423
<div class="sectionbody">
1524
<ul>
1625
<li><p><a href="./man/rbenv.1"><em>rbenv(1)</em></a></p></li>
1726
<li><p><a href="./man/ruby-build.1"><em>ruby-build(1)</em></a></p></li>
1827
</ul>
1928
</div>
29+
<h2 id="thanks">Thanks</h2>
30+
<div class="sectionbody">
31+
<p>Thank you <a href="https://sls.name/">Sam Stephenson</a> (the original creator of rbenv) and to hundreds of rbenv and ruby-build contributors ❤️</p>
32+
</div>
2033
</body>
2134
</html>

install.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/bin/bash
2+
set -e
3+
4+
homebrew=
5+
type -p brew >/dev/null && homebrew=1
6+
7+
if ! type -p git >/dev/null; then
8+
git() {
9+
echo "Error: git is required to proceed. Please install git and try again." >&2
10+
exit 1
11+
}
12+
fi
13+
14+
rbenv="$(command -v rbenv ~/.rbenv/bin/rbenv | head -1)"
15+
16+
if [ -n "$rbenv" ]; then
17+
echo "rbenv already seems installed in \`$rbenv'."
18+
cd "${rbenv%/*}"
19+
20+
if [ -x ./brew ]; then
21+
echo "Trying to update with Homebrew..."
22+
brew update >/dev/null
23+
if brew list rbenv | grep -q rbenv/HEAD; then
24+
brew reinstall rbenv
25+
else
26+
brew upgrade rbenv
27+
fi
28+
elif git remote -v 2>/dev/null | grep -q rbenv; then
29+
echo "Trying to update with git..."
30+
git pull --tags origin master
31+
cd ..
32+
fi
33+
else
34+
if [ -n "$homebrew" ]; then
35+
echo "Installing rbenv with Homebrew..."
36+
brew update
37+
brew install rbenv
38+
rbenv="$(brew --prefix)/bin/rbenv"
39+
else
40+
echo "Installing rbenv with git..."
41+
mkdir -p ~/.rbenv
42+
cd ~/.rbenv
43+
git init
44+
git remote add -f -t master origin https://github.com/rbenv/rbenv.git
45+
git checkout -b master origin/master
46+
rbenv=~/.rbenv/bin/rbenv
47+
fi
48+
fi
49+
50+
rbenv_root="$("$rbenv" root)"
51+
ruby_build="$(command -v "$rbenv_root"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
52+
53+
echo
54+
if [ -n "$ruby_build" ]; then
55+
echo "\`rbenv install' command already available in \`$ruby_build'."
56+
cd "${ruby_build%/*}"
57+
58+
if [ -x ./brew ]; then
59+
echo "Trying to update with Homebrew..."
60+
brew update >/dev/null
61+
brew upgrade ruby-build
62+
elif git remote -v 2>/dev/null | grep -q ruby-build; then
63+
echo "Trying to update with git..."
64+
git pull origin master
65+
fi
66+
else
67+
if [ -n "$homebrew" ]; then
68+
echo "Installing ruby-build with Homebrew..."
69+
brew update
70+
brew install ruby-build
71+
else
72+
echo "Installing ruby-build with git..."
73+
mkdir -p "${rbenv_root}/plugins"
74+
git clone https://github.com/rbenv/ruby-build.git "${rbenv_root}/plugins/ruby-build"
75+
fi
76+
fi
77+
78+
# Enable caching of rbenv-install downloads
79+
mkdir -p "${rbenv_root}/cache"
80+
81+
# Detect the type of shell that invoked the installer:
82+
shell="$(ps -p "$PPID" -o 'args=' 2>/dev/null || true)"
83+
shell="${shell%% *}"
84+
shell="${shell##-}"
85+
shell="${shell:-$SHELL}"
86+
shell="${shell##*/}"
87+
88+
case "$shell" in
89+
bash | zsh| ksh | ksh93 | mksh | fish )
90+
# allow known shells to be configured
91+
;;
92+
* )
93+
# default to bash in case the parent process is not a known shell
94+
shell=bash
95+
;;
96+
esac
97+
98+
echo
99+
echo "Setting up your shell with \`rbenv init $shell' ..."
100+
"$rbenv" init "$shell"
101+
102+
echo
103+
echo "All done! After reloading your terminal window, rbenv should be good to go."

0 commit comments

Comments
 (0)