Skip to content

Commit

Permalink
sagemath#26968: workaround for an ecl race in maxima init
Browse files Browse the repository at this point in the history
When maxima is initialized a bug in ecl implementation of
`ensure-directories-exist` might result in a runtime error.

As a workaround, in case we get a runtime error we use python to create
the directory and continue with maxima initialization.

Note that for normal usage the directory will already exist within the
user's `DOT_SAGE` so this code will almost never run. However, when
running doctests on CI this occasionally triggers.
  • Loading branch information
tornaria committed Feb 21, 2023
1 parent 944f9bd commit b0bb05e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/sage/interfaces/maxima_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,19 @@
ecl_eval("(setq $nolabels t))")
ecl_eval("(defvar *MAXIMA-LANG-SUBDIR* NIL)")
ecl_eval("(set-locale-subdir)")
ecl_eval("(set-pathnames)")

try:
ecl_eval("(set-pathnames)")
except RuntimeError:
# Recover from :trac:`26968` by creating `*maxima-objdir*` here.
# This cannot be done before calling `(set-pathnames)` since
# `*maxima-objdir*` is computed there.
maxima_objdir = ecl_eval("*maxima-objdir*").python()[1:-1]
import os
os.makedirs(maxima_objdir, exist_ok=True)
# Call `(set-pathnames)` again to complete its job.
ecl_eval("(set-pathnames)")

ecl_eval("(defun add-lineinfo (x) x)")
ecl_eval('(defun principal nil (cond ($noprincipal (diverg)) ((not pcprntd) (merror "Divergent Integral"))))')
ecl_eval("(remprop 'mfactorial 'grind)") # don't use ! for factorials (#11539)
Expand Down

0 comments on commit b0bb05e

Please sign in to comment.