Ask Your Question

Revision history [back]

I can reproduce with - SageMath 9.8 from conda-forge in Ubuntu 22.04. - Firefox installed as a "snap"

Arguably the problem is from Firefox rather than SageMath, as

  • SageMath saves the image to some html file in /tmp
  • Firefox installed as a snap refuses to open files in /tmp

Two ways around this

  • either reinstall Firefox not as a snap, which might help according to:
  • or use a workaround: manually save 3d graphics to html file, then open that file in a browser.

Example.

My Firefox is installed using apt install firefox, which installed it as a "snap":

$ dpkg-query --list firefox
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version           Architecture Description
+++-==============-=================-============-==============================================
ii  firefox        1:1snap1-0ubuntu2 amd64        Transitional package - firefox -> firefox snap

Version of Sage and Python:

sage: print("{}, Python {}.{}.{}".format(version(), *sys.version_info[:3]))
SageMath version 9.8, Release Date: 2023-02-11, Python 3.10.8

Declare "symbolic ring" variables:

sage: x, y = SR.var('x, y')

Define 3d plot:

sage: p = plot3d(x*y^3, (-1, 1), (-1, 1))

Try to view:

sage: p

For me this launches a Firefox tab which tries to access a temporary file and complains:

File not found

Firefox can’t find the file at /tmp/tmp58e2me0a/tmp_68ciixtz.html.

  • Check the file name for capitalization or other typing errors.
  • Check to see if the file was moved, renamed or deleted.

The problem seems to be that Firefox installed as a "snap" refuses to open local files in /tmp.

Save the plot to an html file and open that file:

sage: p.save("myplot.html")
sage: !open myplot.html

That works well for me.

I can reproduce with - with

  • SageMath 9.8 from conda-forge in Ubuntu 22.04. - 22.04
  • Firefox installed as a "snap"

    Arguably the problem is from Firefox rather than SageMath, as

What happens is:

  • SageMath saves the image to some html file in /tmp then asks your browser to open it
  • Firefox installed as a snap refuses is set not to open files in /tmp

Two Three ways around thisthis (including the one suggested by @John Palmieri):

  • either reinstall Firefox not as a snap, "snap", which might help according to: help, see:
  • or use a workaround: run Sage with the TMPDIR environment variable set to some directory inside your home directory
  • or, as a workaround, manually save 3d graphics to html file, then open that file in a browser.obtained file in browser

Example.

My If Firefox is installed using apt install firefox, which it might have been installed it as a "snap":

$ dpkg-query --list firefox
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version           Architecture Description
+++-==============-=================-============-==============================================
ii  firefox        1:1snap1-0ubuntu2 amd64        Transitional package - firefox -> firefox snap

$ snap list | grep firefox
firefox              112.0.2-1                   2605   latest/stable/…  mozilla**       -

Version of Sage and Python:Here is what happens in that situation.

Start Sage:

sage: print("{}, Python {}.{}.{}".format(version(), *sys.version_info[:3]))
$ conda activate sage
$ sage
SageMath version 9.8, Release Date: 2023-02-11, released 2023-02-11. Python 3.10.8
3.10.8.

Declare "symbolic ring" variables:variables, define plot, and try to view it

sage: x, y = SR.var('x, y')

Define 3d plot:

sage: p = plot3d(x*y^3, (-1, 1), (-1, 1))

Try to view:

sage: p

For me this launches a Firefox tab which tries to access a temporary file and complains:

File not found

Firefox can’t find the file at /tmp/tmp58e2me0a/tmp_68ciixtz.html.

  • Check the file name for capitalization or other typing errors.
  • Check to see if the file was moved, renamed or deleted.

The problem seems to be is that Firefox installed as a "snap" refuses "snap" is set not to open local files in /tmp.

Save Things work if Sage starts with TMPDIR set to a subdirectory of the user's home directory.

I created a tmp directory in my home directory:

$ mkdir -p $HOME/tmp

Then things work if I start Sage with this command:

$ TMPDIR=$HOME/tmp sage

or with these two commands:

$ export TMPDIR=$HOME/tmp
$ sage

The "export" command can be included in a file that is run each time a shell is started. For example,~/.bashrc if using bash, or ~/.zshrc if using zsh.

If Sage was started without setting TMPDIR, we can save the plot to an html file and open that file:

sage: p.save("myplot.html")
sage: !open myplot.html

That works well for me.