@@ -701,11 +701,18 @@ protected void launch(Builder contextBuilder) {
701
701
702
702
private void findAndApplyVenvCfg (Builder contextBuilder , String executable ) {
703
703
Path binDir = Paths .get (executable ).getParent ();
704
+ if (binDir == null ) {
705
+ return ;
706
+ }
704
707
Path venvCfg = binDir .resolve (J_PYENVCFG );
705
708
if (!Files .exists (venvCfg )) {
706
- venvCfg = binDir .getParent ().resolve (J_PYENVCFG );
709
+ Path binParent = binDir .getParent ();
710
+ if (binParent == null ) {
711
+ return ;
712
+ }
713
+ venvCfg = binParent .resolve (J_PYENVCFG );
707
714
if (!Files .exists (venvCfg )) {
708
- return ; // not found
715
+ return ;
709
716
}
710
717
}
711
718
try (BufferedReader reader = Files .newBufferedReader (venvCfg )) {
@@ -718,11 +725,15 @@ private void findAndApplyVenvCfg(Builder contextBuilder, String executable) {
718
725
String name = parts [0 ].trim ();
719
726
if (name .equals ("home" )) {
720
727
contextBuilder .option ("python.PythonHome" , parts [1 ].trim ());
728
+ String sysPrefix = null ;
721
729
try {
722
- contextBuilder .option ("python.SysPrefix" , venvCfg .getParent ().toAbsolutePath ().toString ());
723
- } catch (IOError ex ) {
724
- System .err .println ();
725
- throw abort ("Could not set the home according to the pyvenv.cfg file." , 65 );
730
+ sysPrefix = venvCfg .getParent ().toAbsolutePath ().toString ();
731
+ } catch (IOError | NullPointerException ex ) {
732
+ // NullPointerException covers the possible null result of getParent()
733
+ warn ("Could not set the sys.prefix according to the pyvenv.cfg file." );
734
+ }
735
+ if (sysPrefix != null ) {
736
+ contextBuilder .option ("python.SysPrefix" , sysPrefix );
726
737
}
727
738
break ;
728
739
}
0 commit comments