Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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

share|improve this answer
    
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 Feb 5 '13 at 22:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.