Does Cygwin import user variables or just system variables?

4

I can see windows system variables in cygwin with

echo $MYVar

However, user variables don't seem to work. I'm referring to the variables you set in system properties->advanced->environment variables (red arrow). Does Cygwin only import system variables?

Environment and User Variables

AlexMA

Posted 2013-02-05T20:57:21.177

Reputation: 417

Answers

5

Under normal circumstances, it should import both.

The exception that most likely applies in your case is that you're using an SSH client as your terminal. In this case, Cygwin does not import the user vars. Are you SSHing to your own workstation using PuTTY or another such SSH client? If you're not sure, try running the command echo $SSH_TTY. If you don't get a blank output to that command, that means your shell instance is being run via an SSH client, and the user's local environment vars will not be imported in this case.

You have two choices to solve this... You can either use a local terminal client like Mintty or rxvt instead of SSHing, both of which come native with Cygwin, or you can edit your Cygwin profile file in /etc to tell it not to skip local vars when running through SSH. This link shows how that can be done... http://smithii.com/node/44

Costa

Posted 2013-02-05T20:57:21.177

Reputation: 491

2My cygwin install isnt reading my user path, only my system path. i need it to read both – meffect – 2015-05-02T06:13:05.197

This is a great answer, so credit given. However, my problem was just a novice Windows mistake; I assumed once I hit the 'OK' button shown above, my variable would be created, but in fact it seems you have to hit the 'OK' in System Preferences and close it before any changes take place. And you also need to restart Cygwin to import the new variable. Doh. – AlexMA – 2013-02-05T22:23:54.777