gem-repair 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/lib/rubygems/commands/repair_command.rb +46 -33
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de1546b65c1f9dd21344f01ffdb924dd21b1d1ad18a837645702b875f331c468
|
|
4
|
+
data.tar.gz: 20493791f64c066be2bd29303d7f846ef82d9837f0d271ad13226054f9642a73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac1791aead1e4f8ad1ee21a824a99c0f7bf8d114ed1e12a030d951f3bdfc1bd44dde72e0b79c5958e5ede695a785f286fb47443480356e3cc030b0575d715ae7
|
|
7
|
+
data.tar.gz: 974848b02311245c9ae757046b3e2d12d4a6e059c562c0888c05d21a6170bd549ed31a0baa45227ca5835e443784792bc517facf62b0151e5022e6b4c0f0437e
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Hiroshi SHIBATA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -44,7 +44,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
44
44
|
|
|
45
45
|
## Contributing
|
|
46
46
|
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/
|
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/gem-repare.
|
|
48
48
|
|
|
49
49
|
## License
|
|
50
50
|
|
|
@@ -53,47 +53,60 @@ Use -j to specify the number of parallel threads (default: 4).
|
|
|
53
53
|
|
|
54
54
|
say "Found #{specs.count} gem(s) to repair: #{specs.map(&:full_name).join(', ')}"
|
|
55
55
|
|
|
56
|
-
queue = Queue.new
|
|
57
|
-
specs.each { |spec| queue << spec }
|
|
58
|
-
|
|
59
|
-
threads = []
|
|
60
56
|
# Get number of threads from -j option, default to 4
|
|
61
57
|
num_threads = options[:jobs] || 4
|
|
58
|
+
# Running Gem::Installer in multiple threads deadlocks on old Rubies
|
|
59
|
+
# (fatal "No live threads left" on Ruby 2.3), so repair sequentially there.
|
|
60
|
+
num_threads = 1 if RUBY_VERSION < "2.6"
|
|
61
|
+
|
|
62
|
+
if num_threads > 1
|
|
63
|
+
say "Repairing gems using #{num_threads} parallel threads..."
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
threads
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# Ensure spec.base_dir is correct and writable
|
|
71
|
-
# The installer might need specific options, ensure they are correctly set up
|
|
72
|
-
installer_options = {
|
|
73
|
-
wrappers: true,
|
|
74
|
-
force: true, # Reinstall even if it appears installed
|
|
75
|
-
install_dir: spec.base_dir, # Install into the same location
|
|
76
|
-
env_shebang: true,
|
|
77
|
-
build_args: spec.build_args,
|
|
78
|
-
# Add other options as needed, e.g., :user_install => false if installing to system gems
|
|
79
|
-
# ignore_dependencies: true # Usually good for a restore/pristine operation
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
# Use spec.cache_file if available and valid, otherwise the installer might re-download
|
|
83
|
-
# Forcing a specific installer might be needed if default behavior isn't right
|
|
84
|
-
installer = Gem::Installer.at(spec.cache_file, installer_options)
|
|
85
|
-
installer.install
|
|
86
|
-
say "Successfully repaired #{spec.full_name} to #{spec.base_dir}"
|
|
87
|
-
rescue Gem::Ext::BuildError, Gem::Package::FormatError, Gem::InstallError, Zlib::BufError, NameError => e
|
|
88
|
-
alert_error "Failed to repair #{spec.full_name}: #{e.message}\n Backtrace: #{e.backtrace.join("\n ")}"
|
|
89
|
-
rescue => e
|
|
90
|
-
alert_error "An unexpected error occurred while repairing #{spec.full_name}: #{e.message}\n Backtrace: #{e.backtrace.join("\n ")}"
|
|
65
|
+
queue = Queue.new
|
|
66
|
+
specs.each { |spec| queue << spec }
|
|
67
|
+
|
|
68
|
+
threads = num_threads.times.map do
|
|
69
|
+
Thread.new do
|
|
70
|
+
while (spec = (queue.pop(true) rescue nil))
|
|
71
|
+
repair_gem(spec)
|
|
91
72
|
end
|
|
92
73
|
end
|
|
93
74
|
end
|
|
75
|
+
|
|
76
|
+
threads.each(&:join)
|
|
77
|
+
else
|
|
78
|
+
say "Repairing gems sequentially..."
|
|
79
|
+
|
|
80
|
+
specs.each { |spec| repair_gem(spec) }
|
|
94
81
|
end
|
|
95
82
|
|
|
96
|
-
threads.each(&:join)
|
|
97
83
|
say "Gem repair process complete."
|
|
98
84
|
end
|
|
85
|
+
|
|
86
|
+
private
|
|
87
|
+
|
|
88
|
+
def repair_gem(spec)
|
|
89
|
+
say "Repairing #{spec.full_name}..."
|
|
90
|
+
# Ensure spec.base_dir is correct and writable
|
|
91
|
+
# The installer might need specific options, ensure they are correctly set up
|
|
92
|
+
installer_options = {
|
|
93
|
+
wrappers: true,
|
|
94
|
+
force: true, # Reinstall even if it appears installed
|
|
95
|
+
install_dir: spec.base_dir, # Install into the same location
|
|
96
|
+
env_shebang: true,
|
|
97
|
+
build_args: spec.build_args,
|
|
98
|
+
# Add other options as needed, e.g., :user_install => false if installing to system gems
|
|
99
|
+
# ignore_dependencies: true # Usually good for a restore/pristine operation
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# Use spec.cache_file if available and valid, otherwise the installer might re-download
|
|
103
|
+
# Forcing a specific installer might be needed if default behavior isn't right
|
|
104
|
+
installer = Gem::Installer.at(spec.cache_file, installer_options)
|
|
105
|
+
installer.install
|
|
106
|
+
say "Successfully repaired #{spec.full_name} to #{spec.base_dir}"
|
|
107
|
+
rescue Gem::Ext::BuildError, Gem::Package::FormatError, Gem::InstallError, Zlib::BufError, NameError => e
|
|
108
|
+
alert_error "Failed to repair #{spec.full_name}: #{e.message}\n Backtrace: #{e.backtrace.join("\n ")}"
|
|
109
|
+
rescue => e
|
|
110
|
+
alert_error "An unexpected error occurred while repairing #{spec.full_name}: #{e.message}\n Backtrace: #{e.backtrace.join("\n ")}"
|
|
111
|
+
end
|
|
99
112
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem-repair
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hiroshi SHIBATA
|
|
@@ -17,11 +17,13 @@ executables: []
|
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
|
+
- LICENSE
|
|
20
21
|
- README.md
|
|
21
22
|
- lib/rubygems/commands/repair_command.rb
|
|
22
23
|
- lib/rubygems_plugin.rb
|
|
23
24
|
homepage: https://github.com/hsbt/gem-repair
|
|
24
|
-
licenses:
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
25
27
|
metadata: {}
|
|
26
28
|
rdoc_options: []
|
|
27
29
|
require_paths:
|