Skip to content

NoMethodError when invoking rails command without arguments (undefined method `start_with?' for nil:NilClass) #666

@mernen

Description

@mernen

With Spring 4.0, running rails without any arguments causes a NoMethodError.

This is caused by b85f41be, since command_name will be nil in that case. I believe a null check is all that's needed.

Steps for reproduction

On a terminal, run the rails command in a Rails project that has Spring 4.0.

Example output

$ rails
Traceback (most recent call last):
    12: from bin/rails:2:in `<main>'
    11: from bin/rails:2:in `load'
    10: from /usr/src/testapp/bin/spring:7:in `<top (required)>'
     9: from /usr/src/testapp/bin/spring:7:in `tap'
     8: from /usr/src/testapp/bin/spring:10:in `block in <top (required)>'
     7: from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
     6: from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
     5: from /usr/local/bundle/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `<top (required)>'
     4: from /usr/local/bundle/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `load'
     3: from /usr/local/bundle/gems/spring-4.0.0/bin/spring:49:in `<top (required)>'
     2: from /usr/local/bundle/gems/spring-4.0.0/lib/spring/client.rb:30:in `run'
     1: from /usr/local/bundle/gems/spring-4.0.0/lib/spring/client/command.rb:7:in `call'
/usr/local/bundle/gems/spring-4.0.0/lib/spring/client/rails.rb:25:in `call': undefined method `start_with?' for nil:NilClass (NoMethodError)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions