tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

Generate vendor gem rbis

Open adisonlampert opened this issue 2 years ago • 1 comments

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

  1. Open Tapioca
  2. Install a random gem into your Gemfile (e.g., dog_breeds)
  3. Run bundle install
  4. Run gem unpack dog_breeds
  5. mv dog_breeds-0.4.0 vendor/gems
  6. Go into the Gemfile and modify gem("dog_breeds") to gem("dog_breeds", "0.4.0", :path => "vendor/gems/dog_breeds-0.4.0"
  7. Run bundle install
  8. Run bundle exec tapioca gem dog_breeds and this should print created 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 avatar Jul 26 '22 18:07 adisonlampert

@adisonlampert Is this PR still relevant given the conversation with @paracycle on Slack?

wildmaples avatar Aug 26 '22 18:08 wildmaples

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

eeternalspring avatar Mar 27 '23 20:03 eeternalspring

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.

paracycle avatar Mar 27 '23 20:03 paracycle

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.

paracycle avatar Mar 27 '23 20:03 paracycle