local gems not recognized
In my gemspec I have:
group :development do
gem 'domainic-dev', path: 'domainic-dev'
end
In my rbs_collection.yaml I have:
sources:
- type: git
name: ruby/gem_rbs_collection
remote: https://github.com/ruby/gem_rbs_collection.git
revision: main
repo_dir: gems
- type: local
name: domainic-dev
path: domainic-dev/sig
and when I run bundle exec rbs collection install I get:
╰─ bundle exec rbs collection install ─╯
W, [2024-10-10T09:55:47.295514 #36800] WARN -- rbs: Cannot find `domainic-dev-0.1.0` gem. Using incorrect Bundler context? (src/domainic/domainic/Gemfile.lock)
Using ast:2.4 (ast@ddba0c60808)
Using csv:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/csv/0)
Using domainic-dev:0.1.0 (src/domainic/domainic/domainic-dev/sig)
Using fileutils:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/fileutils/0)
Using forwardable:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/forwardable/0)
Using json:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/json/0)
Using logger:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/logger/0)
Using monitor:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/monitor/0)
Using optparse:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/optparse/0)
Using parser:3.2 (parser@ddba0c60808)
Using pathname:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/pathname/0)
Using rbs:3.6.1 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/sig)
Using rdoc:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/rdoc/0)
Using ripper:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/ripper/0)
Using rubocop:1.57 (rubocop@ddba0c60808)
Using rubocop-ast:1.30 (rubocop-ast@ddba0c60808)
Using rubocop-yard:0.9.3 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rubocop-yard-0.9.3/sig)
Using securerandom:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/securerandom/0)
Using strscan:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/strscan/0)
Using thor:1.2 (thor@704f7e6b395)
Using tsort:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/tsort/0)
Using yard:0.9 (yard@ddba0c60808)
Using zlib:0 (.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-3.6.1/stdlib/zlib/0)
It's done! 23 gems' RBSs now installed.
This may be an issue of documentation or it may be a bug. I'm not sure I fully understand the expectation of the sources property of the rbs_collection.yaml
Additionally this is adding a gem called "name" to the collection which doesn't exist and causes steep to fail
I'm not 100% sure because I haven't implemented nor used the local source, but a few ideas:
- When you have
gemline in yourGemfile, you may not need additional source inrbs_collection.yaml - What you needed actually might be
rbs collection update, not adding the local source
@pocke might help you if you continue having the problem.
I expect the rbs collection to load the gem's RBS for a gem with the path: option from the RubyGems source instead of the local source.
So, it should work with the following configuration.
# rbs_collection.yaml
sources:
- type: git
name: ruby/gem_rbs_collection
remote: https://github.com/ruby/gem_rbs_collection.git
revision: main
repo_dir: gems
But I haven't tested the path: option with rbs collection. If it does not work well, please tell me 🙏
The local source is designed to specify not a sig/ directory of a gem but an RBS collection repository. For example, if you want to use local source, you need to put a collection directory like the following:
$ tree
.
└── my_rbs_collection
└── gems
└── domainic-dev
└── 0.1
└── domainic-dev.rbs
However you do not need the collection repository because rbs collection should load RBS files from domainic-dev/sig/ directory without any configuration. It's a bug if it does not work.
Idk for sure but this might not work as expected for mono repos with multiple gems
Hmm, I couldn't reproduce this problem on my local. The following commands works for me.
$ bundle init
$ $EDITOR Gemfile
$ cat Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
gem "rbs", require: false
gem 'my_gem', path: './my_gem'
$ bundle gem my_gem
$ $EDITOR my_gem/my_gem.gemspec # To remove TODOs
$ (cd my_gem && bundle install)
$ bundle install
$ bundle exec rbs collection init
$ bundle exec rbs collection install
W, [2024-10-10T09:55:47.295514 #36800] WARN -- rbs: Cannot finddomainic-dev-0.1.0gem. Using incorrect Bundler context? (src/domainic/domainic/Gemfile.lock)
This error indicates that your environment has two or more Gemfile.locks and you execute the rbs collection command with unexpected Gemfile.lock.
The rbs collection command expects to work with the Bundler context, including gems for which you want to install RBS files. So, when you bundle exec rbs collection install, the Gemfile.lock for the bundle exec should include domainic-dev gem.
But this error indicates that the Gemfile.lock does not include it.
Could you confirm it?
Hmm, I couldn't reproduce this problem on my local. The following commands works for me.
$ bundle init $ $EDITOR Gemfile $ cat Gemfile # frozen_string_literal: true source "https://rubygems.org" gem "rbs", require: false gem 'my_gem', path: './my_gem' $ bundle gem my_gem $ $EDITOR my_gem/my_gem.gemspec # To remove TODOs $ (cd my_gem && bundle install) $ bundle install $ bundle exec rbs collection init $ bundle exec rbs collection install
W, [2024-10-10T09:55:47.295514 #36800] WARN -- rbs: Cannot finddomainic-dev-0.1.0gem. Using incorrect Bundler context? (src/domainic/domainic/Gemfile.lock)This error indicates that your environment has two or more
Gemfile.locks and you execute therbs collectioncommand with unexpectedGemfile.lock. Therbs collectioncommand expects to work with the Bundler context, including gems for which you want to install RBS files. So, when youbundle exec rbs collection install, theGemfile.lockfor thebundle execshould includedomainic-devgem. But this error indicates that theGemfile.lockdoes not include it. Could you confirm it?
Don't know how I missed this I apologize for the delay: https://github.com/domainic/domainic/blob/main/Gemfile.lock#L12