emyl / vagrant-triggers

Allow the definition of arbitrary scripts that will run on the host before and/or after Vagrant commands.
MIT License
546 stars 35 forks source link

Triggers not running bash command to remove files #70

Closed jeff1evesque closed 7 years ago

jeff1evesque commented 8 years ago

When I run vagrant destroy, my Vagrantfile should remove any files with a *.pyc extension:

...
  # clean up files on the host after 'vagrant destroy'
  config.trigger.after :destroy do
    run 'find . -name *.pyc -type f -exec rm -r {} +'
  end
...

However, it doesn't remove the python *.pyc files. Instead, if I run vagrant destroy a second time, the files are properly removed, recursively.

jeff1evesque commented 8 years ago

My host machine is Windows 7 (not sure if that is useful).

jeff1evesque commented 8 years ago

Quoting the *.pyc also requires vagrant destroy to be run a second time:

  # clean up files on the host after 'vagrant destroy'
  config.trigger.after :destroy do
    run 'find . -name "*.pyc" -type f -exec rm -r {} +'
  end
emyl commented 8 years ago

Hello!

Please, could you post the output of the two vagrant destroy commands with VAGRANT_LOG=debug enabled?

Many thanks!

jeff1evesque commented 8 years ago

Hi @emyl, I will have this paste to you tomorrow (my apologies). Only have access to an OSX machine this long weekend.

jeff1evesque commented 8 years ago

Shoot, it says:

$ vagrant destroy VAGRANT_LOG=debug
The machine with the name 'VAGRANT_LOG=debug' was not found configured for
this Vagrant environment.

So, I ran it without the above flag (first time):

$ vagrant destroy
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...
==> default: Running triggers after destroy...
==> default: Executing command "rm -Rf log/database"...
==> default: Command execution finished.
==> default: Executing command "rm -Rf log/application"...
==> default: Command execution finished.
==> default: Executing command "rm -Rf log/webcompiler"...
==> default: Command execution finished.
==> default: Executing command "rm -Rf log/webserver"...
==> default: Command execution finished.
==> default: Executing command "rm -Rf build"...
==> default: Command execution finished.
==> default: Executing command "rm -Rf interface/static/css"...
==> default: Command execution finished.
==> default: Executing command "rm -Rf interface/static/img"...
==> default: Command execution finished.
==> default: Executing command "rm -Rf interface/static/js"...
==> default: Command execution finished.
==> default: Executing command "rm -Rf puppet/environment/*/modules_contrib"...
==> default: Command execution finished.
==> default: Executing command "rm -f src/js/.gitignore"...
==> default: Command execution finished.
==> default: Executing command "rm -f src/js/support_vector.js"...
==> default: Command execution finished.
==> default: Executing command "find . -name *.pyc -type f -exec rm -r {} +"...
==> default: Command execution finished.
==> default: Executing command "find . -name __pycache__ -type d -exec rm -r {} +"...
==> default: Command execution finished.
==> default: Executing command "find . -name .cache -type d -exec rm -r {} +"...
==> default: Command execution finished.

vagrant-destroy

Note: the screenshot above (towards the right), shows *.pyc files that was supposed to be deleted, and an indication that the config.trigger.after :destroy do didn't run.

However, if I run it a second time, everything works as expected:

vagrant-destroy2

emyl commented 7 years ago

Hi,

Please could you swap the command to:

VAGRANT_LOG=debug vagrant destroy

and post the output?

jeff1evesque commented 7 years ago

Hi @emyl, sorry for the late response. It seems my original error no longer exists. I recently had to reinstall vagrant, on another windows machine. I currently have vagrant 1.8.5. So, either I had an older version of vagrant (pre 1.8.5), or my same windows 7 on the other machine had some internal problems.

emyl commented 7 years ago

Thanks for the feedback, going to close the issue 😉