castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
425 stars 23 forks source link

Unable to start solargraph #74

Closed Mathiou04 closed 5 years ago

Mathiou04 commented 6 years ago

OS: macOS 10.11.5 ruby: 2.2.3 (set by rbenv) solargraph gem: 0.25.0 vscode: 1.26.1 Ruby Solargraph: 0.17.6

When loading a ruby file in vscode, there is a popup message at the bottom right: Failed to start Solargraph:.

solargraph socket gives Solargraph is listening PORT=7658 PID=6749

In the console, there is no message but the end of the stack: t.onDidNotificationChange @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:2386

I had my hosts file overriding the 127.0.0.1 but removed it, restarted the laptop and it didn't solve the issue.

castwide commented 6 years ago

Are you starting VS Code in a workspace (i.e., opening a folder) or opening the Ruby file standalone?

ianks commented 6 years ago

@castwide same issue happens with me. it's when opening a workspace.

castwide commented 6 years ago

@ianks Are you using rvm or rbenv? If so, is the solargraph gem installed on whatever version of Ruby the workspace is configured to use? vscode-solargraph will attempt to use the configured version, such as the one specified by the .ruby-version file in your workspace, instead of the system Ruby.

landoncope commented 6 years ago

Same with me. When opening a workspace. I'm using rbenv and I have the correct gem installed. It does eventually load after a few minutes of 100% cpu usage.

castwide commented 6 years ago

@landoncope That sounds like it's running correctly other than taking an inordinately long time to initialize.

Are you using the most recent version of the gem?

How large is your workspace? e.g., number of files, lines of code, etc.

You might be able to reduce the initialization time by excluding files that don't need to be mapped. The default configuration, for example, excludes spec, test, and vendor directories. Run solargraph config to generate a .solargraph.yml file with the default settings.

ianks commented 6 years ago

I’m using rbenv which is set in the .ruby-version as well as the global default. i’ve instructed both vscode-ruby and solargraph-vscode to useBundler, with solar graph added to the gem file. Vscode is configured to use ZSH.

i don’t see any solar graph output in the debug log, and the error message does not give any useful output. both of those things would help a ton 😄

castwide commented 5 years ago

Version 0.18.0 might fix this issue. It changes how the extension starts processes under zsh.

pradosh987 commented 5 years ago

I am using version 0.18.0 with zsh shell on Mac and having same problem. VS code says "Starting the Solargraph language server" and it stays there forever. No change in CPU or ram usage.

I did used Solargraph few days back (like 2 weeks) and it worked correctly. I was trying out other ruby extensions so I deleted it and now it's not working after reinstalling.

castwide commented 5 years ago

@pradosh987 Some things that might help:

  1. Make sure you're running the latest version of the gem (0.29.4.).
  2. Check the developer console (Help -> Toggle Developer Tools) for error messages.
  3. Try setting solargraph.commandPath to the absolute path of the solargraph executable. (My goal is to make this step unnecessary in most cases, but if nothing else works, it should bypass problems with the shell.)
pradosh987 commented 5 years ago

Thanks @castwide It kind of worked. If I specify commandPath and install Solargraph gem in default gemset then everything works. Problem seems to be with bundler and zsh. Does this mean Solargraph will only detected gems installed in default gemset and the actual gemset used for rails development is ignored? Below is my logs.

INFO no standard startup: not just one text editor
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] vscode-icons is active!
workbench.main.js:sourcemap:294 [Extension Host] zsh:1: command not found: bundle
charltona commented 5 years ago

I hit so many issues while trying to install solargraph on Windows 10 - jumping through multiple threads. I thought maybe I'd combine everything I did here to help share.

Disclosure: I'm new to Ruby and VSCode. (looking forward to using squib!)

gem install solargraph initially failed because MSYS was not installed. I could not run MSYS because my PowerShell had restricted Security policy.

Set-ExecutionPolicy Unrestricted fixed this. (yes, probably not safe) I was then able to run ridk install The update to MSYS failed due to libcats being in conflict.

So in the MSYS console that was freshly installed I ran pacman -Syu manually which allowed me to remove and install the update AND the development toolchain

Finally, I was able to go back and complete gem install solargraph

Restarting VSCode I now had issues with eventmachine so I ran gem uninstall eventmachine gem install eventmachine --platform ruby

Restart VSCode Finally get a Solargraph is listening PORT=63981 PID=3188

I don't know if this will help any or if its relevant to this thread but this is the first result that comes up in google and would have saved me 3hrs - hope it saves someone else.

☮️

castwide commented 5 years ago

@charltona Thanks for the information. I haven't run into the MSYS policy issue myself, but I did run into another permission issue that I could only resolve by uninstalling and reinstalling Ruby. I also still needed to install eventmachine with gem install eventmachine --platform ruby -- --use-system-libraries. For a while I've been wondering if I could replace eventmachine with something else, but I haven't found an alternative besides rolling my own.

castwide commented 5 years ago

Welp, I rolled my own.

Solargraph will start using Backport for language server transports. This should eliminate the hassles with installing EventMachine on Windows.

More information: castwide/solargraph#118

shawnkoh commented 5 years ago

@pradosh987 Some things that might help:

  1. Make sure you're running the latest version of the gem (0.29.4.).
  2. Check the developer console (Help -> Toggle Developer Tools) for error messages.
  3. Try setting solargraph.commandPath to the absolute path of the solargraph executable. (My goal is to make this step unnecessary in most cases, but if nothing else works, it should bypass problems with the shell.)

Hello, apologies if I did not provide enough info as I am incredibly new to VSCode, Ruby, rails and etc; please let me know if you need more.

I'm experiencing the same issue as the OP: I'm running ruby 2.5.3 (rbenv), macOS Mojave 10.14.2, VSCode 1.30.1, Ruby Solargraph 0.19.0

I apologise but I'm not sure how to complete your step #3. Could you please advise how?

In the developer tools, these are the following errors

[Extension Host] Expanded command for shell /bin/bash Array(3)
console.ts:134 [Extension Host] /bin/bash: solargraph: command not found

console.ts:134 [Extension Host] Error starting socket provider /bin/bash: solargraph: command not found
castwide commented 5 years ago

@shawnkoh What happens when you run solargraph -v from a command line?

Make sure you gem install solargraph from the same Ruby version that you're running from VS Code. For example, if your project has a .ruby-version file, that version needs to have Solargraph installed.

As for #3, solargraph.commandPath is a configuration setting. On Mac, go to Code ->Preferences -> Settings. If you're able to run solargraph from a command line, you can try setting solargraph.commandPath to whatever path you get from running which solargraph.

lobsterkatie commented 3 years ago

In case it helps anyone else, I was still getting this error even after I'd installed solargraph, but restarting VSCode solved it.

haroldofurtado commented 3 years ago

Still having this kind of problem. Using OSX here.

vosmakov commented 2 years ago

after this

try setting solargraph.commandPath to whatever path you get from running which solargraph.

have another problem: 'find_spec_for_exe': can't find gem solargraph (>= 0.a) with executable solargraph (Gem::GemNotFoundException)

rpopovici commented 2 years ago

In my case I got this error: rbenv: cannot rehash: ~/.rbenv/shims/.rbenv-shim exists

I had to manually delete .rbenv-shim and then run again rbenv rehash in order to add solargraph to ~/.rbenv/shims/solargraph folder.