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 120836 - Run failed if the project was created without compilers in path
Summary: Run failed if the project was created without compilers in path
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P1 blocker (vote)
Assignee: Thomas Preisler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-01 16:11 UTC by Alexander Pepin
Modified: 2008-04-09 14:08 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pepin 2007-11-01 16:11:58 UTC
Steps to reproduce:
- remove a path to GNU compiler collection from PATH environment variable
- run IDE with a fresh userdir
- create a sample project (e.g. Welcome)
- try to compile the project, close compiler settings window
- open Tools->Options->C/C++ Settings window
- add a path to Cygwin compiler collection
- clean and build the project
- try to run the project
Result: Run fails with an error message box "Windows can not find sh". Also wrongly localized message ("ЌҐ г¤ Ґвбп ­ ©вЁ
д ©« sh.") appears in the output window.
Comment 1 Thomas Preisler 2008-03-14 06:34:13 UTC
This situation should not be possible anymore with the new design of the tool chains setup. I don't think it is possible
to build a project with no compilers available.
Comment 2 Alexander Pepin 2008-04-02 11:38:22 UTC
The bug is not about possibility to compile the project but it's about impossibility to run compiled project and this is
not fixed with a new toolchain. 
Comment 3 Thomas Preisler 2008-04-02 17:13:02 UTC
Agree. This bug should not have been closed. and "Gdb could not be started http://www.netbeans.org/issues/show_bug.cgi?id=131802" is most likely a dup.
Comment 4 _ gordonp 2008-04-02 17:59:58 UTC
The gdb version (131802) is a duplicate of this issue. I raised 131802 to P1 but Jesse lowered
it back to P2. I think this issue is critical as it was very important to support project building
for users who do not have their compiler directory in their path. Not only does that directory
need to be in their path to build, it needs to be their to run (so it finds dlls at Runtime).
Comment 5 Thomas Preisler 2008-04-03 06:14:53 UTC
Fixed the Run part. Debugging needs a similar fix in GdbLite's code. I added the following code that will add proper path to environment (PATH):

                    // Append compilerset base to run path. (IZ 120836)
                    ArrayList<String> env1 = new ArrayList<String>();
                    String csname = ((MakeConfiguration) pae.getConfiguration()).getCompilerSet().getOption();
                    String csdirs = CompilerSetManager.getDefault().getCompilerSet(csname).getDirectory();
                    if (((MakeConfiguration)pae.getConfiguration()).getCompilerSet().getFlavor().equals(CompilerFlavor.MinGW.toString())) {
                        // Also add msys to path. Thet's where sh, mkdir, ... are.
                        String msysBase = CppUtils.getMSysBase();
                        if (msysBase != null && msysBase.length() > 0) {
                            csdirs = csdirs + File.pathSeparator + msysBase + File.separator + "bin"; // NOI18N
                        }
                    }
                    boolean gotpath = false;
                    String pathname = Path.getPathName() + '=';
                    int i;
                    for (i = 0; i < env.length; i++) {
                        if (env[i].startsWith(pathname)) {
                            env1.add(env[i] + File.pathSeparator + csdirs); // NOI18N
                            gotpath = true;
                        } else {
                            env1.add(env[i]);
                        }
                    }
                    if (!gotpath) {
                        env1.add(pathname + Path.getPathAsString() + File.pathSeparator + csdirs);
                    }
                    env = env1.toArray(new String[env1.size()]);

GdbLite needs to add similar code.

In the future we should consolidate the code.
Comment 6 Thomas Preisler 2008-04-04 01:10:05 UTC
Extending the fix to cover shell file and make file stand-alone execution from a project by adding the compiler base path to the environment shell file and 
make files are executed in. If you start the IDE with no compilers in the PATH and configure the tool chain from the tool chain dialog, projects are now 
buildable and debuggable, and shel and make execution work. I realize it was important that shell file execution did work because the project wizard may 
execute a configure script as part of project creation which wouldn't work without this extra fix.
Comment 7 Thomas Preisler 2008-04-04 01:54:29 UTC
Extended fix committed to trunk:
changeset 8310e758f828 in main
details: http://hg.netbeans.org/main?cmd=changeset;node=8310e758f828
description:
	120836 Run failed if the project was created without compilers in path

What should work now (when you include fix for http://www.netbeans.org/issues/show_bug.cgi?id=131802):

- remove a path to GNU compiler collection from PATH environment variable
- run IDE with a fresh userdir
- create a sample project (e.g. Welcome)
- try to compile the project, close compiler settings window
- open Tools->Options->C/C++ Settings window
- add a path to Cygwin compiler collection
- clean and build the project
- run the project
- debug the project
- run make directly from it's context menu
- add a shell file and run it directly from it's context menu
Comment 8 alexandrov 2008-04-04 13:53:23 UTC
verified in trunk 200804040003
Comment 9 alexandrov 2008-04-04 15:16:35 UTC
fix failed.
Run executable through context menu leads to NPE:

java.lang.NullPointerException
	at
org.netbeans.modules.cnd.makeproject.api.DefaultProjectActionHandler$HandleEvents.go(DefaultProjectActionHandler.java:365)
	at
org.netbeans.modules.cnd.makeproject.api.DefaultProjectActionHandler.actionPerformed(DefaultProjectActionHandler.java:131)
	at org.netbeans.modules.cnd.makeproject.api.ProjectActionSupport.fireActionPerformed(ProjectActionSupport.java:72)
	at org.netbeans.modules.cnd.makeproject.api.actions.RunDialogAction.perform(RunDialogAction.java:137)
	at org.netbeans.modules.cnd.makeproject.api.actions.RunDialogAction.perform(RunDialogAction.java:107)
	at org.netbeans.modules.cnd.makeproject.api.actions.RunDialogAction.performAction(RunDialogAction.java:91)
	at org.openide.util.actions.NodeAction$DelegateAction$1.run(NodeAction.java:581)
	at org.netbeans.modules.openide.util.ActionsBridge$ActionRunnable.actionPerformed(ActionsBridge.java:111)
	at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:104)
	at org.netbeans.modules.openide.actions.ActionsBridgeImpl.invokeAction(ActionsBridgeImpl.java:52)
	at org.netbeans.modules.openide.util.ActionsBridge$ActionRunnable.doRun(ActionsBridge.java:102)
	at org.netbeans.modules.openide.util.ActionsBridge$1.run(ActionsBridge.java:71)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)

Comment 10 Thomas Preisler 2008-04-04 16:30:53 UTC
and the steps are?

I cannot reproduce. are you sure it is related to my changes?
Comment 11 Alexander Pepin 2008-04-04 17:56:43 UTC
I'm not sure which changes caused this exception but it's definitely a regression. It does not happen in trunk build
20080403 and does happen in today's 20080404. Probably it's a side effect of fixing issue #131739. Because it does not
depend on having compilers in path I would create a new IZ for this.
Anyway here is steps to reproduce:
- create a new project (e.g. Welcome)
- build the project
- run the project, everything is OK
- switch to Files tab
- expand Welcome/dist/Debug/welcome.exe and call "Run..." from the file context menu
- select Welcome project in Project combobox in Run window then press Run
Result: Mentioned exception appears

Comment 12 Alexander Pepin 2008-04-04 18:03:58 UTC
somehow I changed Priority and Target milestone. Now I've changed them back
Comment 13 Alexander Pepin 2008-04-04 22:19:17 UTC
verified in the trunk build 200804041203 with additional jar (org-netbeans-modules-cnd-makeproject.jar)
Comment 14 Thomas Preisler 2008-04-05 02:59:37 UTC
Pushed to release61
Comment 15 Alexander Pepin 2008-04-09 14:08:37 UTC
verified in NB6.1RC1 (build 200804082140)