-
Notifications
You must be signed in to change notification settings - Fork 909
Make sure netbeans in embedded terminal means itself #8756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
npb.getEnvironment().put("DYLD_LIBRARY_PATH", "");// NOI18N | ||
|
||
envVars.put("LD_LIBRARY_PATH", "");// NOI18N | ||
envVars.put("DYLD_LIBRARY_PATH", "");// NOI18N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- it was always clear to me I need to set an environment variable to represent the value of
--userdir
- otherwise the
CLIHandler
won't be able to connect to the same NetBeans process - originally I thought I will have to make changes here, but ...
then | ||
sh=/bin/bash | ||
fi | ||
NETBEANS_USERDIR=${userdir} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Store the value of
--userdir
to a system variable - so that child processes can pick it up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- any objections against this change?
- if no, then TODO:
- document the new environment variable
- modify
netbeans.exe
to behave the same
- let's have a time for inception review now
- I plan to get this change into NetBeans 28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favour of the general principle - in fact I use this feature with the DEB package quite a bit, and alternative userdir support there would be great.
I have a few reservations about the implementation. Our packaging tool works by wrapping the launcher in various ways to meet different OS requirements. Some will already have netbeans
in the path. We need to ensure that this works for standalone and installed usage. And I think we need to ensure JAVA_HOME
is set in the parent to be picked up in the child process.
|
No, the Windows launcher code is back in the main repository. It is built by the workflow at https://github.com/apache/netbeans/blob/master/.github/workflows/native-binary-build-launcher.yml When ready, the version numbers will need updating, binaries built from the workflow, and a release vote done - see #8408 and https://lists.apache.org/thread/491tvp6o44nj9wpmcpbdtcmt8rn0d9h8 EDIT : I'm currently -1 to the Have pinged @matthiasblaesing and @mbien for thoughts. Matthias also ran the last Windows launcher update and vote. |
I am somewhat mixed on this. On one hand I think that if a terminal behaves differently in the IDE it is essentially a bug (that is also why I think that the launcher should probably not export I am a bit worried about the can of worms this opens (why is javac, mvn, ant etc not in path too etc) and that it is set by default without opt-in or out. Maybe the solution is to store it in an env var and add a text field to the terminal settings where users can configure path extensions in the sense of I am wondering if
I agree, prepend would break existing user setups too, so if at all, it would have to be append IMO. (slightly related to this proposal would be: path selection -> right click -> open in NB or System for output and terminal as quality of life improvement) |
+1
I hadn't thought about setting an alias based on the environment variable, but that's a good idea. I think, set up something like But in the shorter term, the environment variable could still be invoked directly or used to set an alias manually. Having basedir in there too could allow for pointing aliases at some of those other things you mentioned, should people wish to. The launcher variable would need to be kept separate to the basedir, and only set if not already configured, so the various package scripts can use it to route through themselves.
Maybe. Some of the packages set |
914565a
to
ed6a3f7
Compare
Thank you for your review:
I'll wrestle with the |
793ee04
to
cc211d3
Compare
if (path != NULL) { | ||
string setPath = "PATH="; | ||
setPath = setPath + path + ";" + baseDir + "\\bin\\"; | ||
putenv(setPath.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested these changes with following program:
package execenv;
public class ExecEnv {
public static void main(String[] args) throws Exception {
System.out.println("Env: " + System.getenv("PATH"));
var p = new ProcessBuilder("netbeans", "S:\\readme.txt").start();
var r = p.waitFor();
System.out.println("Res: " + r);
}
}
when executed on NetBeans 27 it fails with:
run:
Env: C:\Program Files\OpenSSH\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Users\jst\AppData\Local\nvm;C:\nvm4w\nodejs;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Users\jst\.cargo\bin;C:\Users\jst\AppData\Local\Microsoft\WindowsApps;C:\Users\jst\AppData\Local\nvm;C:\nvm4w\nodejs;C:\Program Files\Git\bin;S:\windows\bin;S:\windows\bin\graalvm-community-openjdk-24.0.1+9.1\bin\;S:\windows\bin\sbt-1.7.2\bin\;
Exception in thread "main" java.io.IOException: Cannot run program "netbeans": CreateProcess error=2, The system cannot find the file specified
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1044)
at execenv.ExecEnv.main(ExecEnv.java:6)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.base/java.lang.ProcessImpl.create(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:485)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:146)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1076)
... 2 more
C:\Users\jst\AppData\Local\NetBeans\Cache\27\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\jst\AppData\Local\NetBeans\Cache\27\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 1 second)
With changes in this PR it properly opens the file in the IDE executing the script. Setting NETBEANS_USERDIR=IGNORE
opts-out and falls back to previous behavior.
Final steps in this PR:
|
756370d
to
79ea9c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks sane. I have left two inline comments.
The usability on windows is IMHO not good. I you run netbeans
under windows you get an error, because the script launcher is invoked as it is a 100% match:

You need to know, that you have to invoke the exe launcher, which (for me surprisingly works even though I have a 64bit JDK):

|
Personally, I don't see a reason to rush this to get it into NB28, which with the Windows launcher changes will be a hard push to do before freeze. It would be better to get this in early for NB29 for proper testing. The Windows changes here probably affect platform applications, but the Unix changes don't. That should probably be looked at to ensure aligned behaviour. The workflows shouldn't be showing waiting for approval - there's something awry with your account or the commit info here. |
d538afb
to
54edd84
Compare
|
Thanks!
Matthias made similar comments on the PR I linked to above - #8408 (comment) Short term, it's possibly better to align the behaviour on this for the platform as well anyway? ie. update the platform shell launcher rather than further changes in the Windows launcher. Could be just as useful for platform applications. Longer term if you're considering re-architecting, for info, there was some discussion on the NB Slack channel a while ago about the possibility of using a Java file launcher instead that could run either as single Java source or be native compiled. That's tangential to this PR obviously. |
netbeans pom.xml
in the embedded terminal would open the file in the IDE the terminal is embedded into--userdir
well