After installing Ubuntu, I had to run the following two commands repeatedly. I haven't noted the exact error messages I got.
$ sudo apt update
$ sudo apt install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
Install rbenv
$ cd
$ git clone https://github.com/rbenv/rbenv.git .rbenv