Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/rbs/collection/config/lockfile_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ class LockfileGenerator
"pstore" => nil,
}

NONGEM_STDLIBS = Set[
"cgi-escape",
"coverage",
"monitor",
"objspace",
"pathname",
"pty",
"ripper",
"socket",
]

class GemfileLockMismatchError < StandardError
def initialize(expected:, actual:)
@expected = expected
Expand Down Expand Up @@ -168,7 +179,9 @@ def generate
end
end
else
RBS.logger.warn "Cannot find `#{name}` gem. Using incorrect Bundler context? (#{definition.lockfile})"
unless NONGEM_STDLIBS.include?(name)
RBS.logger.warn "Cannot find `#{name}` gem. Using incorrect Bundler context? (#{definition.lockfile})"
end
end
end

Expand Down
2 changes: 2 additions & 0 deletions sig/collection/config/lockfile_generator.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module RBS
#
ALUMNI_STDLIBS: Hash[String, String?]

NONGEM_STDLIBS: Set[String]

class GemfileLockMismatchError < StandardError
@expected: Pathname

Expand Down
48 changes: 48 additions & 0 deletions test/rbs/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,54 @@ def test_collection_install__pathname_set
end
end

def test_collection_install__nongem_stdlib_no_warning
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
dir = Pathname(dir)
dir.join(RBS::Collection::Config::PATH).write(<<~YAML)
sources:
- name: ruby/gem_rbs_collection
remote: https://github.com/ruby/gem_rbs_collection.git
revision: b4d3b346d9657543099a35a1fd20347e75b8c523
repo_dir: gems

path: #{dir.join('gem_rbs_collection')}

gems:
- name: socket
- name: pathname
YAML

bundle_install('ast', 'logger', 'tsort')

# First install creates the lockfile with socket as stdlib
_stdout, stderr = run_rbs_collection("install", bundler: true)

lockfile = RBS::Collection::Config::Lockfile.from_lockfile(
lockfile_path: dir + "rbs_collection.lock.yaml",
data: YAML.safe_load((dir + "rbs_collection.lock.yaml").read)
)

assert_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["socket"][:source]
assert_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["pathname"][:source]

# Second install with existing lockfile should not warn about nongem stdlibs
_stdout, stderr = run_rbs_collection("install", bundler: true)

refute_match(/Cannot find `socket` gem/, stderr)
refute_match(/Cannot find `pathname` gem/, stderr)

lockfile = RBS::Collection::Config::Lockfile.from_lockfile(
lockfile_path: dir + "rbs_collection.lock.yaml",
data: YAML.safe_load((dir + "rbs_collection.lock.yaml").read)
)

assert_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["socket"][:source]
assert_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["pathname"][:source]
end
end
end

def test_collection_install__set_pathname__manifest
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
Expand Down
Loading