@@ -701,11 +701,18 @@ protected void launch(Builder contextBuilder) {
701701
702702 private void findAndApplyVenvCfg (Builder contextBuilder , String executable ) {
703703 Path binDir = Paths .get (executable ).getParent ();
704+ if (binDir == null ) {
705+ return ;
706+ }
704707 Path venvCfg = binDir .resolve (J_PYENVCFG );
705708 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 );
707714 if (!Files .exists (venvCfg )) {
708- return ; // not found
715+ return ;
709716 }
710717 }
711718 try (BufferedReader reader = Files .newBufferedReader (venvCfg )) {
@@ -718,11 +725,15 @@ private void findAndApplyVenvCfg(Builder contextBuilder, String executable) {
718725 String name = parts [0 ].trim ();
719726 if (name .equals ("home" )) {
720727 contextBuilder .option ("python.PythonHome" , parts [1 ].trim ());
728+ String sysPrefix = null ;
721729 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 );
726737 }
727738 break ;
728739 }
0 commit comments