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
Make srb
aware of tapioca
#3332
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the comment!
This change will be untested in our repo, do you think it would be possible to add a snapshot test to |
b9164b1
to
c7a3773
Compare
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
…s used Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, I just had one question about the content of the test.sh
for the tapioca test.
@@ -0,0 +1,3 @@ | |||
#!/bin/bash | |||
|
|||
bundle exec "$1" tc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is explicitly not calling srb init
because that's not the workflow with tapioca
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. We assume the user will do tapioca init
instead.
By default, `srb` will look for RBIs coming from gems. Since we migrated to Prism, Sorbet is now picking up the RBI shipped with the gem which results in a lot of errors. We can disable this behavior by using Tapioca. See sorbet/sorbet#3332. Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Motivation
One difference between
srb
andtapioca
is the way they handle signatures coming from gems.With
srb
, the developer of a gem can provide a dir calledrbi/
that contains all the signatures they want to export.When the end user runs
srb tc
, the content of the gemrbi/
dir is cached locally then passed to sorbet along the other files to be typechecked in the project.This approach brings at least two problems: 1) Sorbet does not come with a de-facto solution to copy signatures from the code to the
rbi/
folder, hence 2) there is a high probability for therbi/
folder to get desynchronized from the actual lib code.tapioca
tries to address this problem by automatically copying code signatures to the RBI when it generates the RBIs for all the gems in the end user project. That way, the work is transferred from the gem developer to the gem user, and ultimately totapioca
. Since you likely runtapioca
every time you change your Gemfile, you always get the up-to-date signatures from the gem code for free.While still imperfect, this solution allows the whole RBI sharing to work without intervention from the developer nor the end user and avoid desynchronization. Also, since
tapioca
comes with an exclusion list mechanism the end user can chose to completely ignore a gem RBI if they want.Now comes the problem with the current
srb
behaviour. By always copying therbi/
folder, the RBI from the gem is always passed to Sorbet when one callsrb tc
. Which is then in conflict with the expected behaviour of atapioca
user.To address this problem, @paracycle proposed a new environment variable controlling
srb
behaviour regarding gems RBIs:SRB_SKIP_GEM_RBIS
. While it solves the problem, it can be cumbersome for the end user that always have to remember to set this variable every time they usetapioca
in a project that depends on gems with arbi/
folder. This problem is even bigger sincetapioca
started depending on theparlour
gem which provides arbi/
folder meaning that alltapioca
users now need to set the environment variable.With this pull-request, the idea is to make
srb
aware thattapioca
is used in the project and copying therbi/
folder is not needed. The end user get the expected behaviour without changing environment variables and nothing changes if the project does not usetapioca
.Test plan
See included automated tests.