On Windows the env command uses 'export' and 'eval' independently of the shell type
Using vagrant-service-manager 1.0.2 on Windows 10, I get the following for the env command:
# Set the following environment variables to enable access to the
# docker daemon running inside of the vagrant virtual machine:
export DOCKER_HOST=tcp://10.1.2.2:2376
export DOCKER_CERT_PATH='C:\Users\hardy\work\openshift-vagrant\cdk-v2\.vagrant\machines\cdk\virtualbox\docker\'
export DOCKER_TLS_VERIFY=1
export DOCKER_API_VERSION=1.20
# run following command to configure your shell:
# eval "$(VAGRANT_NO_COLOR=1 vagrant service-manager env docker | tr -d '\r')"
This is regardless of the used shell type. Works for cygwin, but not for PowerShell or cmd. The I18N file in the code seems to define the various cases, but they are not properly retrieved.
@hferentschik Will look into it when windows machine is available to me. Meanwhile if you could try go ahead.
As discuss in , #10 we probably has no good way how to detect terminal type from ruby code. Export can be used by scripts (thanks to eval). I don't know how this can be done on windows, but setx works little bit differently. It doesn't set variables to current shell, but to whole system (for that user), and it still persists after reboots. Maybe we can have eval+export and for windows, document how to use setx manually (just once).
One more note: on windows, there should be setx, unless VAGRANT_DETECTED_OS is set to "cygwin".
I removed the 'blocker' label and moved this issue into v1.2.0 for now. If nothing else there is some stale code which in this case will never be used. If we cannot handle a windows shell better we might as well remove this.
Personally I am pretty sure though that we can do better. I believe there are also alternatives to setx. Needs to be investigated.
@hferentschik Good to move to 1.2.0. I would investigate more once I have machine available with me. Unable to do anything with my fedora machine.
I think we can use PowerShell syntax which allows to modify the variables for the current terminal - http://stackoverflow.com/questions/714877/setting-windows-powershell-path-variable
Nice solution, @hferentschik . But it's not usable in bash or in cmd.exe, so main problem remains: how to decide from which terminal vagrant command is executed. I failed to find any good way, so I reused already recommended env variable (VAGRANT_DETECTED_OS). Current solution is far from optimal, I hope someone will find better way.
BTW, @optak you are right that setting VAGRANT_DETECTED_OS to something (non 'cygwin') makes the setx output appear. So the question is why I need to set it to something at all. If the variable is not set at all, I get the export form of the commands. Should the export form not only be used if we are on Windows (which we can detect) and the vagrant detected os env variable is set to 'cygin'. In the other cases it should be the Windows form.
Regarding bash/cmd.exe, I think it would be better it would work with Powershell. If we cannot detect cmd vs powershell, then we can work with an environment variable there as well. Bottom line is that I want the command to provide the right syntax to configure my PowerShell terminal with the right settings. If I need to set an env variable first, that's fine. @optak Do you see where I am coming from?
Relates to issue #293