felipeochoa / rjsx-mode

A JSX major mode for Emacs
https://github.com/felipeochoa/rjsx-mode
MIT License
641 stars 32 forks source link

Problem using the newest rjsx-mode #120

Closed steinarb closed 4 years ago

steinarb commented 5 years ago

I installed the newest rjsx-mode from melpa 20190614.2215 in emacs 26.1 on ubuntu 16.04.

However, no syntax highlighting happens and the following is written to the minibuffer

Error running timer ‘js2-mode-idle-reparse’: (error "js2-node-pos accessing a non-js2-node")

The js2-mode installed is also from melpa and is 20190815.1327.

Is the version of js2-mode the problem? Which version should I use?

felipeochoa commented 5 years ago

There was probably a breaking change in js2-node somewhere. I'm on 20190229 so somewhere between those two it broke.

steinarb commented 5 years ago

I got the same error in an attempted rebuild from the tag 20190229 in the repo https://github.com/mooz/js2-mode (not sure if it is the right repo, but it was the one that came up first in google).

Here is what I did:

  1. Clone the repo
    cd ~/git/
    git clone https://github.com/mooz/js2-mode.git
  2. Switch to a branch from the 20190219 tag (there was no 20190229 tag)
    cd ~/git/js2-mode/
    git checkout -b release/20190219 20190219
  3. Create a directory for the elpa package and copy all of the .el files there
    mkdir -p /tmp/js2-mode-20190219
    cp ~/git/js2-mode/*.el /tmp/js2-mode-20190219/
  4. Add a file /tmp/js2-mode-20190219/js2-mode-pkg.el with the following contents
    (define-package
      "js2-mode"
      "20190219"
      "Improved JavaScript editing mode for GNU Emacs")
  5. tar the directory
    cd /tmp/
    tar cvf js2-mode-20190219.tar js2-mode-20190219/
  6. Use package-install-file to install the file /tmp/js2-mode-20190219.tar
  7. Manually remove the ~/.emacs.d/elpa/js2-mode-20190815.1327 directory

According to locate-library, js2-mode is fetched from the new package: Library is file ~/.emacs.d/elpa/js2-mode-20190219/js2-mode.elc

(But as I said I don't know the relationship between the tag 20190219 and the 20190229 melpa package)

steinarb commented 5 years ago

I tried getting some info on this problem, but so far without any success:

  1. I tried setting (setq debug-on-error t) in .emacs to get a stack trace from the error.
  2. I haven't found the error message in neither the js2-mode source, nor the rjsx-mode source
  3. The menu-bar-update-hook only contains (menu-bar-update-buffers)

    menu-bar-update-hook is a variable defined in ‘C source code’.
    Its value is (menu-bar-update-buffers)
    
      This variable may be risky if used as a file-local variable.
    
    Documentation:
    Normal hook run to update the menu bar definitions.
    Redisplay runs this hook before it redisplays the menu bar.
    This is used to update menus such as Buffers, whose contents depend on
    various data.
steinarb commented 5 years ago

One more datapoint: the problem only occurs in a .js or .jsx file that actually uses jsx syntax.

Files with only javascript get no error message and syntax highlighting. Removing all HTML-ish tags from a component definition causes the file to be syntax highlighted.

steinarb commented 4 years ago

What I did was replacing the emacs 24 that was native of ubuntu 16.04 with emacs 26 for ubuntu.

Then I tried to let package-list-pacakages updated all of the packages it wanted to upgrade and remove all of the packages it wanted to delete. And at the end of that I ended up in the state that caused me to create this issue.

What I did to fix this/workaround the issue was to delete the ~/emacs.d/elpa/ directory and then start from scratch installing the packages I needed, from stable sources (gnu and melpa stable) if possible.

I ended up with v0.4.0 (not sure from where, I thought it was melpa stable, but melpa stable now has 20190614.2215) and now it works.

I guess this can be written down as a user error, and the lesson is: don't keep the ~/.emacs.d/elpa/ directory when bumping emacs two major versions.