Macaulay2 in emacs issue

107 views
Skip to first unread message

KSchwede

unread,
May 17, 2022, 11:50:59 AM5/17/22
to Macaulay2
Hi all,
This is probably because I'm running something on a minimal vm in my department, but when our department pulled the latest version of M2 (1.20) on Ubuntu 20.04, and I tried running M2 via [F12] in emacs I get the following error at the bottom of my screen.

"Wrong type argument: commandp, M2"

Playing around in emacs lisp, it appears that emacs doesn't know about the M2 command.  Is there some missing package in this minimal ubuntu install?  

Where is the lisp script I should be loading in emacs typically?

Thanks!

Karl

Daniel R. Grayson

unread,
May 17, 2022, 5:23:16 PM5/17/22
to Macaulay2
Try running /usr/bin/M2 in a shell window, and then giving M2 the command "setup()" or "setupEmacs()".  That
will put a file in your home directory and add a line to your .emacs file that calls it.  The result will be that the various
needed functions get loaded and attached to keystroke sequence (the next time you start emacs).


KSchwede

unread,
May 18, 2022, 1:18:06 AM5/18/22
to Macaulay2
Hi Dan,

That's the first thing we tried.  We've executed M2 and run setup() in lots of different ways. 

Any other thoughts?

Karl

Doug Torrance

unread,
May 18, 2022, 3:27:26 PM5/18/22
to Macaulay2
How was Macaulay2 installed?  If it was using the PPA, then the Emacs files are in a separate package (elpa-macaulay2).  By default, it should be installed alongside macaulay2 and macaulay2-common, but not if apt isn't set up to install "Recommended" packages, which may be the case on a minimal system.

Doug

KSchwede

unread,
May 19, 2022, 11:07:43 AM5/19/22
to Macaulay2
Thanks!  Problem solved.  It turned out there were multiple versions of emacs running around.

Daniel R. Grayson

unread,
May 19, 2022, 11:10:19 AM5/19/22
to Macaulay2
So how did using the wrong version of emacs prevent it from working?  Was it a version of
emacs that doesn't even load the file ~/.emacs ?


Marcus Zibrowius

unread,
Oct 24, 2023, 10:55:47 AM10/24/23
to Macaulay2
I get this exact error message this issue (with M2 version 1.22) and emacs 29.1 *installed as a snap package*.  I can start both emacs by typing 'emacs' on the command line, and I can start M2 by typing 'M2' on the command line.  But when I press F12 in emacs, I get the error message mentioned by the OP: "Wrong type argument: commandp, M2".

I suspect the sandboxing of snap packages is preventing emacs from starting M2 in this context.  Is there any know workaround (besides installing a second, native version of emacs)?

Torrance, Douglas

unread,
Oct 24, 2023, 4:21:13 PM10/24/23
to maca...@googlegroups.com
Am I correct in assuming that you installed Macaulay2 1.22 using the PPA?

If so, then the first step is to make sure that the emacs package is installed correctly:

sudo apt install elpa-macaulay2

If that's fine but it's still not working, then my guess is it's an issue with the snap package not playing nicely with Ubuntu's emacs package ecosystem.

Hopefully, the snap package knows to look in your ~/.emacs file. Try adding the following to that:

(add-to-list 'load-path "/usr/share/emacs/site-lisp/elpa/macaulay2-1.22")

Marcus Zibrowius

unread,
Oct 25, 2023, 3:44:13 AM10/25/23
to maca...@googlegroups.com

Am I correct in assuming that you installed Macaulay2 1.22 using the PPA?

Yes, correct. Macaulay2 1.22 from the PPA on Ubuntu 20.04. And I'm using GNU Emacs 29.1.

If so, then the first step is to make sure that the emacs package is installed correctly:

sudo apt install elpa-macaulay2

This was already installed.

If that's fine but it's still not working, then my guess is it's an issue with the snap package not playing nicely with Ubuntu's emacs package ecosystem.

Hopefully, the snap package knows to look in your ~/.emacs file. 

Yes, the snap package definitely reads the ~/.emacs file. The only M2-related entries in there are:

(global-set-key [ f12 ] 'M2) 
(setq Info-hide-note-references 'hide)

Try adding the following to that:

(add-to-list 'load-path "/usr/share/emacs/site-lisp/elpa/macaulay2-1.22")

The path you mentioned doesn't exist on my system, I only have the following variation:

"/usr/share/emacs/site-lisp/elpa-src/macaulay2-1.22"

I tried adding your suggestion, and I also tried adding the above path that actually exists. This does not seem to have any effect.

With or without these changes, the situation is as follows. I can activate m2-mode in emacs (via M-x m2-mode), and I get the desired font coloring. I can also start a shell within emacs (M-x shell), and call M2 within that shell by simply typing "M2". The part that does not work is hitting F12 to start an interactive session. When I hit F12, I get the message

Marcus Zibrowius

unread,
Oct 25, 2023, 5:24:30 AM10/25/23
to maca...@googlegroups.com

Sorry for the trouble – I now got it to work. I needed to add the following two lines to my .emacs:

(add-to-list 'load-path "/usr/share/emacs/site-lisp/elpa-src/macaulay2-1.22")
(load "M2-init")

The line with "M2-init" is mentioned in the manual at

https://macaulay2.com/doc/Macaulay2-1.22/share/doc/Macaulay2/Macaulay2Doc/html/_setting_spup_spthe_sp__Macaulay2_spemacs_spinterface.html

However, this line is not/no longer created by the command

setupEmacs()

The file .emacs-Macaulay2 that setupEmacs() creates on my system contains only the lines

(global-set-key [ f12 ] 'M2) 
(setq Info-hide-note-references 'hide)

(and some comments), which I had already copied to my .emacs.

Anyway, thanks a lot for pointing me to the right location of the M2-init file!

Torrance, Douglas

unread,
Oct 25, 2023, 6:12:47 AM10/25/23
to maca...@googlegroups.com
Glad you got it figured out!

I think maybe I made a mistake when I modified the setupEmacs function in the PPA package and removed those things. They *should* be handled automatically when elpa-macaulay2 is installed, and this happens when the standard Ubuntu emacs package is installed, but apparently not with the snap package. I'll take a look -- thanks for bringing this to my attention!
Reply all
Reply to author
Forward
0 new messages