I have Sage Math 9.5, I guess coming from an apt I've once run or a .deb. But how to pass to the latest 10.3 version?

I don’t remember how I’ve installed SageMath once, when I did two years ago.

But I guess it was by an apt command, maybe sudo apt install sagemath-jupyter that gives the 9.5 version of SageMath to everyone, or by the mean of a .deb file.

Because, when I’m running this command:

locate sagemath | xargs -I {} dirname {} | grep -vF '/usr/share/doc/sagemath/' | sort | uniq

I see it dispatched into the next folders:


From here, I would like to follow "the same path" than other users, that look using 10.x versions.
In Example: the latest (10.3)

But it’s not easy to figure what to do. Especially with such mention:

As of Sage 10.2, we can recommend the following distributions, which provide well-maintained and up-to-date SageMath packages: Arch Linux and Void Linux.

Do you have an idea of how I should process to install the latest SageMath version?

Asked By: Marc Le Bihan


Debian 12 (the current stable release) and debian sid both contain sagemath 9.5, so you probably installed it the sensible way: apt install sagemath-jupyter. Nothing special to be done!

Sagemath sadly has a bit of a history of being a bit hard to package, and I remember fighting it multiple times in my career. I was quite happy to see debian packaged a very current version by now!

The fact that not even debian experimental tries to package Sagemath 10.2 can mean one of three things:

  1. nobody tried
  2. Somebody is working on it, but it still needs work, or simply time, because some part in debian needs to be updated before sagemath can be ported. You might have to enable experimental repos.
  3. somebody tried, but sagemath 10.2 requires dependencies that simply cannot be installed into a current debian

I think we’re in case 2, because there’s a 10.2 branch on salsa, so that there’s clearly people working on getting it to you!

So, here’s what needs to be done to get these packages:

# get things we'll need to build packages:
apt update
apt install git devscripts sudo

# get the source package of sagemath, i.e. what becomes the .deb
#         /-------------------------- use the branch that ports 10.2 to debian
#         |             /------------ also get the actual source code of sagemath, as well
#         v             v
git clone --branch 10.2 --recursive https://salsa.debian.org/science-team/sagemath.git
cd sagemath
# now to the actual package build:
# (1) install the tools we need to even install dependencies
debian/rules build-dep-maint
# (2) install dependencies
debian/rules build-dep
# (3) build the software to go into the package
debian/rules build
# (4) build the package
fakeroot debian/rules binary

Now, I’ve went ahead and tried this on current debian, and as predicted, it failed in (2), because libflint-dev is only available in version 2.9.5 yet, not as 3.0.0; removing that version requirement and trying to build with version 2.9.5 leads to a failed build. So, not on debian stable/12/bookworm! On debian testing/trixie, we get a libflint-dev that should be new enough. Try the above method on debian testin/trixie! (you could of course enable the trixie suite in your /etc/apt/apt.sources.list.d/debian.list, but hm, you end up with a mixed-installation debian, so that might not be in the interest of stability; it’s currently building in my debian:12 container with that method).

So, I think it’s kind of fair to say that there’s right now not really a debian-native way for debian bookwork; if you don’t shy away from unstable software, you can build things yourself. The same is true, yet, for (ana)conda: 10.2 is in the "staging" area, not quite ready for public consumption.

Long story short, if you can, wait. Sage 10.3 is being prepared; sage 10.2 currently builds on Frankestein’d stable/testing machines. For an end-user, this is an excellent time to let the dust settle.

If you want, however, to help getting the port done faster, do update your debian to debian trixie, (much wiser: install podman, and run a debian:testing container) and build sage from source as described above, install the resulting packages, and help the developers sort out any problems that arise. Both

Answered By: Marcus Müller
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.