ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 27 Sep 2022 23:42:49 +0200temporary html files location in Sage 9.7https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/ With Ubuntu now using a snap version of Firefox there is a a problem with using the ThreeJS viewer with Firefox or Chrome in recent versions of Sage. Firefox can't access folders outside of a user's home folders nor even in hidden folders within the user's home folders. For Sage 9.6 it was possible to work around this by setting the environment variable DOT_SAGE to be a non-hidden folder, e.g., `export DOT_SAGE="~/Sage/sage-9.6/dotsage"` (on my PC Sage is installed in `~/Sage/sage-9.6`). If you use a non snap browser this isn't necessary, but I prefer to use the default browser with Ubuntu.
With Sage 9.7 just setting DOT_SAGE no longer works, since the output from `show(viewer="threejs")` is now saved to `/tmp/tmp<something>/<something>.html`. The html file is fine, just not accessible by Firefox. I've looked in the the Sage documentation and haven't found a way to set the output path for the html files. (I may just have not found it, but any guidance would be appreciated.)Tue, 27 Sep 2022 01:54:35 +0200https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/Answer by John Palmieri for <p>With Ubuntu now using a snap version of Firefox there is a a problem with using the ThreeJS viewer with Firefox or Chrome in recent versions of Sage. Firefox can't access folders outside of a user's home folders nor even in hidden folders within the user's home folders. For Sage 9.6 it was possible to work around this by setting the environment variable DOT_SAGE to be a non-hidden folder, e.g., <code>export DOT_SAGE="~/Sage/sage-9.6/dotsage"</code> (on my PC Sage is installed in <code>~/Sage/sage-9.6</code>). If you use a non snap browser this isn't necessary, but I prefer to use the default browser with Ubuntu.</p>
<p>With Sage 9.7 just setting DOT_SAGE no longer works, since the output from <code>show(viewer="threejs")</code> is now saved to <code>/tmp/tmp<something>/<something>.html</code>. The html file is fine, just not accessible by Firefox. I've looked in the the Sage documentation and haven't found a way to set the output path for the html files. (I may just have not found it, but any guidance would be appreciated.)</p>
https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/?answer=64206#post-id-64206You should be able to set the environment variable `TMPDIR` to manage this. You can test by running this within Sage:
sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/var/folders/00/zrss7sdj3bzd23f2_gnspy2h0000gp/T/tmpojijqa_h'>
That is the result if I don't set `TMPDIR`. If I first do `export TMPDIR=/Users/jpalmier/Desktop/temporary/` before starting Sage, then I see
sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/Users/jpalmier/Desktop/temporary/tmph25k47mi'>
I think this will only work if the directory already exists.Tue, 27 Sep 2022 21:06:09 +0200https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/?answer=64206#post-id-64206Comment by John Palmieri for <p>You should be able to set the environment variable <code>TMPDIR</code> to manage this. You can test by running this within Sage:</p>
<pre><code>sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/var/folders/00/zrss7sdj3bzd23f2_gnspy2h0000gp/T/tmpojijqa_h'>
</code></pre>
<p>That is the result if I don't set <code>TMPDIR</code>. If I first do <code>export TMPDIR=/Users/jpalmier/Desktop/temporary/</code> before starting Sage, then I see</p>
<pre><code>sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/Users/jpalmier/Desktop/temporary/tmph25k47mi'>
</code></pre>
<p>I think this will only work if the directory already exists.</p>
https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/?comment=64214#post-id-64214Thank you for the good question, and the solution should be documented somewhere. This is now being tracked at https://trac.sagemath.org/ticket/34593.Tue, 27 Sep 2022 23:42:49 +0200https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/?comment=64214#post-id-64214Comment by richardquint for <p>You should be able to set the environment variable <code>TMPDIR</code> to manage this. You can test by running this within Sage:</p>
<pre><code>sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/var/folders/00/zrss7sdj3bzd23f2_gnspy2h0000gp/T/tmpojijqa_h'>
</code></pre>
<p>That is the result if I don't set <code>TMPDIR</code>. If I first do <code>export TMPDIR=/Users/jpalmier/Desktop/temporary/</code> before starting Sage, then I see</p>
<pre><code>sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/Users/jpalmier/Desktop/temporary/tmph25k47mi'>
</code></pre>
<p>I think this will only work if the directory already exists.</p>
https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/?comment=64213#post-id-64213Thank you John.Tue, 27 Sep 2022 23:37:44 +0200https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/?comment=64213#post-id-64213Comment by eric_g for <p>You should be able to set the environment variable <code>TMPDIR</code> to manage this. You can test by running this within Sage:</p>
<pre><code>sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/var/folders/00/zrss7sdj3bzd23f2_gnspy2h0000gp/T/tmpojijqa_h'>
</code></pre>
<p>That is the result if I don't set <code>TMPDIR</code>. If I first do <code>export TMPDIR=/Users/jpalmier/Desktop/temporary/</code> before starting Sage, then I see</p>
<pre><code>sage: from sage.misc.temporary_file import TMP_DIR_FILENAME_BASE
sage: TMP_DIR_FILENAME_BASE
<TemporaryDirectory '/Users/jpalmier/Desktop/temporary/tmph25k47mi'>
</code></pre>
<p>I think this will only work if the directory already exists.</p>
https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/?comment=64207#post-id-64207Just checked that this solution works for threejs graphics: in a Sage 9.7 console, running
sage: sphere()
creates a html file under `TMP_DIR_FILENAME_BASE`.Tue, 27 Sep 2022 21:12:56 +0200https://ask.sagemath.org/question/64192/temporary-html-files-location-in-sage-97/?comment=64207#post-id-64207