Author Topic: Setting Environment Variable  (Read 15912 times)

gawied

  • Community Member
  • Posts: 17
  • Hero Points: 0
Setting Environment Variable
« on: March 04, 2011, 09:31:24 AM »
Hi

I have upgraded to the latest version 15.0.1.3 and there seem to be a difference in how the Environment Variable settings are handled.

I configured my 'compile' command in project properties to call my IAR compiler via a command line instruction. Below is an extract of my slickedit project file that shows how I did it:

      <Target
        Name="Compile"
        MenuCaption="&amp;Compile"
        CaptureOutputWith="ProcessBuffer"
        SaveOption="SaveWorkspaceFiles"
        RunFromDir="%rw">
        <Set
          Name="PATH"
          Value="C:\Program Files\IAR Systems\Embedded Workbench 6.10\common\bin;PATH"/>
        <Exec CmdLine="iarbuild RT3rdGenWifi.ewp -make RT3rdGenProto1 -log all"/>
      </Target>
 
When I run the compile command, it fails with "vsbuild: File not found (iarbuild)". It seems that the PATH variable is never updated. However if I run the same project with a previous version of SlickEdit (V14) it works perfect. I am using this feature exstensively as I have different version of the IAR compiler installed and different projects use different versions of the compiler.

I have checked the following:
I am getting the same result (of not setting the PATH variable) if I try to set the path via "Workspace Environment Options".
I only have one configuration and it is selected as the active one.
It works fine after I execute "Set PATH=C:\Program Files\IAR Systems\Embedded Workbench 6.10\common\bin;PATH" in the SlickEdit command prompt.


Any help will be much appreciated.

Regards,
Gawie

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Setting Environment Variable
« Reply #1 on: March 04, 2011, 09:41:27 AM »
Usually env.vars can be specified per workspace (see workspace properties).
Any chance to use this alternative method ? Ie. using diff. workspaces for diff. compiler versions.
HS2

gawied

  • Community Member
  • Posts: 17
  • Hero Points: 0
Re: Setting Environment Variable
« Reply #2 on: March 04, 2011, 10:00:53 AM »
Hi HS2

I tried setting it via workspace properties and I got the same result.

It is sad that I need to look for atalternatives when it was working in the previous version :'(.

Thanks for the reply.
Gawie

microcode

  • Community Member
  • Posts: 59
  • Hero Points: 10
Re: Setting Environment Variable
« Reply #3 on: March 04, 2011, 09:01:30 PM »
I think we ran into a similar problem a while back.  We had a project that built successfully under v14 but then would not compile under v15.  IIRC, it was because some environment variables specified in the project or workspace properties were not actually getting set prior to invoking the build.  It wasn't just the PATH; it was other environment variables that needed to be set to specific values in order for the code to compile.

I didn't have time to investigate fully then because of our project deadline, so we just continued to use v14.  But I will dust off that old project to see why it didn't build under v15 and I will report back with more info.

microcode

  • Community Member
  • Posts: 59
  • Hero Points: 10
Re: Setting Environment Variable
« Reply #4 on: March 05, 2011, 12:26:14 AM »
The problem for us is that environment variables set by pre-build commands were no longer set when post-build commands were executed.  Attached is a minimal project that demonstrates the problem.

In the workspace properties, we set an environment variable:
Code: [Select]
Set APPNAME=Hello
In the project's pre-build commands we set another environment variable which references the one from the workspace:
Code: [Select]
SET XMLFILE=%(APPNAME).xml
Then in the project's post-build commands we have a series of echo statements to generate an XML file. One example is here:
Code: [Select]
echo ^<Application name="%(APPNAME)"^> >%(XMLFILE)
In SlickEdit v14, the environment variables are set correctly and everything executes successfully. I used v14.0.2.2 with hotfix 26 to test this example project.

