szermatt / mistty

Shell/Comint alternative with a fully functional terminal for Emacs 29.1 and later.
GNU General Public License v3.0
92 stars 5 forks source link

nix emacsPackages.mistty doesn't work: broken .elc #14

Closed 573 closed 10 months ago

573 commented 10 months ago

I was not able to reproduce the logging for this bug as there is no *mistty* buffer to begin with (*mistty-log*):

[Messages] 0.000 Log enabled.

This is what the *Messages* buffer shows when M-x mistty:

command-execute: Symbol’s value as variable is void: mistty-mode-map

szermatt commented 10 months ago

It looks like mistty.el was not fully loaded; mistty-mode-map is defined right there, by defvar-keymap. Did you get errors in the *Messages* buffer when first loading or requiring it, even before running the command?

What version of Emacs are you using? How did you install mistty? What version of mistty did you install?

573 commented 10 months ago

*Messages* after fresh run and M-x mistty no requiring done:

Loading /nix/store/hw18wnrl8rpwlaq3yy62y6a8j75h9wd7-emacs-unstable-29.1.90-nox/share/emacs/site-lisp/site-start.el (source)...done Warning: setting attribute ‘:background’ of face ‘org-priority’: nil value is invalid, use ‘unspecified’ instead. Deft initializing... Deft loaded 144 files. Warning: setting attribute ‘:background’ of face ‘org-priority’: nil value is invalid, use ‘unspecified’ instead. For information about GNU Emacs and the GNU system, type C-h C-a. Warning: setting attribute ‘:background’ of face ‘org-priority’: nil value is invalid, use ‘unspecified’ instead. Quit command-execute: Symbol’s value as variable is void: mistty-mode-map Making completion list...

It is /nix/store/2wvd5g28r5crp987b15r49ldcgbxmhxp-emacs-unstable-with-packages-29.1.90-nox/bin/emacs. mistty installed via nix. In my site-isp there is mistty-20231016.1730:

1 2 3 4 /nix/store/5xyi7l9xnjfy6rbv0b4qrs4b61l25ckw-emacs-packages-deps/share/emacs/site-lisp/elpa/mistty-20231016.1730 󰈔 dir@ 󰈔 mistty-autoloads.el@ 󰈔 mistty-changeset.el@ 󰈔 mistty-changeset.elc@ 󰈔 mistty-log.el@ 󰈔 mistty-log.elc@ 󰈔 mistty-osc7.el@ 󰈔 mistty-osc7.elc@ 󰈔 mistty-pkg.el@ 󰈔 mistty-project.el@ 󰈔 mistty-project.elc@ 󰈔 mistty-queue.el@ 󰈔 mistty-queue.elc@ 󰈔 mistty-term.el@ 󰈔 mistty-term.elc@ 󰈔 mistty-undo.el@ 󰈔 mistty-undo.elc@ 󰈔 mistty-util.el@ 󰈔 mistty-util.elc@ 󰈔 mistty.el@ 󰈔 mistty.elc@ 󰈔 mistty.info@

szermatt commented 10 months ago

You seem to be using a pretest version of Emacs (29.1.90). Maybe there's a bug or maybe something has changed with defvar-keymap. I'll try it out.

Does it work with the stable version of Emacs, 29.1?

szermatt commented 10 months ago

I understand what’s happening now.

The problem comes from emacsPackage.mistty. The *.elc files it contains were compiled for Emacs 28, which doesn’t support the new keymap definition macros mistty uses. This is why it breaks complaining about the missing keymap.

I’d sugest not using that package at all and downloading from melpa, as described in the documentation. This will ensure that the .elc are compiled by the current version of emacs. If you’d like to stick to one specific git version of mistty, you could also download it directly from git using straight.el

Something’s not right with nix emacsPackages. If they’re going to contain *.elc files, they need to be tied to one specific version of Emacs.

adisbladis commented 10 months ago

It's true that emacsPackages.mistty (really an alias for emacs.pkgs.mistty) is built against emacs 28. Nixpkgs has emacs packages for many emacs versions, and emacsPackages is just a "default set".

You can explicitly choose emacs29.pkgs.mistty.

What users should generally do is some variant using withPackages: emacs29.pkgs.withPackages(epkgs: [ epkgs.mistty ]) which ensures a coherently built emacs including all it's packages.

That is to say, the .elc's are tied to exactly one emacs, but nixpkgs has many emacs variants.

573 commented 10 months ago

Thanks for the clarification @adisbladis I see a bit more now again.

The original error persists with the more precise approach (see warning below mistty-project.el:46:23: Warning: the function `mistty' is not known to be defined.): :u (inputs.nixpkgs.legacyPackages.x86_64-linux.emacs29-nox.pkgs.withPackages(epkgs: [ epkgs.mistty ])):

@nix { "action": "setPhase", "phase": "unpackPhase" } unpacking sources unpacking source archive /nix/store/saa7yi68h8jy9a4hxng7zzhiji9lrqic-source source root is source @nix { "action": "setPhase", "phase": "patchPhase" } patching sources @nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" } updateAutotoolsGnuConfigScriptsPhase @nix { "action": "setPhase", "phase": "configurePhase" } configuring no configure script, doing nothing @nix { "action": "setPhase", "phase": "buildPhase" } building Copying files (->) and directories (=>) from /build/working/mistty/ to /build/misttydXCWbp/mistty-20231016.1730 mistty-changeset.el -> mistty-changeset.el mistty-log.el -> mistty-log.el mistty-osc7.el -> mistty-osc7.el mistty-project.el -> mistty-project.el mistty-queue.el -> mistty-queue.el mistty-term.el -> mistty-term.el mistty-undo.el -> mistty-undo.el mistty-util.el -> mistty-util.el mistty.el -> mistty.el mistty.texi -> mistty.texi Generating /build/misttydXCWbp/mistty-20231016.1730/mistty.info Created mistty-20231016.1730.tar containing: mistty-20231016.1730/ mistty-20231016.1730/dir mistty-20231016.1730/mistty-changeset.el mistty-20231016.1730/mistty-log.el mistty-20231016.1730/mistty-osc7.el mistty-20231016.1730/mistty-pkg.el mistty-20231016.1730/mistty-project.el mistty-20231016.1730/mistty-queue.el mistty-20231016.1730/mistty-term.el mistty-20231016.1730/mistty-undo.el mistty-20231016.1730/mistty-util.el mistty-20231016.1730/mistty.el mistty-20231016.1730/mistty.info @nix { "action": "setPhase", "phase": "installPhase" } installing Parsing tar file... Parsing tar file...done Parsing tar file... Parsing tar file...done Extracting... \ Extracting...done INFO Scraping files for loaddefs... INFO Scraping files for loaddefs...done GEN mistty-autoloads.el Checking /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-autoloads.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-changeset.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-log.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-osc7.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-pkg.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-project.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-queue.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-term.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-undo.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty-util.el... Compiling /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730/share/emacs/site-lisp/elpa/mistty-20231016.1730/mistty.el... Done (Total of 9 files compiled, 2 skipped) Parsing tar file... Parsing tar file...done

In end of data: mistty-project.el:46:23: Warning: the function `mistty' is not known to be defined. @nix { "action": "setPhase", "phase": "fixupPhase" } post-installation fixup shrinking RPATHs of ELF executables and libraries in /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730 checking for references to /build/ in /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730... patching script interpreter paths in /nix/store/c4dia09kb8va1ajmmjqx9szn2mdpzgji-emacs-mistty-20231016.1730

573 commented 10 months ago

Same error (build warning) when:

nix-repl> :lf github:nix-community/emacs-overlay nix-repl> :u (packages.x86_64-linux.emacs-unstable-nox.pkgs.withPackages(epkgs: [epkgs.mistty]))

573 commented 10 months ago

Workaround, be careful if ~/.emacs.d does contain no important stuff:

rm ~/.emacs.d/* -rf
rm ~/.emacs.d/ -rf

Then above works.