DEV Community

Masataka Pocke Kuwabara
Masataka Pocke Kuwabara

Posted on

RBS introduced manifest.yaml

RBS introduced manifest.yaml
RBS v2.0.0, for Ruby 3.1, has been released!
RBS v2 contains many my patches. I recently work for rbs collection feature especially. In short, rbs collection is "Bundler" for RBS. It installs, updates and loads gems' RBSs for rbs, steep and typeprof commands.

In this article, I describe a feature of rbs collection, it is manifest.yaml.
manifest.yaml is a file to describe standard libraries dependencies for RBS.

Motivation

rbs collection detects the dependencies from Gemfile.lock.
For example, if your Gemfile has an entry, gem 'rails', rbs collection finds dependencies gems, such as activesupport, railties, nokogiri and so on, from Gemfile.lock. Then it installs RBSs from ruby/gem_rbs_collection repository.

It almost works well, but it has a problem. Gemfile.lock doesn't have standard libraries entries often.
For example, rails gem depends on pathname stdlib, but the dependency doesn't appear in Gemfile.lock. So rbs collection couldn't find pathname dependency from Gemfile.lock, then the user sees Could not find Pathname (RBS::NoTypeFoundError).

manifest.yaml solves this problem.

What is manifest.yaml

manifest.yaml is a file to describe standard libraries dependencies for RBS.

The following is the manifest.yaml of activesupport gem.

dependencies:
  - name: monitor
  - name: date
  - name: singleton
  - name: logger
  - name: mutex_m
  - name: time
  - name: pathname
Enter fullscreen mode Exit fullscreen mode

https://github.com/ruby/gem_rbs_collection/blob/ce6664cec7387b4f5b52d01b80d26e9a9f9ad79c/gems/activesupport/6.0/manifest.yaml

It's simple. If Gemfile.lock has activesupport entry, rbs collection finds the stdlib dependencies from the manifest.yaml.

Who writes manifest.yaml

If you are an application developer, you don't need to write manifest.yaml. You can add a dependency entry to rbs_collection.yaml if your application depends on standard library.

If you are a gem author and the gem contains RBS in sig/ directory, you can put sig/manifest.yaml.

If you'd like to contribute ruby/gem_rbs_collection, you can put gems/GEM_NAME/VERSION/manifest.yaml. Follow the activesupport example.

Future work

Currently rbs collection resolves stdlib dependencies, but rbs -r LIB option doesn't resolve them unfortunately.
For instance, logger depends on monitor, but rbs -r logger doesn't load monitor.

I'll work to fix this problem soon.


By the way, I'll change my job next year to focus on developing RBS. I'll work for both Rails apps and RBS as my job to make RBS production-ready for real Rails applications!

Discussion (0)