However, in SlickEdit v15 (I'm using v15.0.1.3 with hotfix 19) the problem is that the XMLFILE environment variable is not set when the post-build commands run, so to the operating system the command looks like:
Code: [Select]
echo ^<Application name="Hello"^> >The command fails because the syntax is wrong (i.e. no file or device is specified for redirecting the output.)

However, the APPNAME environment variable from the workspace properties is set correctly, as shown in the echo command.

So it appears that environment variables set in the pre-build commands are not being carried forward into later build commands or are not actually being set in the first place.

I don't know if this is related to gawied's PATH problem or not, but it could be.

EDIT: I just now submitted a bug report about this issue.
« Last Edit: March 05, 2011, 12:31:02 AM by microcode »

gawied

  • Community Member
  • Posts: 17
  • Hero Points: 0
Re: Setting Environment Variable
« Reply #5 on: March 07, 2011, 07:28:04 AM »
Thanks microcode for the extra case with example. I am almost sure that our problem is caused by Environmental Variables not getting set.

I have also logged a bug report end of last week.

Let's see, maybe the SlickEdit guys can help us with this one.

Cheers,
Gawie

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Setting Environment Variable
« Reply #6 on: March 07, 2011, 01:59:01 PM »
@microcode:   I have confirmed that your sample it is not working correctly in 15.0.1.3, but it is working as expected in 16.0.0.1 (Beta 2) build.  It sounds like all these issues are related, I'll dig deeper.

gawied

  • Community Member
  • Posts: 17
  • Hero Points: 0
Re: Setting Environment Variable
« Reply #7 on: March 07, 2011, 02:12:13 PM »
Thanks Lee, much appreciated!

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Setting Environment Variable
« Reply #8 on: March 07, 2011, 04:11:20 PM »
I have a potential fix, I need confirmation that it fixes both issues.  The fix addresses 15.0.1.3 installations on Windows.  If you have the admin rights, please backup your existing vsbuild (\win\vsbuild.exe) and replace it with the attached vsbuild.exe.  I believe this addresses both reported issues, and only affects Windows users, let me know otherwise.




gawied

  • Community Member
  • Posts: 17
  • Hero Points: 0
Re: Setting Environment Variable
« Reply #9 on: March 07, 2011, 06:52:24 PM »
Thanks Lee, it fixes my problem with the PATH Environmental variable!!

Much appreciated!
Gawie

microcode

  • Community Member
  • Posts: 59
  • Hero Points: 10
Re: Setting Environment Variable
« Reply #10 on: March 07, 2011, 06:54:36 PM »
@Lee: Thank you for the fast fix!  The new vsbuild.exe solved the problem for me with SE v15.0.1.3.  The example project here and my real project both build fine.

However, neither project builds for me under SE v16.0.0.1 (beta 2, 64-bit).  I had tried building the example project with Beta 2 last Friday when I posted here, but I got a very different type of error.  So I thought they were different problems and I was going to investigate a little more and then post something in the beta forum.  But here are the errors I get when trying to build the example project with beta 2:

Code: [Select]
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\sand\se_env_test>echo VSLICKERRORPATH="C:\sand\se_env_test"
VSLICKERRORPATH="C:\sand\se_env_test"

C:\sand\se_env_test>"C:\PROGRA~1\SLICKE~1.0X6\win\vsbuild" "C:\sand\se_env_test\se_env_test.vpw" "C:\sand\se_env_test\se_env_test.vpj" -t rebuild -signal 61737
---------- Rebuild Project: 'se_env_test.vpj' - 'Debug' ---------- VSLICKERRORPATH="C:\sand\se_env_test"
SET XMLFILE=Hello.xml
main.c
gcc.EXE: /DAPPNAME=Hello: No such file or directory
gcc.EXE: /DMAKE_DEBUG: No such file or directory
gcc.EXE: /DDEBUG_LOG=localhost: No such file or directory
*** Errors occurred during this build ***

C:\sand\se_env_test>

Do you think this is related to the same vsbuild issue or is it something different?

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Setting Environment Variable
« Reply #11 on: March 07, 2011, 07:16:41 PM »
GCC expects -D for preprocessor define arguments, not /D.  I will file a defect for this, looks like some translation got missed in the beta for converting the arguments correctly.  Thanks for the report, try to get this fixed for next beta drop.

microcode

  • Community Member
  • Posts: 59
  • Hero Points: 10
Re: Setting Environment Variable
« Reply #12 on: March 11, 2011, 12:07:37 AM »
This has been fixed in v16 beta 3.  Thanks!

Gered

  • Community Member
  • Posts: 27
  • Hero Points: 1
Re: Setting Environment Variable
« Reply #13 on: March 24, 2011, 04:33:09 AM »
I'm also having this problem using the trial version for Linux (15.0.1.3). It's basically making my makefile totally ineffective when invoked via actions in the Build menu, as the PATH environment variable doesn't match what's in my ~/.bashrc.

Any hope of a fixed trial version?

UPDATE: Ah, nevermind I fixed it myself. And the answer was right in front of my face in the build window when it pops up the first time after starting SlickEdit:

Quote
To configure a different shell, set the macro variable 'def_build_shell' to the.
shell you want (/bin/tcsh -i,/bin/csh -i,/bin/ksh -i, etc.). Use the menu item
Macro>Set Macro Variable to set the macro variable.

Only setting it to "/bin/bash -i" worked for me (by that, I mean that all my environment variables are set properly in the build window shell).
« Last Edit: March 25, 2011, 02:09:13 AM by Gered »