This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 89962

Summary: $PATH is corrupted for projects with dependent library projects
Product: cnd Reporter: soldatov <soldatov>
Component: -- Other --Assignee: Thomas Preisler <thp>
Status: CLOSED WORKSFORME    
Severity: blocker    
Priority: P2    
Version: 5.x   
Hardware: All   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Attachments: Project

Description soldatov 2006-11-23 15:46:20 UTC
IDE clean PATH variable when external console is used and therefore HelloApp
sample project can not be run correctly on Windows (If Netbeans is started not
under cygwin).

Steps:
- Run Netbeans on Windows (not under cygwin)
- Create HelloApp project
- Build project
- Run project
==> Terminal appears with '[Press Enter to close window]' message only!!!
- Switch Console Type to 'Output Window (Input only)'
==> I see in output tab:
--------------------------------
Hello from main...
Hello from hello1...
Hello from hello2...

Arguments:
1: argument1
2: argument2

Run successful. Exit value 0.
--------------------------------
- Switch Console Type to 'Default'
- Find c:\netbeans-5.5\cnd1\dorun.sh script and add 2 strings:
echo $PATH
export PATH=/usr/bin:$PATH
- Run project
==> I see in output tab:
./hello1lib/dist/Debug:./hello2lib/dist/Debug <-- It is all PATH!!!
Hello from main...
Hello from hello1...
Hello from hello2...

Arguments:
1: argument1
2: argument2

Run successful. Exit value 0.
Comment 1 soldatov 2006-11-24 12:13:45 UTC
I have same problem when I use any static library.

Steps:
- Run Netbeans on Windows (but not under cygwin)
- Create 'C/C++ Static Library' project
- Add into project 2 file:
-------------------------------------------------------
#include <stdio.h>

int hello() {
    printf("Hello!!!\n");
    printf("%s\n", getenv("PATH"));
    return 0;
}

-------------------------------------------------------
/* 
 * File:   newfile.h
 * Author: tester
 *
 */

#ifndef _newfile_H
#define	_newfile_H

#ifdef	__cplusplus
extern "C" {
#endif

int hello();


#ifdef	__cplusplus
}
#endif

#endif	/* _newfile_H */

-------------------------------------------------------
- Create 'C/C++ Application' project
- Add path to newfile.h into 'Include Directories' property
- Add static project into Linker|Libraries|Libraries property ('Add Project'
button in 'Libraries' window)
- Add file into project:
-------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include "newfile.h"

int main(int argc, char** argv) {
    hello();
    return (EXIT_SUCCESS);
}

-------------------------------------------------------
- Run project
==> Terminal appears with '[Press Enter to close window]' message only
- Switch Console Type to 'Output Window (Input only)'
==> Program works correctly
Comment 2 soldatov 2006-11-24 12:49:01 UTC
And I have problem with PATH variable when I use Dynamic library.

Steps:
- Create 'C/C++ Dynamic Library' and 'C/C++ Application' projects identical
previous sample
- Run Netbeans under cygwin
- Switch Console Type to 'Output Window (Input only)'
- Run main project
==> I see in console:
Hello!!!
../Appl1/dist/Debug/GNU-Windows:/usr/local/bin:/usr/bin:/usr/bin:/usr/X11R6/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/forte4j/extbin:/cygdrive/c/Program
Files/Reflection/:/usr/bin
- Close Netbeans
- Run Netbeans not under cygwin
- Switch Console Type to 'Default'
- Run main project
==> I see in output window:
Run failed. Exit value -1073741515.
- Add path to dynamic library into 'Project Properties|Running|Run Directory'
property
==> I see in output window:
Hello!!!
/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/forte4j/extbin:/cygdrive/c/Program
Files/Reflection/:/usr/bin

Run successful. Exit value 0.

PATH to dynamic library (../Appl1/dist/Debug/GNU-Windows) is missed
Comment 3 _ gordonp 2006-11-29 00:29:10 UTC
This bug only manifests when netbeans is started outside the Cygwin enviroment
(usually by double clicking the desktop icon or from the Start menu).

If you echo $PATH from args (in dorun.sh) its correct. If you echo $PATH
from helloapp its wrong. Whats happening is that because helloapp has library
project dependencies, the build directories from those projects are prepended
to the existing $PATH. However, the PATH lookup is done on Env-PATH instead of
env-path. Since Windows uses a case independent variable Env-PATH returns
null and the library paths become the entire path.

The fix is to look for Env-PATH and if its not found (and the platform
is Windows), look for env-path. Then prepend the additional directores (but
again, only if they're for dynamic libraries).
Comment 4 soldatov 2007-04-29 12:26:34 UTC
Now all scenarios work correctly
Comment 5 soldatov 2007-12-27 15:40:23 UTC
I cannot run project with Dynamic library in Output Window when I am using Cygwin (works correctly with MinGW and in
external terminal).

Steps:
- Run Netbeans
- Open the attached projects
- Switch Console Type to 'Default' (in Project properties window)
==> program works correctly
- Switch Console Type to 'Output Window (Output only)'
- Run main project
==> "Hello!!!" message doesn't appears
Comment 6 soldatov 2007-12-27 15:41:23 UTC
Created attachment 54529 [details]
Project
Comment 7 soldatov 2007-12-27 17:23:39 UTC
It is not a problem with $Path. Tomorrow I will create a separated issue.
Workaround: build projects with -mno-cygwin option.