Limits to environment variable nesting?

Page 1 of 2 12 LastLast

  1. Posts : 7
    Windows 7 / Fedora 12
       #1

    Limits to environment variable nesting?


    So, is there a limit to how deeply environment variables can be nested in Windows? I do a lot of development work and I'm trying to set up my development environment vars, and a lot of them nest off each other, ie.

    FOO=C:\path\to\foo
    FOO_BAR=%FOO%\bar
    BAR_ETC=%BAR%\etc

    I'm having some trouble getting Windows to expand all of them. Eventually when I look at 'set' I get an output like:

    FOO=C:\path\to\foo
    FOO_BAR=C:\path\to\foo\bar
    BAR_ETC=%BAR%\etc


    Is there some limit to how deeply it'll expand envvars? Is there a way to coax it into looking more deeply? A registry entry perhaps?

    Thanks all!
      My Computer


  2. Posts : 121
    Windows 7
       #2

    Have you enabled delayed expansion?
      My Computer


  3. Posts : 7
    Windows 7 / Fedora 12
    Thread Starter
       #3

    Have you enabled delayed expansion?
    Thanks for your help :)

    I'd never heard of that before. Just Google'd around and looked at it, I tried (from cmd) "setlocal enabledelayedexpansion" and echoing a nested library path and it doesn't look like it worked..

    Perhaps I'm using it wrong.. everywhere I see it used, it's being used in scripts and such, though I'm not sure how I can make this work for me here. I'm setting these envvars in the actual system properties so they're globally accessible when I'm doing my development work... is there a way to do delayed expansion on these types of envvars?
      My Computer


  4. Posts : 121
    Windows 7
       #4

    Try Catch,

    Can you post the path names (whether they use variables or not) as you have them set in the Environment Variables dialog in windows. If you need to, you can change the names, for privacy.

    Next, can you post a copy of the SET command below that. Again, just change names, like %USERNAME%, for privacy.
      My Computer


  5. Posts : 7
    Windows 7 / Fedora 12
    Thread Starter
       #5

    I'm not currently at my PC in question but I can give it to you mostly from memory. I've had this issue before and it's usually when I get about five deep that it starts to refuse expanding any further.

    It'll be something like:
    DEV_HOME=C:\dev
    THIRD_PARTY=%DEV_HOME%\thirdparty
    OSG=%THIRD_PARTY%\OpenSceneGraph
    OSG_ROOT=%OSG%\OpenSceneGraph-2.8.3
    OSG_INCLUDE_PATH=%OSG_ROOT%\include
    GLEW=%THIRD_PARTY%\GLEW
    GLEW_ROOT=%GLEW%\glew-1.5.5
    GLEW_INCLUDE_PATH=%GLEW_ROOT%\include


    (The reason for the [foo]_ROOT is for keeping multiple versions of dev packages around, I can just toggle [foo]_ROOT to point to a different one...)

    When I run set from cmd, I'll get (from memory, I'll post the actual contents later when I get back to my PC, but I'm 99% sure this is right)

    DEV_HOME=C:\dev
    THIRD_PARTY=C:\dev\thirdparty
    OSG=C:\dev\thirdparty\OpenSceneGraph
    OSG_ROOT=C:\dev\thirdparty\OpenSceneGraph\OpenSceneGraph-2.8.3
    OSG_INCLUDE_PATH=%OSG_ROOT%\include
    GLEW=C:\dev\thirdparty\GLEW
    GLEW_ROOT=C:\dev\thirdparty\glew-1.5.5
    GLEW_INCLUDE_PATH=%GLEW_ROOT%\include

    It gets as far as OSG_ROOT and GLEW_ROOT and then OSG_INCLUDE_PATH and GLEW_INCLUDE_PATH refuse to expand. Can't cd to it or anything. I'll double check that this is exactly where it breaks later. Needless to say this is frustrating because that's THE depth layer I need it to get to. D:
      My Computer


  6. Posts : 121
    Windows 7
       #6

    I've nested a number of paths, many "variables" deep, but honestly I've really only done it in batch files, and they are tempprary directories. But the concepts are really just the same. However, it would be more helpful, as im sure you know, if I can see the actual data, and not something posted from memory

    I'll go home and try some nesting in the env~ var~ dialog and see if I can reproduce the error. I'm personally interested in the outcome myself.
      My Computer


  7. Posts : 7
    Windows 7 / Fedora 12
    Thread Starter
       #7

    I was in the middle of copying for set and explaining where it went wrong when I realized... everything is expanded now..

    Confusion level = high. I haven't rebooted lately, and I know I opened a new cmd after trying the delayed expansion... I need to poke around with this a bit. I don't suppose you were able to force any errors?

    EDIT: WAIT, no... GLEW_BIN_PATH fully expands:

    GLEW=C:\dev\third-party\GLEW
    GLEW_1_5_5=C:\dev\third-party\GLEW\glew-1.5.5
    GLEW_BIN_PATH=C:\dev\third-party\GLEW\glew-1.5.5\bin
    GLEW_INCLUDE_PATH=C:\dev\third-party\GLEW\glew-1.5.5\include
    GLEW_LIB_PATH=C:\dev\third-party\GLEW\glew-1.5.5\lib
    GLEW_ROOT=C:\dev\third-party\GLEW\glew-1.5.5
    THIRD_PARTY_ROOT=C:\dev\third-party

    But in path it doesn't fully decompress:
    %THIRD_PARTY_ROOT%\GLEW\glew-1.5.5\bin;

    I've got it listed in Path as just GLEW_BIN_PATH%; tacked onto the end of path.

    ................... and now GLEW isn't expanding and OSG still is....

    Confusion level going critical...
    Last edited by trycatch; 23 Aug 2010 at 19:20.
      My Computer


  8. Posts : 7
    Windows 7 / Fedora 12
    Thread Starter
       #8

    AH HA!

    Okay I seem to have tracked it down. What was causing one set of dev envvars to expand and the other not had to do with I had some user specific envvars set for OSG and forgot about it, which was causing a few conflicts. Here's what I've tracked down.

    It's not nesting, it really is a lack of delayed expansion, but I can't seem to get around it. Here's what's going on...

    GLEW/OSG_LIB, _INCLUDE, and _BIN, all depend on GLEW/OSG_ROOT, which is expanded AFTER all of them. So now what I'm getting is _LIB, _INCLUDE, and _BIN are all just having unexpanded variables in them. I've tried enabling delayed expansion but that's not getting me anywhere.. any thoughts (other than renaming _ROOT to something alphabetically first?)
      My Computer


  9. Posts : 121
    Windows 7
       #9

    I think I may see some errors in logic here, but give me a few minutes. Also, just an FYI, you would have gotten a lot more responses than one if you posted this to Stack Overflow , a Coders Q&A forum, full of nothing but coders. Or even Server Fault , a Sys Admins forum, full of nothing but sys admins.

    Seven Forums is great, but it really has a different focus. IYKWIM
      My Computer


  10. Posts : 7
    Windows 7 / Fedora 12
    Thread Starter
       #10

    I feel like if I had gone to SO or a coders forum I would have gotten a lot of "WUT IS THIS GO TO A WINDOWS FORUM" responses. lol I can say from experience from living in a few coder IRC channels if you ask something vaguely off topic it can get testy quickly. :/

    I restarted and now everything expands EXCEPT I have OSG_BIN_PATH and GLEW_BIN_PATH in my Path variable and they DON'T expand... this is all very odd...
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 04:49.
Find Us