ruby / ruby/rbs

manifest.yaml does not allow gems as dependencies

Open
#1,538 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Description

Currently manifest.yaml does not allow gems as dependencies. For example:

# manifest.yaml for gem X
dependencies:
  - name: ast

When your Gemfile.lock contains the gem X, rbs collection install generates the following rbs_collection.lock.yaml.

$ rbs -v
rbs 3.2.1
# snip

gems:
- name: X
  version: '0.1'
  source:
    type: git
    name: local_collection
    revision: 2908d5a84c0364fceaa6046b35c290e720052172
    remote: "..."
    repo_dir: gems
- name: ast
  version: '0'
  source:
    type: stdlib
gemfile_lock_path: Gemfile.lock

This RBS is invalid. ast is a gem, but the lockfile indicates that it is a stdlib. Therefore rbs validate fails with the lockfile.

$ rbs validate
/path/to/rbs/environment_loader.rb:118:in `block in each_dir': Cannot find type definitions for library: ast (0) (RBS::EnvironmentLoader::UnknownLibraryError)

(snip)

BTW, it is a regression of a recent RBS version. Because it works well on rbs 2.0.0, which is the version introduced manifest.yaml.

rbs collection install generates the following lockfile on rbs v2.0.0.

(snip)
gems:
- name: X
  version: '0.1'
  source:
    type: git
    name: local_collection
    revision: 2908d5a84c0364fceaa6046b35c290e720052172
    remote: "..."
    repo_dir: gems
- name: ast
  version: '2.4'
  source:
    type: git
    name: ruby/gem_rbs_collection
    revision: 267dd270bb5aabcc1e21c87f44360f0680a8501c
    remote: https://github.com/ruby/gem_rbs_collection.git
    repo_dir: gems

So I think manifest.yaml should allows containing a gem as a dependency.

Problem if it contains a gem as a dependency

It has a problem if manifest.yaml contains a gem as a dependency. Becaues rbs collection cannot resolve dependency of the gem written in manifest.yaml. For example:

  • Gemfile.lock only contains dependency of gem X
  • ruby/gem_rbs_collection has an RBS for gem X
  • gem X has a dependency on gem Y, which is specified by manifest.yaml.
  • gem Y has a dependency on gem Z, which is specified by the gemspec.

In this case, rbs collection finds gem X and gem Y. But it cannot find gem Z if Gemfile.lock does not contain gem Y or gem Z.

I'm not sure this problem is critical. I guess allowing gems in manifest.yaml is better even if it has the dependency resolution problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the regression with manifest.yaml, Gemfile.lock, and rbs collection install, then inspect the generated rbs_collection.lock.yaml and run rbs validate. Trace how manifest dependencies are classified and how dependencies are resolved when they are absent from Gemfile.lock. Done means a gem listed in manifest.yaml is represented with the correct source and the documented transitive-dependency case is handled or clearly constrained.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.