Skip to content

Commit 6040c0d

Browse files
committed
Use rbenv instead of RVM
I can't reliably install RVM on Ubuntu in an installer script such as this, even with the supplied RVM Ubuntu package. Use rbenv instead like the Windows and macOS installer guides also use.
1 parent 76e2def commit 6040c0d

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

rails-install-ubuntu.sh

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,35 @@ sudo snap install node --classic --channel=18
2222
echo "Installs ImageMagick for image processing"
2323
sudo apt-get install imagemagick --fix-missing -y
2424

25-
echo "Installs RVM (Ruby Version Manager) for handling Ruby installation"
26-
# Retrieve the GPG key.
27-
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
28-
curl -sSL https://get.rvm.io | bash -s stable
29-
source ~/.rvm/scripts/rvm
25+
echo "Install rbenv (Ruby version manager) for handling the Ruby installation"
26+
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
27+
28+
RBENV_INSTALL_PATH="$HOME/.rbenv"
29+
if [ -d "$RBENV_INSTALL_PATH" ]; then
30+
echo "rbenv already installed"
31+
else
32+
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
33+
34+
echo "Configuring rbenv for your Shell"
35+
if [[ "$SHELL" == *"bash" ]]; then
36+
echo 'eval "$($HOME/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc
37+
elif [[ "$SHELL" == *"zsh" ]]; then
38+
echo 'eval "$($HOME/.rbenv/bin/rbenv init - zsh)"' >> ~/.zshrc
39+
else
40+
echo "Unknown Shell. Please configure rbenv manually."
41+
echo "Please visit: https://github.com/rbenv/rbenv"
42+
fi
43+
fi
3044

31-
echo "Installs Ruby"
32-
rvm install 3.1.2
33-
rvm use 3.1.2 --default
45+
echo "Load rbenv config in install script"
46+
eval "$($HOME/.rbenv/bin/rbenv init - bash)"
3447

48+
echo "Install Ruby"
49+
RUBY_VERSION=3.1.3
50+
rbenv install "$RUBY_VERSION"
51+
rbenv global "$RUBY_VERSION"
52+
53+
echo "Install Rails"
3554
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
3655
gem install bundler rails
3756

@@ -41,9 +60,7 @@ echo -e "Now we are going to print some information to check that everything is
4160

4261
echo -n "Should be sqlite 3.22.0 or higher: sqlite "
4362
sqlite3 --version
44-
echo -n "Should be rvm 1.29.8 or higher: "
45-
rvm --version | sed '/^.*$/N;s/\n//g' | cut -c 1-11
46-
echo -n "Should be ruby 3.0 or higher: "
63+
echo -n "Should be Ruby 3.1.3 or higher: "
4764
ruby -v | cut -d " " -f 2
4865
echo -n "Should be Rails 7.0 or higher: "
4966
rails -v
@@ -55,12 +72,6 @@ and we will help you do the installation the manual way at the event.
5572
5673
Congrats!
5774
58-
Make sure that all works well by running the application generator command:
59-
$ rails new railsgirls
60-
61-
If you encounter the message:
62-
The program 'rails' is currently not installed.
63-
64-
It is just a hiccup with the shell, solutions:
65-
$ source ~/.rvm/scripts/rvm
66-
Allow login shell, example http://rvm.io/integration/gnome-terminal/"
75+
Open a new Terminal tab/window and make sure that all works well
76+
by running the application generator command:
77+
$ rails new railsgirls"

0 commit comments

Comments
 (0)