Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341064

Summary: CDT runs application with empty environment
Product: [Tools] CDT Reporter: Sven Köhler <sven.koehler>
Component: cdt-debugAssignee: cdt-debug-inbox <cdt-debug-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: normal    
Priority: P3 CC: cdtdoug, marc.khouzam, pawel.1.piech, yevshif
Version: 7.0.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Sven Köhler CLA 2011-03-27 19:17:36 EDT
Build Identifier:  M20110210-1200

I compile and run this little test program:
	char * pPath;
	pPath = getenv("PATH");
	if (pPath != NULL)
		printf("The current path is: %s\n", pPath);
	else
		printf("no path\n");

When I run it, it prints "no path".

However, if I edit the launch configuration and add a completely useless variable "asdfasdf", then the PATH variable is suddenly set.
(The radio button below the environment variables is set to "Append ...")

If I remove the variable again, then the radio buttons below the list of variables get grayed out. (BTW: this is not how the radio buttons should behave - it makes aboslute sense to have the choice between "Append variables" and "Replace native environment" even if the list of variables is empty). If I run the created binary, the PATH variable is empty again.

(My conclusion is, that the setting somehow defaults to "Replace native environment" if the list of variables is empty and the radio buttons are grayed out)


Reproducible: Always
Comment 1 Sven Köhler CLA 2011-03-27 19:25:02 EDT
A java launch configuration works: the environment variables exist, if the list of variables is empty. However, the radio buttons are also grayed out. (Which keeps a user from configuring a completely empty environment.)

Please advise, if I should report a seperate bug for the "radio button grayed out" issue.
Comment 2 Marc Khouzam CLA 2011-05-24 11:47:32 EDT
(In reply to comment #1)
> A java launch configuration works: the environment variables exist, if the list
> of variables is empty. However, the radio buttons are also grayed out. (Which
> keeps a user from configuring a completely empty environment.)
> 
> Please advise, if I should report a seperate bug for the "radio button grayed
> out" issue.

We take the environment tab from the platform, so your suggestion (which seems to make sense) to not have them grayed out, would need to be a separate bug on the platform.
Comment 3 Marc Khouzam CLA 2011-05-24 11:48:37 EDT
(In reply to comment #0)
> I compile and run this little test program:
>     char * pPath;
>     pPath = getenv("PATH");
>     if (pPath != NULL)
>         printf("The current path is: %s\n", pPath);
>     else
>         printf("no path\n");
> 
> When I run it, it prints "no path".

I am not able to reproduce this on Linux with CDT 7.0.2 or HEAD.  It may be a Windows-specific problem.