From 0ade8b038b24b0036d3253e3bf286e2d277ec819 Mon Sep 17 00:00:00 2001 From: Soutaro Matsumoto Date: Wed, 24 Dec 2025 15:56:42 +0900 Subject: [PATCH] Skip `set` and `pathname` from `manifest.yaml` --- .../collection/config/lockfile_generator.rb | 7 ++ test/rbs/cli_test.rb | 80 +++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/lib/rbs/collection/config/lockfile_generator.rb b/lib/rbs/collection/config/lockfile_generator.rb index 56e04497f..c742f963a 100644 --- a/lib/rbs/collection/config/lockfile_generator.rb +++ b/lib/rbs/collection/config/lockfile_generator.rb @@ -184,6 +184,13 @@ def generate lockfile.gems[name] = { name: name, version: "0", source: source } end return + when 'set', 'pathname' + # set and pathname is migrated to core from stdlib. + RBS.logger.info { + from = from_gem || "rbs_collection.yaml" + "`#{name}` is a part of the Ruby core library. The dependency to the library can be safely deleted from #{from}." + } + return when *ALUMNI_STDLIBS.keys version = ALUMNI_STDLIBS.fetch(name) if from_gem diff --git a/test/rbs/cli_test.rb b/test/rbs/cli_test.rb index 168bb8726..26d5de506 100644 --- a/test/rbs/cli_test.rb +++ b/test/rbs/cli_test.rb @@ -1543,6 +1543,86 @@ def test_collection_install__mutex_m__rbs_dependency_and__gem_dependency end end + def test_collection_install__pathname_set + 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: pathname + - name: set + - name: ast + - name: cgi-escape + YAML + + bundle_install('ast', 'logger') + _stdout, stderr = run_rbs_collection("install", bundler: true) + + assert_include stderr, 'Cannot find `pathname` gem.' + assert_include stderr, 'Cannot find `set` gem.' + + 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_nil lockfile.gems["set"] + assert_nil lockfile.gems["pathname"] + assert_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["cgi-escape"][:source] + assert_instance_of RBS::Collection::Sources::Git, lockfile.gems["ast"][:source] + end + end + end + + def test_collection_install__set_pathname__manifest + Dir.mktmpdir do |dir| + Dir.chdir(dir) do + dir = Pathname(dir) + + (dir + RBS::Collection::Config::PATH).write(<<~YAML) + sources: + - type: local + path: repo + + path: #{dir.join('gem_rbs_collection')} + YAML + + (dir/"repo/true_string/0").mkpath + (dir/"repo/true_string/0/manifest.yaml").write(<<~YAML) + dependencies: + - name: set + - name: pathname + - name: cgi-escape + YAML + + bundle_install("logger", "true_string") # true_string is a soutaro's gem that doesn't have sig directory + + _stdout, stderr = run_rbs_collection("install", bundler: true) + + assert_include stderr, '`set` is a part of the Ruby core library.' + assert_include stderr, '`pathname` is a part of the Ruby core library.' + + 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_nil lockfile.gems["set"] + assert_nil lockfile.gems["pathname"] + assert_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["cgi-escape"][:source] + assert_instance_of RBS::Collection::Sources::Local, lockfile.gems["true_string"][:source] + end + end + end + def test_subtract Dir.mktmpdir do |dir| dir = Pathname(dir)