Osh Mansor
Osh Mansor

Reputation: 1232

Invalid configured shell error when running the official FreeBSD vagrant box

I tried to run the official FreeBSD vagrant box by using:

vagrant init freebsd/FreeBSD-10.2-STABLE

And afterwards, modified my Vagrantfile accordingly based on the instructions at https://forums.freebsd.org/threads/52717/ by adding the following lines:

Vagrant.configure("2") do |config|
  config.vm.guest = :freebsd
  config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
  config.vm.box = "freebsd/FreeBSD-10.2-STABLE"
  config.ssh.shell = "sh"
  config.vm.base_mac = "080027D14C66"

  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "1024"]
    vb.customize ["modifyvm", :id, "--cpus", "1"]
    vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
    vb.customize ["modifyvm", :id, "--audio", "none"]
    vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
    vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
  end
end

When I issue the vagrant up command:

vagrant up --provider virtualbox

the following error was shown:

The configured shell (config.ssh.shell) is invalid and unable to properly execute commands. The most common cause for this is using a shell that is unavailable on the system. Please verify you're using the full path to the shell and that the shell is executable by the SSH user.

Regardless of the error, I'm still able to vagrant ssh into the box. However, I'm not able to gracefully shutdown the machine using vagrant halt. It would show the same error as above and does not shutdown at all.

Upvotes: 11

Views: 4938

Answers (1)

Osh Mansor
Osh Mansor

Reputation: 1232

The fix was simple as it was a totally noob mistake on my part. In the Vagrantfile, you should remove all the parts generated when running vagrant init command except for the two lines at the very top. Then paste the suggested ones below those two lines. The complete Vagrantfile should be like the following:

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

Vagrant.configure("2") do |config|
    config.vm.guest = :freebsd
    config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
    config.vm.box = "freebsd/FreeBSD-10.2-STABLE"
    config.ssh.shell = "sh"
    config.vm.base_mac = "080027D14C66"

    config.vm.provider :virtualbox do |vb|
      vb.customize ["modifyvm", :id, "--memory", "1024"]
      vb.customize ["modifyvm", :id, "--cpus", "1"]
      vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
      vb.customize ["modifyvm", :id, "--audio", "none"]
      vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
      vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
    end

    config.vm.network "private_network", ip: "192.168.33.10"
end

What I did wrong was nesting this Vagrant.configure("2") do |config| block inside the auto-generated one.

Upvotes: 5

Related Questions