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

rbs prototype rb fails due to syntax error #1414

Closed
sinsoku opened this issue Aug 8, 2023 · 0 comments · Fixed by #1574
Closed

rbs prototype rb fails due to syntax error #1414

sinsoku opened this issue Aug 8, 2023 · 0 comments · Fixed by #1574

Comments

@sinsoku
Copy link
Contributor

sinsoku commented Aug 8, 2023

Description

We often create template files in *.rb.
The rbs prototype command will fail on the directory containing these files.

Steps to reproduce

It fails because devise has template files that uses ERB in *.rb.

$ git clone --depth 1 https://github.com/heartcombo/devise.git
$ cd devise
$ rbs prototype rb --out-dir=sig/prototype --base-dir=. lib
Processing `lib`...
  Generating RBS for `lib/generators/active_record/devise_generator.rb`...
    - Writing RBS to `sig/prototype/lib/generators/active_record/devise_generator.rbs`...
  Generating RBS for `lib/generators/active_record/templates/migration.rb`...
<internal:ast>:59:in `parse': syntax error, unexpected local variable or method, expecting ';' or '\n' (SyntaxError)
...:Migration<%= migration_version %>
...              ^~~~~~~~~~~~~~~~~
syntax error, unexpected operator-assignment, expecting `end' or dummy end
    create_table :<%= table_name %><%= primary_key...
                   ^~
syntax error, unexpected operator-assignment, expecting `end' or dummy end
    add_index :<%= table_name %>, :reset_passwo...
                ^~
syntax error, unexpected `end'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/lib/rbs/prototype/rb.rb:97:in `parse'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/lib/rbs/cli.rb:823:in `block (2 levels) in run_prototype_file'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/lib/rbs/cli.rb:793:in `each'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/lib/rbs/cli.rb:793:in `block in run_prototype_file'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/lib/rbs/cli.rb:784:in `each'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/lib/rbs/cli.rb:784:in `run_prototype_file'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/lib/rbs/cli.rb:642:in `run_prototype'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/lib/rbs/cli.rb:137:in `run'
	from /Users/sinsoku/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.3/exe/rbs:7:in `<top (required)>'
	from /Users/sinsoku/.rbenv/versions/3.2.2/bin/rbs:25:in `load'
	from /Users/sinsoku/.rbenv/versions/3.2.2/bin/rbs:25:in `<main>'

System configuration

$ ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]

$ rbs --version
rbs 3.1.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant