Vagrant Error: symlink has no referent - vagrant

I'm struggling with old bug/error, I'm listed a lot of possible solutions, but with no result for me.
I have a Virtual Box and Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "debian/jessie64"
config.vm.network "private_network", ip: "192.168.56.101"
config.vm.synced_folder "../mysite.local", "/code/mysite.local", type: "virtualbox"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
end
It was ok until I created the symlinked folder. So when I type vagrant up it throws an error:
==> default: Checking if box 'debian/jessie64' is up to date...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
[default] GuestAdditions 5.1.31 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /Users/user/code/sandbox/mysite.local/ => /vagrant
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /Users/user/code/sandbox/mysite.local/
Guest path: /vagrant
Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--no-owner" "--no-group" "--rsync-path" "sudo rsync" "-e" "ssh -p 2222 -o LogLevel=FATAL -o ControlMaster=auto -o ControlPath=/var/folders/kh/sp8l6c0d1s3_jqkv6cv2jzlw0000gn/T/ssh.832 -o ControlPersist=10m -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i '/Users/user/code/sandbox/mysite.local/.vagrant/machines/default/virtualbox/private_key'" "--exclude" ".vagrant/" "/Users/user/code/sandbox/mysite.local/" "vagrant#127.0.0.1:/vagrant"
Error: symlink has no referent:
"/Users/user/code/sandbox/mysite.local/web"
rsync error: some files could not be transferred (code 23) at
/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-
52/rsync/main.c(996) [sender=2.6.9]
What I need to do to fix that issue?

So, deleting broken link is not the best solution for that question. By default - "home" synchronized directory is /vagrant. And I've made another synced folder. It was the conflict between them.
config.vm.synced_folder ".", "/vagrant", disabled: true
After adding these lines to my Vagrantfile the error is gone.

You have a broken symlink /Users/user/code/sandbox/mysite.local/web, hence rsync cannnot copy it to your VM. Either fix your symlink or move it away before you run vagrant up:
cd /Users/user/code/sandbox/mysite.local
mv web ../

Related

Vagrant 'pre-boot' VM customization error

What is the cause of this particular error?
I have the latest version of VirtualBox (5.2.22-126460) and Vagrant (2.2.2).
Those are running on a freshly installed Windows 10 operating system.
Whenever I try to 'vagrant up' my machine I get this following output:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Vagrant has detected a configuration issue which exposes a
==> default: vulnerability with the installed version of VirtualBox. The
==> default: current guest is configured to use an E1000 NIC type for a
==> default: network adapter which is vulnerable in this version of VirtualBox.
==> default: Ensure the guest is trusted to use this configuration or update
==> default: the NIC type using one of the methods below:
==> default:
==> default: https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
==> default: https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 1080 (guest) => 1080 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
A customization command failed:
["modifyvm", :id, "--cableconnected0", "on"]
The following error was experienced:
#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "22fda01f-9b13-43f9-bf0d-4deb81c688c8", "--cableconnected0", "on"]
Stderr: VBoxManage.exe: error: Invalid NIC number 0
>
Please fix this customization and try again.
Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "local.1400degrees.com"
config.vm.hostname = "local.website.com"
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777,fmode=777"]
config.vm.network "forwarded_port", guest: 1080, host: 1080
config.vm.network "private_network", ip: "192.168.33.13"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
config.ssh.insert_key = false
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
end
Per this github issue a solution can be to
1.first of all destroy the virtual box with vagrant destroy
2.navigate to C:\Users\YOUR_USERNAME
3.delete the .vagrant.d folder
4.go into VirtualBox VMs folder and delete everything inside it.
5.start it again with vagrant up
You can get more in depth logs by using vagrant up --debug or if you would like to save it to a file vagrant up --debug &> vagrant.log. Also, a great thing about this is you can always tear it down and start over :)
I believe the real reason this is happening is due to this: https://github.com/hashicorp/vagrant/issues/10481
The fix was already merged to the vagrant master branch, however it will probably be included in version 2.2.5 or later. Latest vagrant version as of writing this up is 2.2.4 and the bug is still present.
The fix that was done:
In plugins/providers/virtualbox/action/set_default_nic_type.rb
They changed the code from E1000_SUSCEPTIBLE = Gem::Requirement.new("<= 5.2.22").freeze to E1000_SUSCEPTIBLE = Gem::Requirement.new("< 5.2.22").freeze

Vagrant sync folder doesn't work on windows 10

