#!/bin/bash | |
# -------------------------------------------------------------------------------------------- | |
# Installs Ruby 3.0 using rbenv/ruby-build on the Raspberry Pi (Raspbian) | |
# | |
# Run from the web: | |
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh) | |
# -------------------------------------------------------------------------------------------- | |
# Welcome message | |
echo -e " | |
This will install Ruby 3.0 using rbenv/ruby-build. | |
It will take about 2 hours to compile on the original Raspberry Pi, | |
35 minutes on the second generation, and 16 minutes on the third.\n" | |
# Prompt to continue | |
read -p " Continue? (y/n) " ans | |
if [[ $ans != "y" ]]; then | |
echo -e "\nQuitting...\n" | |
exit | |
fi | |
echo | |
# Time the install process | |
START_TIME=$SECONDS | |
# Check out rbenv into ~/.rbenv | |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
# Add ~/.rbenv/bin to $PATH, enable shims and autocompletion | |
read -d '' String <<"EOF" | |
# rbenv | |
export PATH="$HOME/.rbenv/bin:$PATH" | |
eval "$(rbenv init -)" | |
EOF | |
# Save to ~/.bashrc | |
echo -e "\n${String}" >> ~/.bashrc | |
# Enable rbenv for current shell | |
eval "${String}" | |
# Install ruby-build as an rbenv plugin, adds `rbenv install` command | |
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build | |
# Install dependencies | |
# See: https://github.com/rbenv/ruby-build/wiki#suggested-build-environment | |
sudo apt update | |
sudo apt install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev | |
# Install Ruby 3.0, don't generate RDoc to save lots of time | |
CONFIGURE_OPTS="--disable-install-doc --enable-shared" rbenv install 3.0.0 --verbose | |
# Set Ruby 3.0 as the global default | |
rbenv global 3.0.0 | |
# Don't install docs for gems (saves lots of time) | |
echo "gem: --no-document" > ~/.gemrc | |
# Reminder to reload the shell | |
echo -e "\nReload the current shell to get access to rbenv using:" | |
echo " source ~/.bashrc" | |
# Print the time elapsed | |
ELAPSED_TIME=$(($SECONDS - $START_TIME)) | |
echo -e "\nFinished in $(($ELAPSED_TIME/60/60)) hr, $(($ELAPSED_TIME/60%60)) min, and $(($ELAPSED_TIME%60)) sec\n" |
This comment has been minimized.
This comment has been minimized.
Thanks for this. Wish I'd seen it earlier as I was having a problem installing. I think my install is taking more than two hours. But can watch the log to make sure it's still progressing. |
This comment has been minimized.
This comment has been minimized.
Pi 2, 22 min 14 sec |
This comment has been minimized.
This comment has been minimized.
I've tried this multiple times, and it gets quite far in. However, at the "Parsing sources", stage, CPU usage goes through the roof, and the RPi eventually just reboots itself, and the installation doesn't finish. Last few lines of log:
Any ideas? I've tried three times now, and it always stops at the exact same point. |
This comment has been minimized.
This comment has been minimized.
I think I am going to be getting into the habit of doing this now so ruby doesn't build docs if it doesn't need to - rbenv/rbenv-vars#18 (comment) |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Why to take all that work when you can simply do: cd /usr/src/
wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz
tar -xvzf ruby-2.2.2.tar.gz
cd ruby-2.2.2
./configure --enable-shared --disable-install-doc --disable-install-rdoc --disable-install-capi
make install Reference: https://github.com/facastagnini/raspberry-bitcoin/blob/master/bootstrap.sh |
This comment has been minimized.
This comment has been minimized.
@blacktm you should really add "--enable-shared" to the configure opts. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
thanks for this! |
This comment has been minimized.
This comment has been minimized.
This is excellent, thank you. It took about 35 minutes on my rPi 2. It didn't load rbenv for the current shell, but re-launching terminal fixed that right up. |
This comment has been minimized.
This comment has been minimized.
16 minutes on RPI 3 |
This comment has been minimized.
This comment has been minimized.
Thanks! Just got done running on my second pi, 19min 9sec on this one, 33min on the other, this was very smooth. |
This comment has been minimized.
This comment has been minimized.
Great script, thanks. One suggestion: make sure git is installed before running git commands. Other than that it worked great on my Rpi 3 |
This comment has been minimized.
This comment has been minimized.
Worked great for getting Ruby running on my Pi3 But ... I had to come here to get rails working: |
This comment has been minimized.
This comment has been minimized.
"Oh no! Something has gone wrong."My Output:pi@raspberrypi:~ $ uname -a pi@raspberrypi:~ $ sudo sh install_ruby_rpi.sh |
This comment has been minimized.
This comment has been minimized.
Note:
|
This comment has been minimized.
This comment has been minimized.
@Robertthcan: It's too late, but I ran into the same problem (after trying to install ruby and upgrading it to 2.4, and borking my system) sudo apt-get install rbenv curl I added curl just in case. The error output showed that the script could not find rbenv. I assumed it wasn't installed for some reason, so I did it. Then Re run the script. |
This comment has been minimized.
This comment has been minimized.
took 44 minutes on a RPi 3B but helped a lot!! thanks |
This comment has been minimized.
This comment has been minimized.
Great gist! Thanks! |
This comment has been minimized.
This comment has been minimized.
Thanks, very easy to install the latest version of Ruby onto my Raspberry Pi. Took 2 hr, 21 min, and 42 sec on an Model B+ with Raspbian Stretch. |
This comment has been minimized.
This comment has been minimized.
My version of ruby is still 2.1: pi@raspberrypi:~ $ ruby -v It installed successfully, without any errors. I had ruby installed earlier via |
This comment has been minimized.
This comment has been minimized.
Pi3, 35 minutes and 28 seconds. My setup reported version 2.1 immediately after the install, but reports 2.5.0 after a reboot. Thank you, sir! |
This comment has been minimized.
This comment has been minimized.
Pi3, Raspbian Lite (Stretch), 14min/11sec. No reported errors. Nice job! |
This comment has been minimized.
This comment has been minimized.
pi3b+, Raspbian, Ruby 2.4.4, 17minutes. |
This comment has been minimized.
This comment has been minimized.
This gist is unreal. Amazing work, thanks a lot @blacktm Pi3 on Jesse (I think - I'm a n00b). No errors. This just worked. Roughly 30 minutes (didn't really time it), but I wouldn't care if it took 4 hours. |
This comment has been minimized.
This comment has been minimized.
I don't care how long it takes as long as it worked. I bet he took his precious time writing this wonderful script. Thank you so much for your contribution. I wish I could write a script like you. |
This comment has been minimized.
This comment has been minimized.
I have the following warning messages :
|
This comment has been minimized.
This comment has been minimized.
Thanks a million @blacktm for creating this bash script. Ruby 2.6 downloaded for me in 22 minutes. No stress. :-) Wonderful script. Thank you again for posting. |
This comment has been minimized.
This comment has been minimized.
Hey @blacktm! First of all amazing work. This is a solid script. But I'm having an issue getting it to work on a Raspberry Pi 4 running Raspbian Buster 2020-2-13 version. Everything gets installed correctly, but when I try to invoke Rails s (or sidekiq or any gem) I get a massive error 1000+ lines long that ends with "You may have encountered a bug in the Ruby interpreter or extension libraries. |
This comment has been minimized.