I noticed that even this message was shown as an error (in RED colour), the script was executed successfully! A few days later I saw a possible fix and I posted an answer on SO. The “fix” is:
# Prevent TTY Errors (copied from laravel/homestead: "homestead.rb" file)... By default this is "bash -l". config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
Maybe you just don’t need it, but you can try it and use it if it works for you.
As you can see in the commented line above – the “mesg: ttyname failed Inappropriate ioctl for device” has been prevented from the laravel team. Thanks for this one!
Most developers would like to avoid errors/warnings when we do development, so it seems like the fix (a possible fix) we needed.
Important note: I haven’t tested this solution too much, but the box starts without the “mesg: ttyname failed Inappropriate ioctl for device” error! You are free to try it and if you experience any problems, just drop a comment to save somebody else’s time!
1) open /root/.profile
2) remove the offensive line
3) replace it with:
tty -s && mesg n
Happy linuxing and a merry new year.
George Hart, LSU
It looks like this is caused by an interaction between the default vagrant configuration of
config.ssh.shell to be
bash -l (which simulates a login shell, thus processing login-related configuration files such as
.profile) with a line in the
/root/.profile file on at least some distributions of Linux (including, e.g., the one in the ubuntu/xenial64 vagrant box), which has:
mesg n || true
A better option for this line in that file would probably be to have it say:
test -t 0 && mesg n
… and, given that that’s hard to change as an individual vagrant user, a more immediate solution is to drop the
-l option from the vagrant configuration, e.g. with (within
(Caveat: It’s conceivable that this change could have potentially-negative side effects. It seemed to work great for me, though, with some basic shell provisioners, e.g. with
apt-get update, and so forth.)
What versions of Vagrant and VirtualBox are you using?
I was facing this issue yesterday when using Vagrant 1.8.5 with VirtualBox 5.1.4 (with Ubunty 16.04). However, after I upgraded to Vagrant 1.9.2 and VirtualBox 5.1.14 today, the issue went away.
Note that, prior to upgrading, as @Minister also mentioned, the script executed without issue. It was just outputting that “ttyname failed” message, which gave the impression that an error occurred, when actually the provisioning script executed successfully.
I had this issue start happening in a Vagrant installation that I had been using for years and had upgraded from time to time as well. I upgraded to the latest Vagrant ( 1.9.1 -> 2.0.3 ) and the problem went away. ( it also eliminated some other quirky things as well that had crept into its operation )
Not sure if it was the new version that fixed it or that existing files/configs were freshened in the upgrade process or a combination of the two.
Seems like it only works in VirtualBox v6.0.2 for Mojave/Catalina! (+vagrant 2.2.2 – not sure it matters though!)
This fixed it for me now in your host Mac:
vagrant halt sudo ifconfig vboxnet0 down sudo ifconfig vboxnet0 up vagrant up