I'm trying to sync folders from a windows 10 hosto to a ubuntu guest but I get this error:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 8080 (guest) => 8080 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.3.36
default: VirtualBox Version: 5.0
==> default: Mounting shared folders...
default: /vagrant => C:/sync_workspace
default: /sync_workspace => C:/sync_workspace
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`,nolock,vers=3 core /sync_workspace
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant`,nolock,vers=3 core /sync_workspace
The error output from the last command was:
stdin: is not a tty
unknown mount option `nolock'
valid options:
rw mount read write (default)
ro mount read only
uid =<arg> default file owner user id
gid =<arg> default file owner group id
ttl =<arg> time to live for dentry
iocharset =<arg> i/o charset (default utf8)
convertcp =<arg> convert share name from given charset to utf8
dmode =<arg> mode of all directories
fmode =<arg> mode of all regular files
umask =<arg> umask of directories and regular files
dmask =<arg> umask of directories
fmask =<arg> umask of regular files
Here is my Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.synced_folder "C:/Users/rafa/Documents/personal docs", "/vagrant_data/sync_workspace"
end
Host : Windows 10
Guest: Ubuntu
Vagrant: 1.8.1
VirtualBox : Version 5.0.20 r106931
Any Help?
Install the vagrant vaguest plugin and let it install the host's VirtualBox Guest Additions on the guest system and in your case it will update your guest addition
Also try apt-get update in your guest OS.

Vagrant can't assign static ip to box

I have the following inside my Vagrant file.
config.vm.network "private_network", ip: "192.168.33.12"
When I "vagrant up", vagrant is assigning 127.0.0.1. I'm not sure what's causing this. Below is the full trace.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/vm2
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
what you see here
default: SSH address: 127.0.0.1:2200
is not your VM IP address - this is just for vagrant to ssh into the box using an available port (in your case 2200). vagrant configures on your VM the eth0 interface to communicate with the host
Login to the VM and run ifconfig you will see you have (at least) 2 interfaces available with eth0 on 10.0.2.15 and eth1 on 192.168.33.12
As a shorthand way of doing this, a oneliner you can run from the host to see assigned IPs on the guest:
$ vagrant ssh -c "ifconfig | grep 'inet addr'"
Which will give you an output like this:
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet addr:192.168.200.200 Bcast:192.168.200.255 Mask:255.255.255.0
inet addr:127.0.0.1 Mask:255.0.0.0
Here are the steps that i choose while setting up the static ip of the Ubuntu machine:
ls /etc/netplan/ //go to this directory to find the config file
Note: the YAML file is very strict about the indentations e.g
dhcp4:true //will give wrong indentation error
dhcp4: true //right way to give
Now edit the config file:-
sudo nano /etc/netplan/01-netcfg.yaml
Change Default settings from :-
network:
version: 2
renderer: networkd
eth0:
dhcp4: true
dhcp6: false
optional: true
nameservers:
addresses: [8.8.8.8,8.8.4.4]
To
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
addresses: [172.28.32.11/16] //here choose your desired IP
gateway4: 172.28.32.1 //provide the gateway address,
nameservers:
addresses: [8.8.8.8,8.8.4.4]
Now do :
sudo netplan apply // to apply the network settings
You can then check that the ip address remains same during any course between vagrant halt/up
Here is what i did for the virtual box set machine of vagrant:
Add this to to vagrant file :-
config.vm.network "private_network", ip: "any IP address that you choose"
Then do the Vagrant Reload and you should be good.
In case the VM stucks for Vagrant Up command in retrying the connect or ssh .. do this:-
Run the below command from the cmder console:-
vagrant plugin install vagrant-vbguest
After this enable Vagrant GUI by adding the following to the vagrant file:-
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
Now do the vagrant up
the vagrant gui window will open and Keep Pressing "S" to skip and enter the login screen
Login with the username/password which is root/vagrant by default
and run the following command:-
sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
Now come out of the vagrant gui window shell and
remove the line added earlier for enabling the vagrant gui
from the cmder console do "vagrant up" again
Done!

Can't see the NFS shared directory in Vagrant

I try to create an NFS share directory in the vagrant box, but for some reasons I can not see the shared directory when I login to the box via ssh.
This is my Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
config.vm.synced_folder "./shared", "/st/data", :nfs => true
config.vm.network "private_network", ip: "192.168.33.10"
end
Vagrant reload output:
vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions 5.0.6 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
==> default: Mounting NFS shared folders...
==> default: Mounting shared folders...
default: /vagrant => /Users/stk/Documents/vagrant
==> default: Check for insecure vagrant key: OK (not present)
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
After vagrant ssh I can't see any nfs directory.
vagrant -v
Vagrant 1.7.4
OSX:
10.10.3
I tried most of the solutions mentioned here, but still no luck.

vboxsf error when passing owner,group and mount options parameters

Vagrant Version 1.6.3
Virtual Box 4.3.12
VBoxGuestAdditions-4.3.2
Host OS -> Windows 8
Guest OS -> CentOS 6.5
Vagrant synced_folder works fine when this is the content of Vagrentfile
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/var/www"
But I am unable to change the permissions of files or directories in synced_folder (/var/www).
https://github.com/mitchellh/vagrant/issues/897
To solve this problem I made following changes in Vagrentfile
https://serverfault.com/questions/398414/vagrant-set-default-share-permissions
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/var/www",
:owner=> 'shiva',
:group=> 'shiva',
:mount_options=> ['dmode=>777', 'fmode=>666']
(where 'shiva' is the user which I created, I deleted the default user 'vagrant')
Now the problem is when I try to do vagrant up ,it shows this error
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: shiva
default: SSH auth method: password
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /var/www => C:/Users/Shiva/CentOSDevEnv_v1_1
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u shiva`,gid=`getent group shiva | cut -d: -
f3`,dmode=>777,fmode=>666 var_www /var/www
mount -t vboxsf -o uid=`id -u shiva`,gid=`id -g shiva`,dmode=>777,fmode=
>666 var_www /var/www
I already go through this link
https://github.com/mitchellh/vagrant/issues/3341
I don't know ruby syntax (Vagrantfile syntax).
I am really stuck here, please help.
The error was in my Vagrantfile syntax, my bad :(
This is the correct syntax
:mount_options=> ['dmode=777', 'fmode=666']
But it would be more helpful if vagrant can show the correct error information , something like
"Error in Vagrantfile syntax"
instead of
"This is usually because the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and can work properly."

Resources