Author Topic: Using EnvVar  (Read 5516 times)

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Using EnvVar
« on: June 30, 2010, 03:36:20 pm »
I've set the PATH environment to 'PATH=%PATH%;C:\NewPath' variable via 'Settings > Environment > Environment Variables' which as I understand it should set the variable on startup.  However, when I close C::B and restart it, the PATH variable is not updated (i.e. C:\NewPath is not in %PATH%).  Is there something I have to do to have these environment variables set on startup?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7678
    • My Best Post
Re: Using EnvVar
« Reply #1 on: June 30, 2010, 04:24:33 pm »
I've set the PATH environment to 'PATH=%PATH%;C:\NewPath' variable via 'Settings > Environment > Environment Variables' which as I understand it should set the variable on startup.  However, when I close C::B and restart it, the PATH variable is not updated (i.e. C:\NewPath is not in %PATH%).  Is there something I have to do to have these environment variables set on startup?

The EnvVar plugin is for changing the Environment Variables for just inside Code::Blocks; if you want the changes to be permanent change them the normal way for the OS. Note, most commands ran from Code::Blocks should also see the modified Environment Variables.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Using EnvVar
« Reply #2 on: June 30, 2010, 04:31:10 pm »
The EnvVar plugin is for changing the Environment Variables for just inside Code::Blocks; if you want the changes to be permanent change them the normal way for the OS. Note, most commands ran from Code::Blocks should also see the modified Environment Variables.

Agreed.  I need PATH to be temporarily modified when running a pre-build command, and I would like to not have to modify the system PATH.  My expectations would be that if the PATH variable is set on C::B startup, the modified PATH should be used for the pre-build command and not affect applications run outside of C::B.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7678
    • My Best Post
Re: Using EnvVar
« Reply #3 on: June 30, 2010, 05:04:19 pm »
The Devs are going to need more info; OS Version CB Version etc.
This assumes they think it is a problem.

If you get no fix in a week; post the bug in the correct site.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Using EnvVar
« Reply #4 on: June 30, 2010, 05:13:12 pm »
I'm running XP SP3 with C::B 10.05.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using EnvVar
« Reply #5 on: June 30, 2010, 09:32:23 pm »
Also a simple test project that reproduces the problem or at least the full build log.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Using EnvVar
« Reply #6 on: July 01, 2010, 01:35:52 am »
Also a simple test project that reproduces the problem or at least the full build log.

Erm.... the build log doesn't show much (I have Compiler Logging set to 'Full Command Line') all I see is:

Code
Running project pre-build steps

My pre-build step is:

Code
[[ local hgfile = _T("hgversion.h"); local hgcmd = _T("cmd /c hg summary | grep parent | sed -f hgversion.sed > hgversion.h"); if ( !IO.FileExists(hgfile) ) { IO.Execute(hgcmd); } ]]

the problem is that grep and sed are in my MSYS directory, which I temporarily want to add to the PATH for this pre-build step.  If I add the MSYS path to the PATH prior to starting C::B, the command works fine.

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Using EnvVar
« Reply #7 on: July 03, 2010, 01:31:02 pm »
I've managed to work around the issue by adding my MSYS path to the 'Additional Paths' tabs in 'Settings > Compiler and Debugger > Global Compiler Settings' under the 'Toolchain executables' tab.