Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 480
Osh Mansor Avatar asked Feb 26 '16 01:02

Osh Mansor


People also ask

Why can't I SSH into the box with Vagrant?

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.

How do I pass arguments to Vagrant shell script?

args (string or array) - Arguments to pass to the shell script when executing it as a single string. These arguments must be written as if they were typed directly on the command line, so be sure to escape characters, quote, etc. as needed. You may also pass the arguments in using an array. In this case, Vagrant will handle quoting for you.

Where is the default location for the vagrant shell?

By default this is "/tmp/vagrant-shell". On Windows, this will default to "C: \ tmp \ vagrant-shell". Perhaps the easiest way to get started is with an inline script. An inline script is a script that is given to Vagrant directly within the Vagrantfile. An example is best:

Why won't my vagrant base box download?

There is no source uri being provided for the base box to download (when it doesnt exist in the local storage, it will attempt to download 'base' from the specified location). You have neither a base box in storage, nor a src uri for it in the Vagrantfile.


1 Answers

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.

like image 160
Osh Mansor Avatar answered Nov 11 '22 15:11

Osh Mansor