Vagrant: config.vm.synced_folder Seems to Run Commands on Host VM not Guest VM

Created on 4 Jun 2019  ยท  3Comments  ยท  Source: hashicorp/vagrant

Vagrant version

Vagrant 2.2.0

Host operating system

Windows 10

Guest operating system

Error on Vagrant boxes minimal/xenial64 and bento/ubuntu-18.10 running Ubuntu-16.04 and Ubuntu-18.10 respectively using Virtualbox 5.2.220.

Description

I have been using this VagrantFile to configure my guest vm environment for about 7 months now and recently decided I would add the shared folder functionality. Nothing else has changed. I have a few git repos on my host computer that I use my vagrant vm to compile and run. The shared folder changes bring the folders into the vm however when I try to execute a python command I get "-bash: ./aws_setenv.py: /usr/bin/python^M: bad interpreter: No such file or directory". This is the same error I get if I run the command on my host vm. I ran a few experiments, syncing some folders and not others on the same vm. The synced folders could not run my scripts but the non synced folders worked as expected.

In the code snippet of the change I made below I use #{params['ansible_promote_repo']} with YAML.load to parse a text file for the Host VM repo location. It works throughout the rest of the Vagrantfile for other needed vars. And the synced folder appears on the guest vm but just does not allow me to run my work.

I have also ran tests using rsync but recieved the same error.

Vagrantfile

Snippet:

config.vm.synced_folder "#{params['ansible_repo']}", "/home/vagrant/ansible-promote"

Debug output

-bash: ./aws_setenv.py: /usr/bin/python^M: bad interpreter: No such file or directory

Expected behavior

https://www.vagrantup.com/docs/synced-folders/

Actual behavior

It seems the synced folder is using the resources on my host computer.

Any help will be appreciated. Am I missing something? and please let me know if there is any other details I can provide.

Thanks

Most helpful comment

Hey Hey @briancain , you were absolutely correct. Running "sed -i -e 's/r$//'

All 3 comments

Hi @Hajamu - Just based on the error you are getting, I think Vagrant is working as expected. This looks to be an error from Bash on Ubuntu complaining about your script file having windows line endings:

I'm guessing if you fix the line endings, the error will go away.

If you are still experiencing an issue after following those posts feel free to open a new one or ping on here and we can reopen it. Thanks!

Hey Hey @briancain , you were absolutely correct. Running "sed -i -e 's/r$//'

Related issues

StefanScherer picture StefanScherer  ยท  3Comments

tomhking picture tomhking  ยท  3Comments

mpontillo picture mpontillo  ยท  3Comments

hesco picture hesco  ยท  3Comments

jazzfog picture jazzfog  ยท  3Comments