I was having an exchange on this issue with Marc Culler, the maintainer of the 3-manifolds binary release of SageMath-9.7 for macOS. (FYI: https://github.com/3-manifolds/Sage_macOS/issues/48)
He confirmed that there has been some reorganization in the way environment variables are set so that the SageMath app launches with a minimal environment. But this should in principle not impair launching a sage session.
The problem rather seems to be that TeXmacs, i.e. tm_sage.py
is not correctly initializing its environment. This is made more complicated by the fact that TeXmacs is using python 2.7 internally, even though the plugins only support python 3 sessions. (tm_sage.py
's shebang is: #! /usr/bin/env python
which gives python 2.7 on macOS.)
This is very all very confusing and seems to be a serious issue that needs to be addressed. @pireddag, @jeroen, @darcy, do you think I should file a bug report?
As a work-around which sets the two environment variables to their expected values Marc emailed a patch to tm_sage.py
:
--- tm_sage.py.orig 2022-11-20 17:49:33
+++ tm_sage.py 2022-11-21 08:04:38
@@ -13,6 +13,8 @@
import os
import sys
from os.path import exists
+os.environ["TEXMACS_HOME_PATH"] = os.path.join(os.environ["HOME"], ".TeXmacs")
+os.environ["TEXMACS_PATH"] = "/Applications/TeXmacs.app/Contents/Resources/share/TeXmacs"
tmpy_home_path = os.environ.get("TEXMACS_HOME_PATH") + "/plugins/tmpy"
if (exists (tmpy_home_path)):
sys.path.append(os.environ.get("TEXMACS_HOME_PATH") + "/plugins/")
He is fully aware of its limitations, but at least SageMath-9-7 is launching in a TeXmacs session now.
Cheers
Tilda