pik
pik copied to clipboard
Save and Restore Ruby ENV vars on version switch
Feature Request: Save and Restore Ruby ENV vars on version switch
The following ENV vars are still checked and allowed by Ruby on Win32 in both 1.8.x and 1.9.x branches (ruby.c and win32.c). These are vars for Ruby runtime control, and I have uses for them.
RUBYLIB RUBYOPT RUBYPATH RUBYSHELL RUBYLIB_PREFIX
A temp workaround is a batch cmd file that saves these vars, calls the pik version switch, and restores the ENV vars to a previously saved set for the version parameter (which would be passed to the batch file.)
SO much simpler if pik did this.
Discussing this with Luis Lavena on the GoogleGroup, I think the follwoing is the best course of action.
FYI: pik also needs to save COMSPEC, especially when RUBYSHELL is used. Ruby will check and use RUBYSHELL first, and if it's not set, then it will use the Platform's shell setting, (COMSPEC on Win32 and SHELL on Unix, Linux and OSX.)
I think that's the best place to add the functionality to pik is in the config command:
The most flexible way would be to have an 'env' option that would take a comma separated list of ENV vars to save and restore.
Ex: pik config env COMSPEC,RUBYLIB,RUBYLIB_PREFIX,RUBYOPT,RUBYPATH,RUBYSHELL
And then pik should save them (with their current values,) for whichever ruby configuration is currently active.
This would allow a user to start with a base set of ENV var values, and then tweek one or two of them individually.
To tweek (or add,) an individual ENV var setting:
Ex(s): pik config var RUBYSHELL=spawn.exe pik config var BASEURL=http://www.myrubywebsite.net/downloads
You could then tweek RUBYOPT,GEM_HOME and GEM_PATH using "pik config var" even though there are RVM compatible config options. (maybe the RVM people would like to calaborate on a uniform behaviour for these two config options: 'env' and 'var' ??
On further thought...
I think the "env" config option would need both a "+" and a "-" variant.
The plus variant would add the listed environment vars to a configuration. Ex: pik config env+ RUBYSHELL,COMSPEC
The minus variant would remove the listed vars from a configuration. Ex: pik config env- LOGONSERVER
FYI, the var option: If a variable is set blank, it would tell pik in it's configuration, to perform a "SET %var%=" (clearing the variable when pik switches to the specific configuration.) Ex: pik config var RUBYSHELL=
Question, does RVM have anything like this.. where the user can program the configurations to save and restore whatever Enviroment Variables they wish ??
Bounced the RVM side off of Wayne Seguin over at his GoogleGroup.
He only has project specific means of users setting custom ENV vars, within RVM's .rvmrc shell script files. These are automatically run when a user enters a specific project dir.
On Win32 this feature might be possible using "autorun.inf" files.
But it's not something I'm interested in. (I personally have autorun turned OFF on my system, as it is an annoyance.)