Solargraph: `gem install solargraph` fails with "undefined method `[]' for nil:NilClass"

Created on 23 Jan 2019  路  10Comments  路  Source: castwide/solargraph

I am not able to install solargraph anymore:

$ gem install solargraph
Fetching parser-2.6.0.0.gem
Fetching ast-2.4.0.gem
Fetching kramdown-1.17.0.gem
Fetching mini_portile2-2.4.0.gem
Fetching htmlentities-4.3.4.gem
Fetching backport-0.3.0.gem
Fetching jaro_winkler-1.5.2.gem
Fetching nokogiri-1.10.1.gem
Fetching reverse_markdown-1.1.0.gem
Fetching parallel-1.13.0.gem
Fetching powerpack-0.1.2.gem
Fetching rainbow-3.0.0.gem
Fetching ruby-progressbar-1.10.0.gem
Fetching unicode-display_width-1.4.1.gem
Fetching rubocop-0.63.1.gem
Fetching thor-0.20.3.gem
Fetching solargraph-0.31.1.gem
Fetching tilt-2.0.9.gem
Fetching yard-0.9.18.gem
Successfully installed backport-0.3.0
Successfully installed htmlentities-4.3.4
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.2
Successfully installed kramdown-1.17.0
Successfully installed ast-2.4.0
Successfully installed parser-2.6.0.0
Successfully installed mini_portile2-2.4.0
Building native extensions. This could take a while...
Successfully installed nokogiri-1.10.1
Successfully installed reverse_markdown-1.1.0
Successfully installed parallel-1.13.0
Successfully installed powerpack-0.1.2
Successfully installed rainbow-3.0.0
Successfully installed ruby-progressbar-1.10.0
Successfully installed unicode-display_width-1.4.1
Successfully installed rubocop-0.63.1
Successfully installed thor-0.20.3
Successfully installed tilt-2.0.9
--------------------------------------------------------------------------------
As of YARD v0.9.2:

RubyGems "--document=yri,yard" hooks are now supported. You can auto-configure
YARD to automatically build the yri index for installed gems by typing:

    $ yard config --gem-install-yri

See `yard config --help` for more information on RubyGems install hooks.

You can also add the following to your .gemspec to have YARD document your gem
on install:

    spec.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs.

--------------------------------------------------------------------------------
Successfully installed yard-0.9.18
Successfully installed solargraph-0.31.1
Parsing documentation for backport-0.3.0
Installing ri documentation for backport-0.3.0
Parsing documentation for htmlentities-4.3.4
Installing ri documentation for htmlentities-4.3.4
Parsing documentation for jaro_winkler-1.5.2
Installing ri documentation for jaro_winkler-1.5.2
Parsing documentation for kramdown-1.17.0
Installing ri documentation for kramdown-1.17.0
Parsing documentation for ast-2.4.0
Installing ri documentation for ast-2.4.0
Parsing documentation for parser-2.6.0.0
Installing ri documentation for parser-2.6.0.0
Parsing documentation for mini_portile2-2.4.0
Installing ri documentation for mini_portile2-2.4.0
Parsing documentation for nokogiri-1.10.1
Installing ri documentation for nokogiri-1.10.1
Parsing documentation for reverse_markdown-1.1.0
Installing ri documentation for reverse_markdown-1.1.0
Parsing documentation for parallel-1.13.0
Installing ri documentation for parallel-1.13.0
Parsing documentation for powerpack-0.1.2
Installing ri documentation for powerpack-0.1.2
Parsing documentation for rainbow-3.0.0
Installing ri documentation for rainbow-3.0.0
Parsing documentation for ruby-progressbar-1.10.0
Installing ri documentation for ruby-progressbar-1.10.0
Parsing documentation for unicode-display_width-1.4.1
Installing ri documentation for unicode-display_width-1.4.1
Parsing documentation for rubocop-0.63.1
Installing ri documentation for rubocop-0.63.1
Parsing documentation for thor-0.20.3
Installing ri documentation for thor-0.20.3
Parsing documentation for tilt-2.0.9
Installing ri documentation for tilt-2.0.9
Parsing documentation for yard-0.9.18
Before reporting this, could you check that the file you're documenting
has proper syntax:

  /home/gitpod/.rvm/rubies/ruby-2.6.0/bin/ruby -c lib/yard/i18n/pot_generator.rb

RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.

The internal error was:

        (NoMethodError) undefined method `[]' for nil:NilClass

ERROR:  While executing gem ... (NoMethodError)
    undefined method `[]' for nil:NilClass

Here is a snapshot environment that reproduces this bug:

Open in Gitpod

Could you please help me troubleshoot this problem? Maybe I'm doing something wrong.

Most helpful comment

For the record: gem install solargraph; gem install rdoc -v 6.1.1 && gem install solargraph seems to work.

All 10 comments

Hey, I've never used Gitpod before. Pretty cool.

It looks like the gem gets installed, but there's a problem generating the rdoc documentation for yard.

After installation:

gitpod /workspace/solargraph $ gem list solargraph

*** LOCAL GEMS ***

solargraph (0.31.1)
gitpod /workspace/solargraph $ solargraph -v
0.31.1

Trying to generate the yard rdoc:

gitpod /workspace/solargraph $ gem rdoc yard
Parsing documentation for yard-0.9.18
Before reporting this, could you check that the file you're documenting
has proper syntax:

  /home/gitpod/.rvm/rubies/ruby-2.6.0/bin/ruby -c lib/yard/i18n/pot_generator.rb

RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.

The internal error was:

        (NoMethodError) undefined method `[]' for nil:NilClass

ERROR:  While executing gem ... (NoMethodError)
    undefined method `[]' for nil:NilClass

The syntax in the specified yard file appears to be valid:

gitpod /workspace/solargraph $ /home/gitpod/.rvm/rubies/ruby-2.6.0/bin/ruby -c /home/gitpod/.rvm/gems/ruby-2.6.0/gems/yard-0.9.18/lib/yard/i18n/pot_generator.rb
Syntax OK

This might be a bug in rdoc v6.1.0. I couldn't reproduce the error in environments that use either 6.0.1 or 6.1.1. (I also couldn't figure out how to make 6.1.0 stop being the default in Gitpod.)

Thanks a lot for looking into this!

I tried gem install rdoc, which seems to upgrade to v6.1.1, however the problem still reproduces after that. I'm not quite sure where to take it from there. 馃槙

Yeah, gem list rdoc still lists 6.1.0 as the default, which might be why the problem persists.

It's also worth noting that Ruby 2.6.0 isn't being tested in solargraph's CI yet. I'll create a branch for it and get the ball rolling.

For the record: gem install solargraph; gem install rdoc -v 6.1.1 && gem install solargraph seems to work.

I'm having the same problem with gem install overcommit.

My environment is fairly straightforward, because I'm just now beginning a reinstall of my os onto a blank drive.

  • Mac OS 10.14.4
  • Ruby 2.6.0 installed per the RVM single-user instructions
  • Homebrew 2.0.6
  • Xcode 10.2

It was mentioned earlier that the latest ruby hasn't been fully vetted. Should I try to install an older version of ruby? I need it only for one thing: to install overcommit. I never use it for anything else. Cheers

    gem install overcommit
    Fetching overcommit-0.47.0.gem
    Fetching iniparse-1.4.4.gem
    Fetching ffi-1.10.0.gem
    Fetching childprocess-0.9.0.gem
    Building native extensions. This could take a while...
    Successfully installed ffi-1.10.0
    Successfully installed childprocess-0.9.0
    Successfully installed iniparse-1.4.4
    Install hooks by running `overcommit --install` in your Git repository
    Successfully installed overcommit-0.47.0
    Parsing documentation for ffi-1.10.0
    Installing ri documentation for ffi-1.10.0
    Parsing documentation for childprocess-0.9.0
    Before reporting this, could you check that the file you're documenting
    has proper syntax:

    /Users/rob/.rvm/rubies/ruby-2.6.0/bin/ruby -c lib/childprocess/tools/generator.rb

    RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.

    The internal error was:

    (NoMethodError) undefined method `[]' for nil:NilClass

    ERROR:  While executing gem ... (NoMethodError)
    undefined method `[]' for nil:NilClass

@SaganRitual If you can use Ruby 2.5 instead, it's probably worth a try. As far as I can tell, this issue is specific to rdoc on 2.6.

Closing for inactivity. If anyone still experiences problems with installation, please feel free to comment or open a new ticket.

A fix has just gone into Ruby for this issue: https://github.com/ruby/ruby/commit/6566919176834efb47ea717967669ca83eb78347.

Until this lands in the next version of 2.6, you can patch ripper_state_lex.rb locally. Working perfectly with latest Solargraph and Ruby 2.6.3.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PyvesB picture PyvesB  路  4Comments

dewetblomerus picture dewetblomerus  路  5Comments

castwide picture castwide  路  3Comments

dgutov picture dgutov  路  5Comments

cuongn265 picture cuongn265  路  3Comments