Skip to content

Instantly share code, notes, and snippets.

@michfield
Last active December 12, 2015 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michfield/4692225 to your computer and use it in GitHub Desktop.
Save michfield/4692225 to your computer and use it in GitHub Desktop.
Fix Vagrant about environment variables #vagrant

Batch file vagrant.bat sets both GEM_HOME and GEM_PATH environment variables. It would be nice of him to restore old values after finishing it's work.

Something like:

:: Save variables
SET "GEM_HOME_SAVED=%GEM_HOME%"
SET "GEM_PATH_SAVED=%GEM_PATH%"

...

and at the end of a file

...

:: Restore variables
SET "GEM_HOME=%GEM_HOME_SAVED%"
SET "GEM_PATH=%GEM_PATH_SAVED%"
SET "GEM_HOME_SAVED="
SET "GEM_PATH_SAVED="

:: Restore environment variables GEM_HOME and GEM_PATH (read from .gemrc)
::
:: Restore variables from .gemrc
:: for /f "tokens=*" %%f in ('gem env gemhome') do @set GEM_HOME=%%f
:: for /f "tokens=*" %%f in ('gem env gempath') do @set GEM_PATH=%%f

Btw: This :: thing are comments in .bat files. Nicer than REM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment