castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
424 stars 25 forks source link

Solargraph gets port "0" on VSCode start or when using "Solargraph: Restart Solargraph" command #48

Closed WToorenburghIntiveo closed 6 years ago

WToorenburghIntiveo commented 6 years ago
System, VSCode, and extension info

OS: Windows 10 Pro 1709 build 16299.402 VSCode Version: 1.22.2 Solargraph extension: 0.16.0 Possibly relevant extensions: Ruby extension: `rebornix.ruby` version 0.18.0 Chef Extension for Visual Studio Code `Pendrica.chef` version 0.6.4 Output of `solargraph -t` in VSCode integrated console: ```powershell PS C:\development\chefInfrastructure> solargraph -v 0.20.0 ``` Relevant settings: ```json // Ruby and Solargraph "solargraph.diagnostics": "rubocop", ``` Contents of `.solargraph.yml`: ```yml --- include: - "**/*.rb" exclude: - spec/**/* - test/**/* - doc/** - "**/*.md" domains: [] required: [] # plugins: # - runtime ```

All settings:

```json // Place your settings in this file to overwrite the default settings { // Common core "editor.tabSize": 2, "editor.renderWhitespace": "boundary", "editor.wordWrap": "on", "editor.mouseWheelZoom": true, "editor.wordBasedSuggestions": false, "editor.fontFamily": "'Roboto Mono', monospace", "editor.fontSize": 13, "window.zoomLevel": 0, "explorer.confirmDelete": false, "explorer.confirmDragAndDrop": false, "workbench.editor.closeOnFileDelete": false, "workbench.iconTheme": "vscode-icons", "extensions.autoUpdate": false, // VSIcons "vsicons.associations.files": [ { "icon": "config", "extensions": [".conf"] }, { "icon": "docker", "filenamesGlob": ["docker-compose**"] } ], "files.associations": { //"*.env": "ini", "dockerfile**": "dockerfile" }, // Markdown "markdown-toc.updateOnSave": true, // Ruby and Solargraph "solargraph.diagnostics": "rubocop", // Chef "rubocop.enable": false, //"rubocop.path": "C:\\Tools\\opscode\\chefdk\\bin\\cookstyle.bat", //"rubocop.configFile": ".rubocop.yml", "foodcritic.enable": false, // Git and source control "gitProjectManager.baseProjectsFolders": [ "c:/development" ], "git.path": "C:/Program Files/Git/bin/git.exe", "git.confirmSync": false, "git.defaultCloneDirectory": "c:/development", "git.enableCommitSigning": true, "git.autofetch": true, "gitlens.advanced.messages": { "suppressCommitHasNoPreviousCommitWarning": false, "suppressCommitNotFoundWarning": false, "suppressFileNotUnderSourceControlWarning": false, "suppressGitVersionWarning": false, "suppressLineUncommittedWarning": false, "suppressNoRepositoryWarning": false, "suppressResultsExplorerNotice": false, "suppressShowKeyBindingsNotice": true }, // PHP "php.validate.executablePath": "C:\\Tools\\php-7.0.27\\php.exe", "php.executablePath": "C:\\Tools\\php-7.0.27\\php.exe", "php.suggest.basic": false, // Powershell and terminal "powershell.codeFormatting.preset": "OTBS", "powershell.integratedConsole.focusConsoleOnExecute": false, "terminal.external.windowsExec": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" } ```

All extensions:

```text >code --list-extensions AlanWalk.markdown-toc bierner.markdown-preview-github-styles castwide.solargraph DavidAnson.vscode-markdownlint donjayamanne.githistory DotJoshJohnson.xml eamodio.gitlens felipecaputo.git-project-manager felixfbecker.php-intellisense formulahendry.code-runner GrapeCity.gc-excelviewer hangxingliu.vscode-nginx-conf-hint humao.rest-client irvinlim.language-modsecurity le0zh.vscode-regexp-preivew mechatroner.rainbow-csv mikestead.dotenv ms-vscode.PowerShell Pendrica.chef PeterJausovec.vscode-docker RandomChance.logstash rebornix.Ruby ria.elastic robertohuertasm.vscode-icons Shan.code-settings-sync shanoor.vscode-nginx tuxtina.json2yaml ziyasal.vscode-open-in-github ```


Hey there,

I can't say exactly when this started happening, but the Solargraph gem has started launching listening on port 0, and so is not functioning at all in VSCode, except for the documentation search feature. By not functioning, I mean there is no auto-complete, Ctrl + Space returns a No suggestions message, and linting (using Rubocop) is not running.

In the dev console, it shows the gem having launched successfully, and reports the correct PID. It also shows the port at what the gem should be running on.

This is what Process Explorer says about the running ruby instance: solargraph-port0

This is the output of the dev console in VSCode during launch: solargraph-vscode-launch

I'm not too sure how to troubleshoot this further, so please let me know if there's any additional information I can pass on to you!

castwide commented 6 years ago

The --port 0 argument in the command line is normal. It tells the process to run on the first available port it can find. The extension reads the Solargraph is listening message to identify the port for the client connection. This way, multiple instances of VSCode can run their own language servers without port conflicts.

For the completion problems:

For the RuboCop problem, try adding the following to your .solargraph.yml file:

reporters:
- rubocop

The diagnostics features are in the process of an update, and I neglected to document some of the changes. I'll put documentation on the roadmap.

WToorenburghIntiveo commented 6 years ago

Good to know about the argument! For some reason, I thought I had seen it have a port listed in the past. I verified that the server was listening on the port listed in VSCode using Process Explorer.

Adding the reporters setting seems to have Rubocop working!

If this helps, I tried comparing curl results between the server VSCode started, and one started manually using solargraph server: solargraph-server-responses

WToorenburghIntiveo commented 6 years ago

Right, so for whatever reason, when I tried to install the ruby-debug-ide and debase gems for doing debugging in VSCode, it broke Solargraph. It started throwing that Windows eventmachine compile issue. I reinstalled ruby, installed the debugging gems first, then installed eventmachine using the workaround, and installed Solargraph last. Things seem to work now, with snappy suggestions and linting. I'm really not sure where along the line my ruby install go so bunged up. Thanks for your time!