Bug 70359 - Environment is not being set through exec function
Summary: Environment is not being set through exec function
Status: VERIFIED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 2.0.1   Edit
Assignee: Alain Magloire CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-19 12:44 EDT by Tracy Miranda CLA
Modified: 2004-07-21 13:51 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tracy Miranda CLA 2004-07-19 12:44:23 EDT
To reproduce on windows xp:
- Create a new Standard Make C Project
- Add a makefile with the following in it:

all:
    printenv

- Build project

The environment that is displayed in the console is the sysytem environment and 
does not include variables set programatically such as the PWD and CWD 
variables that are set to the project working directory in the make builder. 

Also for our CDT-based application can't modify the path to pick up our tools.
Comment 1 Alain Magloire CLA 2004-07-19 15:28:40 EDT
Interesting,

  The information is simply not use.  The idea is that
since you can create Target on any folder, the Folder itself
is use as the location;  For example, if you create a "Target Property"
call "all" on /project/src  and run this the action
"Build Target", you will see that CWD/PWD is set to /project/src
no matter what the buildDirctory was set to.

So in brief if the build is run __by the platform__ like running
"clean" this is where the property working directory will be use.

I certainly understanding your point, it seems to be confusing.
We should document the behaviour and make things more consistent.
Many folks here are on vacation but we'll put this as a most for
2.1

How does it sound ?
Comment 2 Tracy Miranda CLA 2004-07-20 09:34:30 EDT
The issue isn't what the PWD/CWD get set to, but the fact that they are not 
being set at all. 

It looks to me like a call to exec function in 
org.eclipse.cdt.core.CommandLauncher i.e

public Process execute(IPath commandPath, String[] args, String[] env, IPath 
changeToDirectory) 

is failing to propagate the "String[] env" variable through to the code that 
eventually does the exec. As a result, the program being executed (e.g make)
always gets executed in the users default system environment rather that with 
what has been set up programmatically. 

The bit with the PWD/CWD is just to demonstrate these variables are not being 
set in CDT 2.0 whereas they were in CDT 1.2.x.
This presents a problem for our port because we set up the environment to 
launch make in so as to pick up our toolchain without requiring it to be on the 
users path. However, in CDT 2.0 (on Windows XP) it is failing to find the tools 
as the environment is not being setup correctly. 

Having tried to debug it the env variable gets propagated properly through to 
the Spawner class upto the point it hits the native function:
native int exec0( String[] cmdarray, String[] envp, String dir, int[] chan) 
throws IOException;
It seems like from this call to the native C/C++ code the envp variable isn't 
correctly propagated ? 
Comment 3 Alain Magloire CLA 2004-07-20 10:21:55 EDT
> The issue isn't what the PWD/CWD get set to, but the fact that they are not 
> being set at all. 
....
> It seems like from this call to the native C/C++ code the envp variable isn't 
> correctly propagated ? 

Allright,
  For now as a quick remedy, remove/rename the DLL:

org.eclipse.cdt.core.win32/os/win32/x86/spawner.dll

When this dll is not found the CommandLauncher/Spawner fall back
to use java.lang.Runtime.exec();

Resetting the MilesStone to 2.0.1 and escalating to Major.

PR reassign to Alex.
Comment 4 Alex Chapiro CLA 2004-07-20 16:39:24 EDT
Works in the HEAD branch now
Comment 5 Alain Magloire CLA 2004-07-20 16:43:03 EDT
> Works in the HEAD branch now

Many thanks, Alex.

Tracy M.,
  Please let me know if this fix things for you
then base on the feedback we will move this to the 2_0 branch


Comment 6 Tracy Miranda CLA 2004-07-21 05:50:00 EDT
Yes, that fix on the HEAD does the trick - the environment is now being set up 
correctly. Thanks for the quick response. 
Comment 7 Alain Magloire CLA 2004-07-21 13:50:28 EDT
> Yes, that fix on the HEAD does the trick

Fix in the branch and the head.
Comment 8 Alain Magloire CLA 2004-07-21 13:51:24 EDT
It was verified by Tracy and Alex