Install vagrant with RVM

Install vagrant with RVM and Ruby 3.3.0

First, open the terminal and type this commands:

cd ~
mkdir ~/opt
cd ~/opt
git clone https://github.com/hashicorp/vagrant.git
rvm use 3.3.0
cd vagrant
direnv allow
bundle install

Next, create wrapper script in the folder that consists in $PATH, for example: ~/.local/bin

vagrant

#!/usr/bin/env bash

if
  [[ -s "/home/artem/.rvm/gems/ruby-3.3.0/environment" ]]
then
  source "/home/artem/.rvm/gems/ruby-3.3.0/environment"
  exec /home/artem/opt/vagrant/exec/vagrant "$@"
else
  echo "ERROR: Missing RVM environment file: '/home/artem/.rvm/gems/ruby-3.3.0/environment'" >&2
  exit 1
fi

Make it executable: chmod +x ~/.local/bin/vagrant

Finally, create Vagrantfile with content:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "debian/bookworm64"
  config.vm.provider "virtualbox" do |v|
    v.memory = 2048
    v.cpus = 2
  end
  # config.vm.disk :disk, size: "2GB", name: "extra_storage"
end

And run:

vagrant up
vagrant ssh
comments powered by Disqus