I tried:
if ! command -v ruby &> /dev/null
then
# - proverbot's version
# First, install Ruby, as that is for some reason required to build
# the "system" project
# git clone https://github.com/rbenv/ruby-build.git ~/ruby-build
# mkdir -p ~/.local
# PREFIX=~/.local ./ruby-build/install.sh
# ~/.local/ruby-build 3.1.2 ~/.local/
# - u-pycoq's version
# sudo apt-get install ruby-full
sudo apt-get install rbenv
rbenv init
eval "$(rbenv init - bash)"
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
sudo apt-get install ruby-build
# ruby-build 3.1.2
rbenv install 3.1.2
rbenv global 3.1.2
ruby -v
else
echo "Error: failed to install ruby"
fi
But I get my Ruby build is not up-to-date perhaps, but when I install it, it is up-to-date. Therefore, why is the proverbot's attempt 3.1.2 if it doesn't exist?
It was inspired from: https://superuser.com/questions/340490/how-to-install-and-use-different-versions-of-ruby
It seems it works with 2.7.1, but not with 3.1.2.
sudo apt-get install rbenv
rbenv init
eval "$(rbenv init - bash)"
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
sudo apt-get install ruby-build
# mkdir -p ~/.local
# PREFIX=~/.local
# sh ~/ruby-build/install.sh
mkdir -p ~/.local
ruby-build 2.7.1 ~/.local
rbenv global 2.7.1
# ruby-build 2.3.1p112 ~/.local/
# ruby-build 3.1.2 ~/.local/
# rbenv global 3.1.2
ruby -v
bot#513314bdda2a:~/ruby-build$ ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [aarch64-linux-gnu]
Main command that fails
I think this is the main command that fails after rbenv and ruby-build are installed:
rbenv install 3.1.2
with
ruby-build: definition not found: 3.1.2
See all available versions with `rbenv install --list.
If the version you need is missing, try upgrading ruby-build.
Might my version of Ubuntu be the issue?
I tried it in a different server outside my Docker container and Ruby works. In the Docker container it says it's:
bot#513314bdda2a:~/ruby-build$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
Is that an issue?
I tried updating ruby-build
I ran sudo apt-get update then sudo apt-get upgrade ruby-build then mkdir -p ~/.local then ruby-build 3.1.2 ~/.local/ and the error is ruby-build: definition not found: 3.1.2
I tried a bunch of Ubuntu's, but it failed
#!/usr/bin/env bash
# - Get the Ubuntu version for the Ubuntu image
#docker run -it --rm ubuntu:20.04 /bin/bash
docker run -it --rm ubuntu:18.04 /bin/bash
apt-get update && apt-get install -y lsb-release && apt-get clean all
lsb_release -a
#apt-get install git
apt-get update
apt-get upgrade ruby-build
apt-get install rbenv
apt-get install ruby-build
rbenv install 3.1.2
# - Get Ubuntu version for the 'miniconda3' Docker image
docker run -it --rm continuumio/miniconda3:latest /bin/bash
#sudo apt-get install lsb-release
#apt-get install lsb-release
apt-get update && apt-get install -y lsb-release && apt-get clean all
lsb_release -a
Output of ruby-build https://gist.github.com/brando90/8a40e83df107f5a915ba105d9fb0121c
$ ruby-build --definitions
1.8.5-p52
1.8.5-p113
...
The gist is that all 3.x.x are missing.
I tried updating ruby-build manually, but it failed
I did do:
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
then
git -C "$(rbenv root)"/plugins/ruby-build pull
Then I installed 3.1.2 with rbenv. It seemed to succeed, but then ruby --version doesn't seem right(?).
bot#e3a50e4f740f:~$ rbenv install 3.1.2
To follow progress, use 'tail -f /tmp/ruby-build.20221207002433.1304.log' or pass --verbose
Downloading ruby-3.1.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.gz
Installing ruby-3.1.2...
Installed ruby-3.1.2 to /home/bot/.rbenv/versions/3.1.2
bot#e3a50e4f740f:~$ ruby --version
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [aarch64-linux-gnu]
bot#e3a50e4f740f:~$ rbenv global 3.1.2
bot#e3a50e4f740f:~$ ruby --version
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [aarch64-linux-gnu]
Option: Official rbenv instructions
Alas, that didn't work :frowning:
$ rbenv install 3.1.2
rbenv: no such command `install'
I did:
mkdir ~/.rbenv
cd ~/.rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc
bash
# exec $SHELL
rbenv install 3.1.2
Using the official instructions: Seamlessly manage your app’s Ruby environment with rbenv, Basic Git Checkout
Is it probably best to use a Ruby Docker container? But how do I get one with the specific version I want 3.1.2 (or any specific version)?
All options I tried to install ruby on a Docker container with specific version 3.1.2, likely better to just use a Ruby image instead, any recommendations for 3.1.2?
An idea for a bounty: force insert the FROM ruby:3.1.2 image into running container
I still can't install Ruby on a already-running container :(, is it possible to layer on top of the running image the ruby 3.1.2 image into the running container?
References:
Crossposted: Why can't I install Ruby 3.1.2 in a Linux Docker container?
All attempts are documented at ruby_install_ubuntu.sh - the Discord channel for Ruby was really helpful, even though we didn't solve it: https://discord.com/channels/518658712081268738/650031651845308419
This doesn't work on an Ubuntu Docker container which is the title of the question, but it at least worked on the HPC with Ubuntu I was using, so it can still be useful for future readers, a real answer on an Ubuntu Docker container is still needed and wanted.
# - install rbenv for installing the Ruby interpreter
mkdir ~/.rbenv
cd ~/.rbenv
git clone https://github.com/rbenv/rbenv.git .
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc.user
echo 'eval "$(rbenv init -)"' >> ~/.bashrc.user
exec $SHELL
bash
source ~/.bashrc.user
rbenv -v
# - install ruby-build
mkdir ~/.ruby-build
cd ~/.ruby-build
git clone https://github.com/rbenv/ruby-build.git .
export PATH="$HOME/.ruby-build/bin:$PATH"
echo 'export PATH="$HOME/.ruby-build/bin:$PATH"' >> ~/.bashrc.user
exec $SHELL
bash
source ~/.bashrc.user
ruby-build --version
# - install ruby without sudo -- now that ruby build was install
mkdir -p ~/.local
# ruby-build 3.1.2 ~/.local/
rbenv install 3.1.2
rbenv global 3.1.2
ruby -v
which ruby
Given the giant effort I've put so far, I think the best is just to rebuild the Docker image from scratch, starting from all the Docker images you need. For me I need to start from these:
FROM continuumio/miniconda3
# FROM --platform=linux/amd64 continuumio/miniconda3
#FROM ubuntu:20.04
#FROM ubuntu:18.04
FROM ruby:3.1.2
But rebuilding the image, I tested to see if the right Ruby image was available once I started the Ruby 3.1.2 container (if you want a different one, I assume going to the Docker website for Ruby works or try different version tags or do latest). Output:
(meta_learning) brandomiranda~ ❯ docker run -it --rm ruby:3.1.2 bash
Unable to find image 'ruby:3.1.2' locally
3.1.2: Pulling from library/ruby
077c13527d40: Pull complete
a3e29af4daf3: Pull complete
3d7b1480fa4d: Pull complete
426e8acfed2a: Pull complete
7301bf329e1e: Pull complete
1e6ce022773b: Pull complete
08fd3b7f7d99: Pull complete
2a797222ff77: Pull complete
Digest: sha256:7681a3d37560dbe8ff7d0a38f3ce35971595426f0fe2f5709352d7f7a5679255
Status: Downloaded newer image for ruby:3.1.2
root#70d03f6408cd:/# ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [aarch64-linux]
You can use rvm instead of rbenv.
website: https://rvm.io. it works on docker.
here are the commands for ubuntu docker image
curl -sSL https://get.rvm.io | bash -s stable
rvm install 3.1.2
ruby -v // 3.1.2
Related
I am beginner of learning rails. I want to install rails5 in my Linux operating system.
How can I install rails in Ubuntu 16.04 LTS system ?
The first step is to install some dependencies for Ruby.
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs
Install rbenv and ruby:
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.4.0
rbenv global 2.4.0
ruby -v
The last step is to install Bundler
gem install bundler
Install nodejs:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Install rails now:
gem install rails -v 5.0.1
you'll need to run the following command to make the rails executable available:
rbenv rehash
Now that you've installed Rails, you can run the rails -v command to make sure you have everything installed correctly:
rails -v
# Rails 5.0.1
You should use RVM to install Rails. It's a virtualization system that will allow you to install multiple versions of Ruby, and maintain different sets of libraries (including Rails) for each project you work on. By default, it installs Rails and its libraries (gems) in your user directory. This is both safer (more secure) than system-wide installation, and much more flexible.
You could install Rails via Ubuntu's package manager (sudo apt-get install rails), and install its libraries via the system-wide RubyGems installer (gem), but that's not a best-practice. While Ruby and Rails don't change as often as they did a few years ago, the dev ecosystem still evolves faster than Linux distributions like Ubuntu can keep up with.
These days, everyone developing Rails apps uses either RVM or rbenv to manage user-space installations. There's no compelling reason to prefer RVM or rbenv as you start out, but RVM is more popular.
I am trying to install ruby on docker. I could install the 1.9 versions but it is not possible to install the latest version such as 2.2.0 and above. I am actually trying to set up calabash on docker. Have tried this. Whenever I try to install calabash-android in it getting the error
ERROR: Error installing calabash-android:
luffa requires Ruby version >= 2.0.
If you're starting FROM a different base Docker instance, you can simply RUN commands that install Ruby from your base instance's package management system. For example, this GitHub Gist shows how to use apt-get to install Ruby on a Ubuntu instance:
# Pull base image.
FROM dockerfile/ubuntu
# Install Ruby.
RUN \
apt-get update && \
apt-get install -y ruby
And this Gist shows a Dockerfile that's configured to install RVM and Ruby on a Ubuntu instance:
FROM ubuntu
RUN apt-get update
# basics
RUN apt-get install -y openssl
# install RVM, Ruby, and Bundler
RUN \curl -L https://get.rvm.io | bash -s stable
RUN /bin/bash -l -c "rvm requirements"
RUN /bin/bash -l -c "rvm install 2.0"
RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
This makes ruby available for any future RUN command and not just bash:
FROM debian:stretch-slim
RUN \
apt-get update && apt-get install -y --no-install-recommends --no-install-suggests curl bzip2 build-essential libssl-dev libreadline-dev zlib1g-dev && \
rm -rf /var/lib/apt/lists/* && \
curl -L https://github.com/sstephenson/ruby-build/archive/v20180329.tar.gz | tar -zxvf - -C /tmp/ && \
cd /tmp/ruby-build-* && ./install.sh && cd / && \
ruby-build -v 2.5.1 /usr/local && rm -rfv /tmp/ruby-build-* && \
gem install bundler --no-rdoc --no-ri
You could start view a dockerfile starting with:
# 2016
FROM ruby:2.3.0
# 2020
# Import your ruby version
FROM ruby:2.7.1
# Install bundler gem
RUN gem install bundler
# Assign a work directory
WORKDIR /work
That would use the docker image ruby, with ruby already installed.
The 2020 version comes from "Ruby version management with docker" from Arjun Das, mentioned by ArMD in the comments.
Low reputation so I can't comment inline (all those years of lurking, sigh), but in case anyone else happens across this while searching for ways to install old ruby versions to docker, I found #grosser's answer very helpful - it worked where trying to install via RVM simply wouldn't, at least for me.
I would, however, recommend using the recommended approach for installing ruby-build - the following worked for me:
<prior steps>
RUN git clone https://github.com/rbenv/ruby-build.git && \
PREFIX=/usr/local ./ruby-build/install.sh && \
ruby-build -v 2.4.1 /usr/local && \
gem install bundler -v <VERSION HERE> --no-ri --no-rdoc && bundle install
<following steps>
Key point here is that this keeps you up to date with ruby-build instead of being hard-coded to the 2018-03-29 version as in a previous #grosser's comment.
If you want to use things like bundle install and don't use a base image with pre-installed devtools like Ubuntu, you need to install these packages:
RUN apt-get update && apt-get install -y ruby ruby-dev ruby-bundler build-essential
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Thanks to #Jacob and #grosser, I've managed to set up mine in a similar, if a bit more unpacked way:
# Install Local ruby
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv \
&& echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc \
&& echo 'eval "$(rbenv init -)"' >> ~/.bashrc
ENV HOME /home/jenkins # Change this dir as needed.
ENV PATH "$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
ENV RUBY_VERSION 2.6.3
RUN mkdir -p "$(rbenv root)"/plugins \
&& git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
RUN rbenv install $RUBY_VERSION
RUN rbenv global $RUBY_VERSION && rbenv versions && ruby -v
# RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash # Uncomment this to get rbenv to validate your setup.
I use ImageMagick on the Google Cloud Platform. I use rails and Google's App Engine Flexible Environment. So the problem is I want to upload an Image to process in more sizes. I use paperclip.
The error is:
Could not run the identify command. Please install ImageMagick.
So my question is how I can solve this issue? Uploading a Image without processing works 100%. But the issue is the processing I think. So paperclip needs ImageMagick to process the images.
The problem is I use App Engine Flexible Environment so I am not sure how to install it. I already tried it with apt-get install imageMagick
Okay really simple you need just a Dockerfile.
# This Dockerfile for a Ruby application was generated by gcloud.
# The base Dockerfile installs:
# * A number of packages needed by the Ruby runtime and by gems
# commonly used in Ruby web apps (such as libsqlite3)
# * A recent version of NodeJS
# * A recent version of the standard Ruby runtime to use by default
# * The bundler and foreman gems
FROM gcr.io/google_appengine/ruby
# Install ruby 2.3.0 if not already preinstalled by the base image
RUN cd /rbenv/plugins/ruby-build && \
git pull && \
rbenv install -s 2.3.0 && \
rbenv global 2.3.0 && \
gem install -q --no-rdoc --no-ri bundler --version 1.11.2 && \
gem install -q --no-rdoc --no-ri foreman --version 0.78.0
ENV RBENV_VERSION 2.3.0
# To install additional packages needed by your gems, uncomment
# the "RUN apt-get update" and "RUN apt-get install" lines below
# and specify your packages.
# RUN apt-get update
# RUN apt-get install imagemagick -y
RUN apt-get update && apt-get install imagemagick -y
# Install required gems.
COPY Gemfile Gemfile.lock /app/
RUN bundle install && rbenv rehash
# Start application on port 8080.
COPY . /app/
ENTRYPOINT bundle exec rackup -p 8080 -E production config.ru
After that just run gcloud preview app deploy and it will work for you.
Don't forget to change in your app.yaml runtime: ruby to runtime: custom
That's it happy coding 🎉
I am using Vagrant + VirtualBox to set up a virtual machine for my Rails app. I am working on cleaning up a .sh provisioning script that is referenced in Vagrantfile like so:
config.vm.provision "shell", path: "script/provision-script.sh"
The provision script does a number of things, but towards the end it is supposed to install rbenv Ruby versioning and then use rbenv to install Ruby 2.2.1. That part of the provision script looks like this:
echo "setting up rbenv"
# execute the remaining commands as vagrant user, instead of root
sudo -H -u vagrant bash -c "git clone https://github.com/sstephenson/rbenv.git ~vagrant/.rbenv"
sudo -H -u vagrant bash -c "git clone https://github.com/sstephenson/ruby-build.git ~vagrant/.rbenv/plugins/ruby-build"
sudo -H -u vagrant bash -c "git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~vagrant/.rbenv/plugins/rbenv-gem-rehash"
echo "setting up rbenv environment in bash"
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~vagrant/.bashrc
echo 'eval "$(rbenv init -)"' >> ~vagrant/.bashrc
# start new vagrant shell so rbenv will work
echo "building ruby"
su vagrant
rbenv install 2.2.1 && rbenv global 2.2.1 && rbenv rehash && cd /path/to/my/app && gem install bundler rake && rbenv rehash && bundle && rbenv rehash
Everything up to the rbenv install... part works correctly. Installing ruby fails with the following error:
==> default: setting up rbenv
==> default: Cloning into '/home/vagrant/.rbenv'...
==> default: Cloning into '/home/vagrant/.rbenv/plugins/ruby-build'...
==> default: Cloning into '/home/vagrant/.rbenv/plugins/rbenv-gem-rehash'...
==> default: setting up rbenv environment in bash
==> default: building ruby
==> default: /tmp/vagrant-shell: line 73: rbenv: command not found
The script then finishes. I can open the vm with vagrant ssh and then successfully run rbenv install 2.2.1, so I'm guessing that during provisioning a new vagrant shell is not actually being started. I was under the impression that this should happen with su vagrant right before rbenv install 2.2.1.
What can I do to make sure that a new shell is initialized during this provisioning and that the rbenv command will work?
I had a similar problem because I was trying to install rbenv and the vagrant provisioning was giving me the error:
==> default: /tmp/vagrant-shell: line 10: rbenv: command not found
First of all, it is very important to understand that vagrant provisioning script is running in sudo mode.
So, when in the script we refer to ~/ path, we are referring to /root/ path and not to /home/vagrant/ path.
The problem is that I was installing rbenv for the root user and after trying to call rbenv command from a vagrant user and, of course, it didn't work!
So, what I did is specify the vagrant to run the provisioner NOT in sudo user, adding privileged: false:
config.vm.provision :shell, privileged: false, inline: $script
Then in my script I considered everything as being called from the vagrant user.
Here #Casper answer helped me a lot, because it works only specifying:
sudo -H -u vagrant bash -i -c '......'
Since you just updated .bashrc with a new path and other settings, you
will want to run "sudo bash" with the -i option. This will force bash
to simulate an interactive login shell, and therefore read .bashrc and
load the correct path for rbenv.
Below is my final Vagrantfile.
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
sudo apt-get -y update
sudo apt-get -y install curl git-core python-software-properties ruby-dev libpq-dev build-essential nginx libsqlite3-0 libsqlite3-dev libxml2 libxml2-dev libxslt1-dev nodejs postgresql postgresql-contrib imagemagick
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
sudo -H -u vagrant bash -i -c 'rbenv install 2.1.3'
sudo -H -u vagrant bash -i -c 'rbenv rehash'
sudo -H -u vagrant bash -i -c 'rbenv global 2.1.3'
sudo -H -u vagrant bash -i -c 'gem install bundler --no-ri --no-rdoc'
sudo -H -u vagrant bash -i -c 'rbenv rehash'
sudo -u postgres createdb --locale en_US.utf8 --encoding UTF8 --template template0 development
echo "ALTER USER postgres WITH PASSWORD \'develop\';" | sudo -u postgres psql
SCRIPT
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.network "forwarded_port", guest: 3000, host: 3000
# config.vm.provider :virtualbox do |vb|
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
config.vm.provision :shell, privileged: false, inline: $script
end
Hope it will be helpful to someone else.
I'm surprised the provisioning script exits, as running su vagrant should in theory hang the script at that point (you're running the command su which does not normally exit by itself).
The problem is you cannot change the user that is running a shell script "on the fly" by running su.
Your only option is to use sudo.
Since you just updated .bashrc with a new path and other settings, you will want to run "sudo bash" with the -i option. This will force bash to simulate an interactive login shell, and therefore read .bashrc and load the correct path for rbenv.
So, something like this should hopefully work:
echo "building ruby"
sudo -H -u vagrant bash -i -c 'rbenv install 2.2.1 ...'
There another Solution to install rbenv within Vagrant Provisioning process different than both #Casper and #Diego D solutions.
Using Next Commands before using rbenv commands
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
eval "$(rbenv init -)"
Then run rbenv install commands without sudo -H -u vagrant bash -i -c
Bootstrap.sh File
#!/usr/bin/env bash
sudo apt-get update
echo "========================= install dependencies for install rbenv ==========================="
sudo apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
echo "========================= install rbenv =========================================="
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
echo "========================= install ruby build plugin for rbenv ======================="
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
echo "========================= install ruby v2.5.0 =========================================="
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
eval "$(rbenv init -)"
rbenv install 2.5.0
rbenv global 2.5.0
ruby -v
gem -v
echo "========================= install bundler dependencies manager for ruby ====================="
gem install bundler
rbenv rehash
Then VagrantFile file will include vagrant provisioning line
deploy_config.vm.provision :shell, privileged: false, path: "bootstrap.sh"
Source for my Answer from Gits by #creisor
I am trying to setup rbenv with a Dockerfile, but this just fails on rbenv install. I do have ruby-build in there, it just doesn't seem to work.
Relevant bits of the Dockerfile (largely lifted from https://gist.github.com/deepak/5925003):
# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
RUN echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
RUN echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
RUN chmod +x /etc/profile.d/rbenv.sh
# install ruby-build
RUN mkdir /usr/local/rbenv/plugins
RUN git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
ENV PATH /usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Set to Ruby 2.0.0-p247
RUN rbenv install 2.0.0-p247
RUN rbenv rehash
RUN rbenv local 2.0.0-p247
Error:
Step 21 : RUN rbenv install 2.0.0-p247
---> Running in 8869fa8f0651
rbenv: no such command `install'
Error build: The command [/bin/sh -c rbenv install 2.0.0-p247] returned a non-zero code: 1
The command [/bin/sh -c rbenv install 2.0.0-p247] returned a non-zero code: 1
You're missing a setup step for ruby-build: You need to run its install.sh after you cloned it.
If you only need one Ruby version, just use the official Ruby images: https://hub.docker.com/_/ruby