C
C
cool_sniper982021-01-06 09:40:49
Vagrant
cool_sniper98, 2021-01-06 09:40:49

How to specify the desired box version in Vagrantfile?

I do not understand what needs to be done to install the required version of vagrant box for laravel homestead. I added these lines 5ff55b0d0735f459423617.pngto the Vagrantfile, but version 9.7.2 is still downloaded. Tell me what to do

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2021-01-06
@cool_sniper98

cool_sniper98 - checked everything works for me
here

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

require 'yaml'
require 'pp'

basedir = ENV.fetch('USERPROFILE', '')
basedir = ENV.fetch('HOME', '') if basedir == ''
basedir = basedir.gsub('\\', '/')

dir = File.expand_path(File.dirname(__FILE__))

box_hostname = ENV.fetch('BOX_HOSTNAME', 'alpine')
box_name = ENV.fetch('BOX_NAME', 'generic/alpine38')
box_version = ENV.fetch('BOX_VERSION', '3.1.20' ) # 3.1.22
VAGRANTFILE_API_VERSION = '2'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 
  config.vm.box = box_name # box_hostname
  config.vm.hostname = box_hostname
  config.vm.box_version = box_version # v3.1.20

  config.ssh.forward_agent = true
  config.vm.boot_timeout = 600
  config.vm.synced_folder './', '/vagrant'
  
  if ! Vagrant.has_plugin?('vagrant-alpine')
    # TODO: raise an error
  end
  if Vagrant.has_plugin?('vagrant-vbguest')
    config.vbguest.auto_update = false
  end

   config.vm.provision "shell", inline: <<-SHELL
     apk update && apk upgrade
   SHELL
end

here is the check
vagrant up
writes on the console
#  default: Downloading: https://vagrantcloud.com/generic/boxes/alpine38/versions/3.1.20/providers/virtualbox.box

change
export BOX_VERSION=3.1.18
 vagrant stop ; vagrant destroy -f ; vagrant up

writes to console
#  default: Downloading: https://vagrantcloud.com/generic/boxes/alpine38/versions/3.1.18/providers/virtualbox.box

to find out what there are, order a non-existent
export BOX_VERSION=3.1.99
vagrant up

writes to console
The box you're attempting to add has no available version that
matches the constraints you requested. Please double-check your
settings. Also verify that if you specified version constraints,
that the provider you wish to use is available for these constraints.

Box: generic/alpine38
Address: https://vagrantcloud.com/generic/alpine38
Constraints: 3.1.99
Available versions: 1.6.24, 1.6.26, 1.8.0, 1.8.1, 1.8.2, 1.8.4, 1.8.7, 1.8.8, 1.8.9, 1.8.12, 1.8.13, 1.8.14, 1.8.24, 1.8.26, 1.8.27, 1.8.28, 1.8.32, 1.8.38, 1.8.40, 1.8.48, 1.8.50, 1.8.52, 1.8.54, 1.8.56, 1.8.58, 1.8.60, 1.9.2, 1.9.4, 1.9.6, 1.9.8, 1.9.10, 1.9.12, 1.9.14, 1.9.16, 1.9.18, 1.9.19, 1.9.20, 1.9.22, 1.9.24, 1.9.26, 1.9.28, 1.9.30, 1.9.32, 1.9.34, 1.9.36, 1.9.38, 1.9.40, 2.0.0, 2.0.2, 2.0.4, 2.0.6, 3.0.0, 3.0.1, 3.0.2, 3.0.4, 3.0.6, 3.0.8, 3.0.10, 3.0.12, 3.0.14, 3.0.16, 3.0.18, 3.0.20, 3.0.22, 3.0.24, 3.0.26, 3.0.28, 3.0.30, 3.0.32, 3.0.34, 3.0.36, 3.0.38, 3

to find out what is there and remove the excess
vagrant box list
generic/alpine38 (virtualbox, 3.1.18)
generic/alpine38 (virtualbox, 3.1.20)

vagrant box remove generic/alpine38 --box-version 3.1.20

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question