Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeLoader#load_project call to generate file-table-json missing folder path parameter #122

Open
mikeroher opened this issue Aug 21, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@mikeroher
Copy link

Describe the bug
TypeLoader#load_project fails due to changes in the Sorbet file-table-json generator.

The Sorbet file-table-json default parameter behaviour seems to have changed. Parlour's code changes into the user provided directory and calls the generator without passing in any folder path, under the assumption that the generator will use the current working directory if no path is provided. However, the generator now requires the folder path to be provided explicitly.

To Reproduce
Call TypeLoader.load_project on any folder.

Expected behavior
TypeLoader.load_project should return the RbiObjects.

Actual behavior

Traceback (most recent call last):
        6: from lib/gelato/parser.rb:10:in `<main>'
        5: from /Users/mikeroher/.rvm/gems/ruby-2.7.0/gems/sorbet-runtime-0.5.9057/lib/types/private/methods/_methods.rb:268:in `block in _on_method_added'
        4: from /Users/mikeroher/.rvm/gems/ruby-2.7.0/gems/sorbet-runtime-0.5.9057/lib/types/private/methods/call_validation.rb:161:in `validate_call'
        3: from /Users/mikeroher/.rvm/gems/ruby-2.7.0/gems/sorbet-runtime-0.5.9057/lib/types/private/methods/call_validation.rb:161:in `bind_call'
        2: from /Users/mikeroher/.rvm/gems/ruby-2.7.0/gems/parlour-6.0.1/lib/parlour/type_loader.rb:63:in `load_project'
        1: from /Users/mikeroher/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/json/common.rb:156:in `parse'
/Users/mikeroher/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/json/common.rb:156:in `parse': 783: unexpected token at '' (JSON::ParserError)

How to Fix
The fix for this is to add the root folderpath as a parameter to the generator. This occurs on line 58 of type_loader.rb.

Current code:

stdin, stdout, stderr, wait_thr = T.unsafe(Open3).popen3(
        "bundle exec srb tc -p file-table-json",
        chdir: root
      )

Corrected code:

stdin, stdout, stderr, wait_thr = T.unsafe(Open3).popen3(
        "bundle exec srb tc -p file-table-json #{root}",
        chdir: root
      )
@mikeroher mikeroher added the bug Something isn't working label Aug 21, 2021
@AaronC81
Copy link
Owner

Cheers for reporting! I'll aim to push out a fix for this soon, and try to put it behind a version gate so users of older Sorbets don't get errors when we pass an unexpected argument.

@AaronC81
Copy link
Owner

@mikeroher I'm afraid I don't seem to be able to reproduce this on the latest Sorbet (0.5.9058) - what version of Sorbet are you using?

Either way, the form of -p file-table-json where an argument is passed seems to be valid on even relatively old versions of Sorbet, so if the no-argument form is causing problems somewhere, I see no harm in changing how we invoke it :)

@mikeroher
Copy link
Author

@AaronC81 Ah strange, not sure what was causing it then! In any case, thank you for looking into it!!!

Fwiw, here's an excerpt of my Gemfile.lock:

    parlour (6.0.1)
      commander (~> 4.5)
      parser
      rainbow (~> 3.0)
      sorbet-runtime (>= 0.5)
    sorbet (0.5.9057)
      sorbet-static (= 0.5.9057)
    sorbet-runtime (0.5.9057)
    sorbet-static (0.5.9057-universal-darwin-14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants