Skip to content

Instantly share code, notes, and snippets.

@eivan
Last active August 21, 2024 00:40
Show Gist options
  • Save eivan/cab0b0a29eebd91d767ea6ad7448368e to your computer and use it in GitHub Desktop.
Save eivan/cab0b0a29eebd91d767ea6ad7448368e to your computer and use it in GitHub Desktop.
Macaulay2 on Windows 10 with X server and Emacs GUI

Macaulay2 for 'Linux subsystem for Windows', with GUI

Macaulay 2, M2 for short, currently is mainly developed for Linux distros. For most Windows distro-s, use Cygwin to get Linux bash and through that, M2 command to start Macaulay2. However, Windows 10 for developers and insider builds come with a new feature, "Linux subsystem for Windows".

See the following sections for the steps for installation of, firstly, the Linux subsystem then M2, followed by installing and setting up an X server with emacs coupled with M2.

Get 'bash' for Windows and M2:

1.) Get Ubuntu "bash" in cmd Install "Linux subsystem for Windows" with ubuntu.

Follow instructions: https://msdn.microsoft.com/en-us/commandline/wsl/install_guide

2.) Open Ubuntu bash.

Hit Start then type "bash", or open command prompt and type "bash".

3.) Install Macaulay 2 through bash.

Follow instructions: https://macaulay2.com/Downloads/GNU-Linux/Ubuntu/index.html Tip: use the command in bash "lsb_release -a" to retrieve your Ubuntu's version.

Run emacs GUI, coupled with M2:

Secondly, get X server running with emacs GUI

1.) install an X server

2.) Set display to X server:

bash:

export DISPLAY=:0

3.) Install Emacs with X support

bash:

sudo apt-get install emacs
emacs # to see if it brings up GUI

4.) set up M2 environment for emacs:

  • Run Macaulay2: bash> M2
  • Run the following in M2: setupEmacs()
  • exit() M2
  • bash> emacs
  • to run M2 in emacs, hit F12
  • create new file, type
R = QQ[x,y]
f = symmetricPower(2,vars R)
  • select line 1 or line 2, hit F11 and see what the M2 buffer does inside emacs!

TeXmacs with M2

To install TeXmacs, run the following commands in bash:

#cd
#wget http://mirrors.kernel.org/ubuntu/pool/universe/t/texmacs-extra-fonts/texmacs-extra-fonts_0.2_all.deb
#wget http://mirrors.kernel.org/ubuntu/pool/universe/t/texmacs/texmacs-common_1.0.7.18-1_all.deb
#wget http://mirrors.kernel.org/ubuntu/pool/universe/t/texmacs/texmacs_1.0.7.18-1_amd64.deb
#sudo dpkg -i texmacs*.deb
#sudo apt-get install -f

!!! Follow instructions here in stead: https://software.opensuse.org/download.html?project=home:slowphil:texmacs-devel&package=texmacs

Tips and tricks

  • To run M2 directly from windows cmd, passing all commandline arguments, create a file 'M2.bat' with the following content:
@echo off
bash -l -c "M2 -q %*"

(Make sure it's accessible in windows PATH.)

  • To run TeXmacs directly from windows cmd, as previously create a file 'texmacs.bat', with the following content:
@echo off
bash -l -c "export DISPLAY=:0 && texmacs %*"

(Make sure Xming is up and running!)

Sources:

@kschwede
Copy link

Adding firefox is nice, since then it lets you
viewHelp
in Macaulay2.

@bellafinkel
Copy link

It looks to me that the link in 3.) Install Macaulay 2 through bash is depreciated.

@eivan
Copy link
Author

eivan commented Apr 11, 2024

It looks to me that the link in 3.) Install Macaulay 2 through bash is depreciated.

Thank you, I updated the link according to the new domain (macaulay2.com), and two other links to sources below.
If you think this guide needs an improvement, feel free to suggest one or provide a fork to it.

@jesusmartinez-garcia
Copy link

Everything went well apart from pressing F12 on emacs. It opens M2 but it doesn't do what I have typed. Maybe I am not getting what "select line" means. Is it just staying on the line? If not, how can I "select"? Thanks.

@Jazengm
Copy link

Jazengm commented Aug 21, 2024

Everything went well apart from pressing F12 on emacs. It opens M2 but it doesn't do what I have typed. Maybe I am not getting what "select line" means. Is it just staying on the line? If not, how can I "select"? Thanks.

Perhaps your buffer is not in the correct mode. You may try with a new file with a .m2 suffix. I think "select line" simply means putting your cursor on that line. Your buffer should be in Macaulay2 mode if you are opening a .m2 file, and under this mode F11 is bound to M2-send-to-program, which sends the current line to Macaulay2. To be honest, I think the documentation doesn't explain it clearly, it should at least point out the correct suffix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment