2

I byte-compile my ~/.emacs.d/init.el. It was done by Emacs 26.1 from Cygwin and I got error when load emacs-nox 25.2 from Debian WSL:

error: Invalid byte opcode: op=183, ptr=2

Were new opcodes introduced into Emacs byte code starting from v26? For what purpose?

I have no issues to load byte compiled files between v22-v25...

gavenkoa
  • 3,352
  • 19
  • 36
  • 1
    Pretty much every major Emacs release breaks forward compatibility for .elc files, either by introducing new byte-codes (or macros whose expansion uses new functions). If you were able to use Emacs-25-compiled files under Emacs-22 you were just lucky. – Stefan Oct 15 '18 at 12:32

3 Answers3

6

A solution to this is to delete all compiled EmacsLisp files in the user's Emacs directory

cd ~/.emacs.d/
find . -name "*.elc" -type f 

Once you are satisfacted by what the find command returns (it should only return .elc files), delete them with the -delete option:

find . -name "*.elc" -type f -delete

Then restart Emacs and they will be regenerated when needed.

I added this as a function to my .bashrc because I honnestly use it all the time and I hate to have to search for the find syntax each time.

smonff
  • 1,575
  • 1
  • 15
  • 20
3

From NEWS:

* Incompatible Lisp Changes in Emacs 26.1
[...]
** Certain cond/pcase/cl-case forms are now compiled using a faster jump
table implementation.  This uses a new bytecode op 'switch', which
isn't compatible with previous Emacs versions.  This functionality can
be disabled by setting 'byte-compile-cond-use-jump-table' to nil.
npostavs
  • 9,033
  • 1
  • 21
  • 53
2

One way to handle this is to have dedicated package directories for each Emacs version. You can do this by placing the following in your init file:

(setq package-user-dir (concat "~/.emacs.d/elpa/" emacs-version))
Lindydancer
  • 6,095
  • 1
  • 13
  • 25