vscode-solargraph icon indicating copy to clipboard operation
vscode-solargraph copied to clipboard

[Windows] Multiple issues around Solargraph::YardMap::CoreDocs

Open hron84 opened this issue 6 years ago • 4 comments

I trying to use Ruby extension for VSCode on Windows 10 and it encouraged me to use SolarGraph to make the Language server working.

However I ran into multiple issues.

First, if I have a set HOMEDRIVE, SolarGraph tries to use this (even if it is disconnected) and fails to boot up if it cannot make its temporary directory. Instead doing this, I could see something that involves Windows user temp.

I get rid on this by setting SOLARGRAPH_CACHE environment variable to something existing and writable. Then it complains:

C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0/gems/solargraph-0.32.3/lib/solargraph/yard_map/core_docs.rb:44:in `join': no implicit conversion of nil into String (TypeError)
	from C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0/gems/solargraph-0.32.3/lib/solargraph/yard_map/core_docs.rb:44:in `valid?'
	from C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0/gems/solargraph-0.32.3/lib/solargraph/yard_map/core_docs.rb:115:in `yardoc_stdlib_file'
	from C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0/gems/solargraph-0.32.3/lib/solargraph/yard_map.rb:13:in `<class:YardMap>'
	from C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0/gems/solargraph-0.32.3/lib/solargraph/yard_map.rb:7:in `<module:Solargraph>'
	from C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0/gems/solargraph-0.32.3/lib/solargraph/yard_map.rb:3:in `<top (required)>'
	from C:/Users/20150/progs/ruby/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from C:/Users/20150/progs/ruby/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0/gems/solargraph-0.32.3/lib/solargraph.rb:52:in `<top (required)>'
	from C:/Users/20150/progs/ruby/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from C:/Users/20150/progs/ruby/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0/gems/solargraph-0.32.3/bin/solargraph:3:in `<top (required)>'
	from C:/Users/20150/progs/ruby/bin/solargraph:23:in `load'
	from C:/Users/20150/progs/ruby/bin/solargraph:23:in `<main>'

It seems like somehow ver becomes nil. Probably best_match function does not contain a nil-protection and silently passes nil if no matching version found. This is something that should be fixed soon.

 gem li -d solargraph

*** LOCAL GEMS ***

solargraph (0.32.3)
    Author: Fred Snyder
    Homepage: http://solargraph.org
    License: MIT
    Installed at: C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0

    A Ruby language server

λ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0
  - USER INSTALLATION DIRECTORY: C:/Users/20150/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: C:/Users/20150/progs/ruby/bin/ruby.exe
  - GIT EXECUTABLE: C:\Users\20150\progs\cmder\vendor\git-for-windows\cmd/git.EXE
  - EXECUTABLE DIRECTORY: C:/Users/20150/progs/ruby/bin
  - SPEC CACHE DIRECTORY: C:/Users/20150/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Users/20150/progs/ruby/lib/ruby/gems/2.6.0
     - C:/Users/20150/.gem/ruby/2.6.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "-N"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - C:\Users\20150\progs\cmder\bin
     - C:\Users\20150\progs\cmder\vendor\bin
     - C:\Users\20150\progs\cmder\vendor\conemu-maximus5\ConEmu\Scripts
     - C:\Users\20150\progs\cmder\vendor\conemu-maximus5
     - C:\Users\20150\progs\cmder\vendor\conemu-maximus5\ConEmu
     - C:\Program Files (x86)\Common Files\Oracle\Java\javapath
     - C:\WINDOWS\system32
     - C:\WINDOWS
     - C:\WINDOWS\System32\Wbem
     - C:\WINDOWS\System32\WindowsPowerShell\v1.0\
     - C:\WINDOWS\System32\OpenSSH\
     - C:\Program Files (x86)\Enterprise Vault\EVClient\
     - C:\Program Files\Intel\WiFi\bin\
     - C:\Program Files\Common Files\Intel\WirelessCommon\
     - C:\Users\20150\AppData\Local\Microsoft\WindowsApps
     - C:\Users\20150\AppData\Local\Programs\Microsoft VS Code\bin
     - C:\Users\20150\progs\nodejs
     - C:\Users\20150\progs\ffmpeg\bin
     - C:\Users\20150\progs\php
     - C:\Users\20150\progs\ruby\bin
     - C:\Users\20150\AppData\Local\Programs\Microsoft VS Code\bin
     - c:\Users\20150\progs\pgsql\bin
     - C:\Users\20150\progs\cmder\vendor\git-for-windows\cmd
     - C:\Users\20150\progs\cmder\vendor\git-for-windows\mingw64\bin
     - C:\Users\20150\progs\cmder\vendor\git-for-windows\usr\bin
     - C:\Users\20150\progs\cmder

hron84 avatar May 20 '19 14:05 hron84

It looks to me like Ruby's Dir.home relies on a folder that's at least partially determined by the HOMEDRIVE variable. I'm not sure of a good workaround or a way to fix it in the gem itself. I'll have to look further into it.

In the meantime, setting the SOLARGRAPH_CACHE environment variable should fix it. I set it inside my user variables like so:

image

Note that you might need to log out or restart the PC for the environment variable to take effect. (I didn't expect that to be necessary, but it started working after I logged out and logged back in.)

castwide avatar May 25 '19 22:05 castwide

Yup, as I wrote, setting env var SOLARGRAPH_CACHE solved the first issue, but then I got this strange nil complaint. I tried to trace back the error, but I'm currently stuck as I'm not too familiar with SolarGraph and not want to be (because I have very much other things I have to be familiar). So I more likely want a solution for the implicit conversion issue rather than the Dir.home issue.

hron84 avatar May 29 '19 15:05 hron84

Gotcha. I haven't been able to reproduce that particular error with Ruby 2.5.3 on Windows 10. I'll try again with Ruby 2.6.3.

Incidentally, gem version 0.32.4 got released yesterday. I have a feeling it won't impact this issue, but it's worth a shot.

castwide avatar May 29 '19 17:05 castwide

I currently have no time for checking it but I will do it as soon as possible.

hron84 avatar May 30 '19 13:05 hron84