Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Hard reset of environment variables VS ruby version managers #73

Open
ysbaddaden opened this issue Feb 9, 2014 · 8 comments
Open

Hard reset of environment variables VS ruby version managers #73

ysbaddaden opened this issue Feb 9, 2014 · 8 comments

Comments

@ysbaddaden
Copy link
Owner

I'm hard resetting the environment variables to almost nothing, in order for ruby version managers to not be influenced by the ruby version Prax is currently running with.

The problem is that the reset is so hard that not even HOME, USER and UID are kept.

I'm wondering how to correctly fix that problem: have a whitelist of environment variables that must be kept? Keep a hash of the original environment variables? Something else?

@suan
Copy link
Contributor

suan commented Feb 21, 2014

How about purging all vars with RUBY, GEM, BUNDLE in it and PATH, and leave the rest as is?

@ysbaddaden
Copy link
Owner Author

Version managers are each setting their own vars, so it doesn't work to just clean some vars. Prax would have to know about all version managers and filter-out their variables —assuming they won't add more or change any.

@mpapis
Copy link

mpapis commented Nov 25, 2014

the important variables are set by the version managers, they are important for ruby not the manager, just make sure that the shell you use does not load any manager and resetting this variables should be enough:

GEM_HOME
GEM_PATH

+ all listed here http://www.tutorialspoint.com/ruby/ruby_environment_variables.htm:

DLN_LIBRARY_PATH    # Search path for dynamically loaded modules.
HOME        # Directory moved to when no argument is passed to Dir::chdir. Also used by File::expand_path to expand "~".
LOGDIR      # Directory moved to when no arguments are passed to Dir::chdir and environment variable HOME isn't set.
PATH        # Search path for executing subprocesses and searching for Ruby programs with the -S option. Separate each path with a colon (semicolon in DOS and Windows).
RUBYLIB     # Search path for libraries. Separate each path with a colon (semicolon in DOS and Windows).
RUBYLIB_PREFIX  # Used to modify the RUBYLIB search path by replacing prefix of library path1 with path2 using the format path1;path2 or path1path2.
RUBYOPT     # Command-line options passed to Ruby interpreter. Ignored in taint mode (Where $SAFE is greater than 0).
RUBYPATH    # With -S option, search path for Ruby programs. Takes precedence over PATH. Ignored in taint mode (where $SAFE is greater than 0).
RUBYSHELL   # Specifies shell for spawned processes. If not set, SHELL or COMSPEC are checked.

JRuby and RBX might have few more, @headius & @brixen - can you fill in?

@ysbaddaden
Copy link
Owner Author

Thanks for the hint @mpapis ! I'll try with a blacklist solution.

@headius
Copy link

headius commented Nov 25, 2014

JRuby should obey the RUBY* env vars. We have also heard of bugs when there's no HOME set, but it's uncommon.

Additional for JRuby:

JRUBY_OPTS
JAVA_OPTS

I'd have to audit the codebase to get a complete list.

@brixen
Copy link

brixen commented Nov 25, 2014

Anything prefixed with RBX (eg RBXOPT) could affect Rubinius. We can't give you a definitive set because we'll add them whenever we want. But we'll prefix any we depend on.

@mpapis
Copy link

mpapis commented Nov 25, 2014

ah I would have forgotten, there is set of variables starting with BUNDLE that might affect bundler/rails

@ysbaddaden
Copy link
Owner Author

Thanks for the input. I'll try a nicer cleanup of shell environment. Right now I only let $HOME slip by, and I didn't break much projects (only $HOME was required once) —developers can use the sourced ~/.praxconfig if they need anything globally or myapp/.praxrc or myapp/.env for project specifics.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants