Opened 7 weeks ago

#28648 new defect

env var _JAVA_OPTIONS breaks plotting and building docs

Reported by: schilly Owned by:
Priority: major Milestone: sage-9.0
Component: interfaces Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

On CoCalc, we configure JAVA with a _JAVA_OPTIONS env variable. When running java -version it is reported as

Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/... -Xms64m
... usual info ...

before spitting out the version.

This causes 3d plots not to show up and the documentation can't be created.

This little change helped

diff --git a/src/sage/interfaces/jmoldata.py b/src/sage/interfaces/jmoldata.py   
index 8f291fb954..568678f6c8 100644
--- a/src/sage/interfaces/jmoldata.py                                                                             
+++ b/src/sage/interfaces/jmoldata.py                                                                             
@@ -63,13 +63,15 @@ class JmolData(SageObject):                                                                   
             <... 'bool'>                                                                                         
         """                                                                                                      
         try:                                                                                                     
-            version = bytes_to_str(subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT))      
+            output = bytes_to_str(subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT))       
+            # JAVA might output info about an env var it picks up before the version number, e.g.                
+            # "Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/... -Xms64m\n..."                                      
+            vers_str = re.search(r'.*version \"(0\.|1\.)?(\d*)[\s\S]*', output).group(2)                         
+            java_version_number = int(vers_str)                                                                  
+            return java_version_number >= 7                                                                      
         except (subprocess.CalledProcessError, OSError):                                                         
             return False                                                                                         
                                                                                                                  
-        java_version_number = int(re.sub(r'.*version "(0\.|1\.)?(\d*)[\s\S]*', r'\2', version))                  
-        return java_version_number >= 7                                                                          
-                                                                                                                 
                                                                                          

Change History (0)

Note: See TracTickets for help on using tickets.