tapioca
tapioca copied to clipboard
Generate vendor gem rbis
Motivation
Closes #343 RBI files aren't being created for vendor gems & this PR solves that.
Implementation
I created a vendor gem using this blog. After that, I went through RBI gem generation with the debugger and found the spot vendor gems were being lost. Vendor gems are excluded in the gem_in_app_dir?
function because they aren't in the bundle path and their path starts with the root path. To solve this, I created a function similar to gem_in_bundle_path?
named gem_in_vendor_path?
that checks if the gem is in the vendor/gems
folder and added in that logic to gem_in_app_dir?
.
Tests
Manual Test
- Open Tapioca
- Install a random gem into your Gemfile (e.g., dog_breeds)
- Run
bundle install
- Run
gem unpack dog_breeds
-
mv dog_breeds-0.4.0 vendor/gems
- Go into the Gemfile and modify
gem("dog_breeds")
togem("dog_breeds", "0.4.0", :path => "vendor/gems/dog_breeds-0.4.0"
- Run
bundle install
- Run
bundle exec tapioca gem dog_breeds
and this should printcreated sorbet/rbi/gems/[email protected]
:)
Automatic Test Wrote a new test that creates a vendor gem and successfully generates a gem RBI file for it.
@adisonlampert Is this PR still relevant given the conversation with @paracycle on Slack?
Hi, this seems to be effecting me and my team, what was this conversation with @paracycle about? Is there a work around, or some flag thats needed?
cc @wildmapies @adisoniampert
Hi, this seems to be effecting me and my team, what was this conversation with @paracycle about? Is there a work around, or some flag thats needed?
cc @wildmapies @adisoniampert
This PR shouldn't be needed, since Tapioca should be doing the right thing by default, since it respects Bundler paths and all that.
If you have a specific problem, can you please open an issue detailing it and steps to reproduce?
Thank you.
Btw, the workflow described in this PR is an anti-pattern. The better way to solve the problem solved by "vendored" gems is to push your changes to those gems to a repo and depend on the gem via a git source.
Tapioca considers anything inside the application folder (and not inside the Bundler install path) to be a part of the application and assumes they will all be type checked together.