PyvesB / eclipse-solargraph

:gem: Ruby development tools for Eclipse.
https://marketplace.eclipse.org/content/ruby-solargraph
Eclipse Public License 2.0
30 stars 6 forks source link

Unexpected token tLT #27

Closed amurashkin17 closed 2 years ago

amurashkin17 commented 2 years ago

In Eclipse, in any .erb file, at the first line containing <%, I see the following error message

unexpected token tLT (Using Ruby 3.1 parser; configure using TargetRubyVersion parameter, under AllCops)

For example, the error happens if .erb file has the line

<%# comment %>

The software versions

Below is the detailed history.

Installing Ruby Solargraph and running it the first time

I installed Ruby Solargraph from the Eclipse Marketplace. After restart, I got a popup window saying that some gems were not found, with two buttons (cannot recall exact button names). I selected button ?install gems locally?. The installation failed.

In the Eclipse error log, there was the following message

Unexpected exit value 1 from command [bash, -c, -l, gem install -V -n "/home/myuser/Workspace/Foreman/.metadata/.plugins/io.github.pyvesb.eclipse_solargraph" solargraph] Error details: WARNING: You don't have /home/myuser/Workspace/Foreman/.metadata/.plugins/io.github.pyvesb.eclipse_solargraph in your PATH, gem executables will not run. ERROR: Error installing solargraph: ERROR: Failed to build gem native extension.

current directory: /home/myuser/.local/share/gem/ruby/gems/jaro_winkler-1.5.4/ext/jaro_winkler

/usr/bin/ruby -I /usr/share/rubygems -r ./siteconf20221027-1203330-xdgxjs.rb extconf.rb Building has failed. See above output for more information on the failure. extconf failed, exit code 1

Gem files will remain installed in /home/myuser/.local/share/gem/ruby/gems/jaro_winkler-1.5.4 for inspection. Results logged to /home/myuser/.local/share/gem/ruby/extensions/x86_64-linux/3.1.0/jaro_winkler-1.5.4/gem_make.out

I checked Eclipse preferences, and saw there that solargraph and readapt paths were empty.

Installing gems via command line

In Linux shell, I ran as my user (home directory /home/myuser)

gem install solargraph gem install readapt

These commands failed because /usr/include/ruby.h file was missing. So I installed ruby-devel package (as root) and repeated gem install commands.

After it, in Eclipse, I set executable paths in Solagraph preferences

/home/myuser/.local/share/gem/ruby/gems/solargraph-0.47.2/bin/solargraph
/home/myuser/.local/share/gem/ruby/gems/readapt-1.4.4/exe/readapt

Configuring .rubocop.yml

Then I opened .erb file and I got the error

unexpected token tLT (Using Ruby 2.6 parser; configure using TargetRubyVersion parameter, under AllCops)

Note 2.6 (not 3.1). So I looked for .rubocop.yml and found it

/home/myuser/.local/share/gem/ruby/gems/solargraph-0.47.2/lib/.rubocop.yml

I added TargetRubyVersion in AllCops section

AllCops:
  NewCops: enable
  TargetRubyVersion: 3.1

and restarted Eclipse. After the restart the message still was the same - "Using Ruby 2.6 parser". So the language server did not use this file.

I created a symlink /home/myuser/.rubocop.yml pointing to /home/myuser/.local/share/gem/ruby/gems/solargraph-0.47.2/lib/.rubocop.yml. This time, after the Eclipse restart, the error message became "Using Ruby 3.1 parser".

Reinstalling Ruby Solargraph plugin

As the issue was not resolved, I attempted few more steps. I uninstalled Ruby Solargraph from Eclipse. Then I installed it again. After the restart, the error message was still there.

I checked the preferences, and the executable paths were still the same (as above).

There are no other errors in Eclipse error log.

How to troubleshoot?

The last thing that I did - I enabled "Troubleshoot Readapt debugger ..." option. But I have no idea where the log file is. Is it even going to be useful?

PyvesB commented 2 years ago

Hello @amurashkin17 👋🏻

Thanks for raising this issue. I think this boils down to the same problem as https://github.com/castwide/vscode-solargraph/issues/142. Essentially, the Solargraph language server does not support ERB, yet the Eclipse plugin is trying to send requests for ERB files. These end up failing with aforementioned Unexpected token tLT error.

I think I'll simply need to exclude ERB files from the plugin - however, I'd still expect syntax highlighting and basic editor functionality to work. :)