Skip to content
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

manifest.yaml does not allow gems as dependencies #1538

Open
pocke opened this issue Sep 22, 2023 · 0 comments
Open

manifest.yaml does not allow gems as dependencies #1538

pocke opened this issue Sep 22, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@pocke
Copy link
Member

pocke commented Sep 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant