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

Doesn't work on windows? #33

Closed uchagani closed 9 years ago

uchagani commented 9 years ago

I'm trying to set environment variables through the trigger but nothing I've tried works:

uchagani commented 9 years ago

can you please explain the reasoning for: https://github.com/emyl/vagrant-triggers/blob/master/spec/vagrant-triggers/dsl_spec.rb#L80

emyl commented 9 years ago

Please, could you provide an example of what you're trying?

Thanks.

uchagani commented 9 years ago
Vagrantfile
Vagrant.configure("2") do |config|

  config.vm.define "admin" do |admin|    
    admin.vm.box = "MyBaseBox"

    admin.vm.provider "vmware_workstation" do |vm|    
      vm.name = admin.vm.hostname    
    end

    admin.trigger.before :up, :stdout => true do
      run "SET ROLE=Admin"
    end
  end 

  config.vm.define "client" do |client|    
    client.vm.box = "MyBaseBox"

    client.vm.provider "vmware_workstation" do |vm|   
      vm.name = client.vm.hostname   
    end

    client.trigger.before :up, :stdout => true do
      run "SET ROLE=Client"
    end
  end 
end
Output
Bringing machine 'admin' up with 'vmware_workstation' provider...
Bringing machine 'client' up with 'vmware_workstation' provider...
==> admin: Running triggers before up...
==> admin: Executing command "SET ROLE=Admin"...
The executable "SET" Vagrant is trying to trigger
was not found. If you know it is not in the PATH, please
specify its absolute path using the :append_to_path option.

SET ROLE=Admin works just fine when executed from the command line but doesn't when ran through the trigger

emyl commented 9 years ago

Here the problem is that SET is an internal MS-DOS command, and so it can't be found as executable.

Depending on your use case, maybe you could work around the issue by using either SETX, Powershell's Set-Variable, or a more specific plugin like vagrant-env.

uchagani commented 9 years ago

I tried set-variable and got the same result. On Nov 27, 2014 9:46 AM, "Emiliano Ticci" notifications@github.com wrote:

Here the problem is that SET is an internal MS-DOS command, and so it can't be found as executable.

Depending on your use case, maybe you could work around the issue by using either SETX http://ss64.com/nt/setx.html, Powershell's Set-Variable http://ss64.com/ps/set-variable.html, or a more specific plugin like vagrant-env https://github.com/gosuri/vagrant-env.

— Reply to this email directly or view it on GitHub https://github.com/emyl/vagrant-triggers/issues/33#issuecomment-64798346 .