mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
Use better resolution by Bundler at force_activate
This commit is contained in:
parent
5d358b660d
commit
70c6613781
Notes:
git
2024-09-12 07:28:21 +00:00
1 changed files with 17 additions and 15 deletions
32
prelude.rb
32
prelude.rb
|
@ -1,11 +1,7 @@
|
||||||
class Binding
|
class Binding
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
def irb
|
def irb
|
||||||
if defined?(Bundler) && !Gem.loaded_specs["irb"]
|
force_activate 'irb'
|
||||||
unless force_activate "irb"
|
|
||||||
warn "irb is not found. Install irb from RubyGems or add irb to Gemfile."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
require 'irb'
|
require 'irb'
|
||||||
irb
|
irb
|
||||||
end
|
end
|
||||||
|
@ -14,16 +10,22 @@ class Binding
|
||||||
alias irb irb # :nodoc:
|
alias irb irb # :nodoc:
|
||||||
|
|
||||||
private def force_activate(gem)
|
private def force_activate(gem)
|
||||||
gemspecs = (Gem::Specification.dirs + [Gem.default_specifications_dir]).map{|d|
|
return if !defined?(Bundler) || Gem.loaded_specs.key?(gem)
|
||||||
Dir.glob("#{d}/#{gem}*.gemspec").reverse
|
|
||||||
}.flatten
|
Bundler.reset!
|
||||||
if gemspecs.empty?
|
|
||||||
false
|
ui = Bundler::UI::Shell.new
|
||||||
else
|
ui.level = "silent"
|
||||||
gemspec = Gem::Specification.load(gemspecs[0])
|
Bundler.ui = ui
|
||||||
gemspec.dependencies.each{|dep| force_activate dep.name }
|
|
||||||
gemspec.activate
|
@builder = Bundler::Dsl.new
|
||||||
end
|
Bundler.definition.gemfiles.each{|gemfile| @builder.eval_gemfile(gemfile) }
|
||||||
|
@builder.gem gem
|
||||||
|
|
||||||
|
definition = @builder.to_definition(nil, true)
|
||||||
|
definition.validate_runtime!
|
||||||
|
Bundler::Definition.no_lock = true
|
||||||
|
Bundler::Runtime.new(nil, definition).setup
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue