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

few questions on using eclispe-solargraph on MAC OS on 2022-06 #21

Closed iamtennislover closed 1 year ago

iamtennislover commented 2 years ago

Hi, I have installed latest eclipse-solargraph and using generic project to run some ruby code and trying to debug but getting error as follows when I tried to run on debug:

Failed to start debugging
Cannot run program ""/usr/local/bin/readapt"": error=2, No such file or directory

I am able run the script by doing Run -> Run as -> Ruby Script.

My few questions (I am super new to ruby, but familiar with python/pydev):

Environment setup:

MACOS - 12.2.1 (21D62) - Montery

Eclipse IDE for Java Developers (includes Incubating components)

Version: 2022-06 (4.24.0)
Build id: 20220609-1112

Installation package:
  Ruby Solargraph   1.0.0.202202201746  io.github.pyvesb.eclipse_solargraph.feature.group   PyvesB

Terminal:
➜  ~ which readapt
/usr/local/bin/readapt
➜  ~ which solargraph
/usr/local/bin/solargraph
➜  ~ readapt --version
1.4.4
➜  ~ solargraph --version
0.45.0
➜  ~ which ruby
/usr/bin/ruby
➜  ~ ruby --version
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]
➜  ~

Eclipse -> Preference -> Solargraph
solargraph executable: /usr/local/bin/solargraph
readapt executable: /usr/local/bin/readapt
PyvesB commented 2 years ago

Hello @iamtennislover :wave:

Sorry for the delay in answering, I was on vacation end of June and early July.

Could you go to the plugin's preferences, and double check the value that is specified there for Readapt? The quotes around the path in the error message look fishy.

You can specify which files to include in the .solargraph.yml configuration file, but beyond that there is no direct way to specify directories as source.

Solargraph will use the default Ruby interpreter available in your shell. You can easily switch it using a manager like rbenv, but there is currently no way to change the interpreter from within the plugin directly.

spchamp commented 1 year ago

The quote marks might be from ReadaptDebugDelegate.launch - seen while working on a pull request

Ideally, quote marks may not be needed for argv0 in the command to the operating system exec() or however that's implemented on Windows platforms.

In the typical terminal emulator, and in some editors e.g Emacs, any shell command might be forwarded through the user's login shell. In Java - however it's been implemented in the lower layers of each Java runtime - at some point, the first arg in the call might be provided as argv0 to something like a UNIX exec() function in the operating system/kernel. What the operating system's exec function receives would generally be a string argv0 representing a literal filename, and an array of literal args, etc. There are variations on exec() that will search across a well-known path environment variable if argv0 is a relative filename, and so it all works out.

For the method being called - afaict called in LSP4E - called from ReadaptDebugDelegate, it looks like it might expect a literal argv0 as the first arg.

So with the additional quoting provided, the operating system might be searching for a file name with quote marks in the filename itself.

fwiw I was working on a patch that could incorporate this, when I noticed the additional quote marks. I'll forward a pull request once it might seem done & tested. The pull request would add some additional debugging for non-zero exit from a Ruby command launched from one of the shortcuts or debug tools

PyvesB commented 1 year ago

@iamtennislover could you please update to version 1.0.1 of the plugin? @spchamp's patch should hopefully fix your issue. Do let us know if you still bump into any problems.