Vagrant version: 2.2.4
Host operating system: ubuntu 16.04
Guest operating system: ubuntu 16.04
Vagrantfile: Not relevant
Debug output: Not relevant
vagrant box prune removes all outdated / non-latest boxes. prune will display a promptyes N | commandโฏ yes N | vagrant box prune
Checking for older boxes...
Vagrant is attempting to interface with the UI in a way that requires
a TTY. Most actions in Vagrant that require a TTY have configuration
switches to disable this requirement. Please do that or run Vagrant
with TTY.
It does not appear that vagrant box prune has a "configuration switch" to disable the TTY requirement.
I also understand that vagrant box prune has a --force option. This works if you don't want to keep the used VM box.
Couple of options:
vagrant prune box to be run without a TTY such that yes N | command will workvagrant prune box that will skip the prompt but not delete any used VMs (this would be the opposite of --force)DIRTY HACK INCOMING
What follows is _NOT_ the right way to solve your problem, just a workaround to get going. Someone should really add an option to skip the TTY test. Unfortunately, I don't know Ruby.
I've looked for ways to simulate a TTY on stdin, and while there are solutions, they add lots of complexity. So I tried something simpler: since Vagrant checks if stdin is a TTY, we can trick it into believing it is by preloading a different version of the isatty function into the process.
Compile this small piece of C into a shared object:
/* isatty.c */
int isatty(int fd) {
return 1;
}
gcc -o isatty.so -fPIC -shared isatty.c
Then launch Vagrant with your synthetic input, but preload this SO:
yes N | LD_PRELOAD=/path/to/isatty.so vagrant box prune
This should yield the desired result: I've tested it with vagrant destroy which gives the same error if called after a pipe. It is clearly a hack since this will make every single file descriptor passed to isatty look like a TTY and we are messing with standard function.
Hi @kylegibson - I think it makes sense to add another "force" type option that will prune boxes, not in use, without confirmation. :+1:
Would be nice, currently have vagrant box update automatically happening but can't get the prune done via cicd as I don't want to force. What about;
-silent
-skip-in-use-boxes
-skip-used-boxes
-leave-used-boxes
A command line argument using the word force, i would assume deleted or overrides and does not leave or ignore boxes that are in use.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Hi @kylegibson - I think it makes sense to add another "force" type option that will prune boxes, not in use, without confirmation. :+1: