Skip to content

Commit 9a6e555

Browse files
authored
Merge pull request #575 from chadlwilson/fix-gem-path
Correct Bundler 2.x Gem path on war/jar load
2 parents 523237b + 77afa06 commit 9a6e555

6 files changed

Lines changed: 6 additions & 22 deletions

File tree

lib/warbler/gems.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ def specs(gem_dependencies)
5252
# Add a single gem to WEB-INF/gems
5353
def find_single_gem_files(gem_dependencies, gem_pattern, version = nil)
5454
gem_spec_class = Gem::Specification
55-
gem_spec_class = Gem::BasicSpecification if Gem.const_defined?(:BasicSpecification)
56-
# Gem::Specification < Gem::BasicSpecification (since RGs 2.1)
5755
case gem_pattern
5856
when gem_spec_class
5957
return BundlerHelper.to_spec(gem_pattern)

lib/warbler/templates/bundler.erb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,3 @@ ENV['BUNDLE_WITHOUT'] = '<%= config.bundle_without.join(':') %>'
22
<% if config.bundler[:frozen] -%>
33
ENV['BUNDLE_FROZEN'] = '1'
44
<% end -%>
5-
6-
module Bundler
7-
module Patch
8-
def clean_load_path
9-
# nothing to be done for embedded JRuby
10-
end
11-
end
12-
module SharedHelpers
13-
def included(bundler)
14-
bundler.send :include, Patch
15-
end
16-
end
17-
end
18-
19-
require 'bundler/shared_helpers'

lib/warbler/templates/jar.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ ENV['GEM_PATH'] = nil # RGs sets Gem.paths.path = Gem.default_path + [ GEM_HOME
99
<% if config.bundler && config.bundler[:gemfile_path] -%>
1010
ENV['BUNDLE_GEMFILE'] = File.expand_path(File.join('..', '..', '<%= config.bundler[:gemfile_path] %>'), __FILE__)
1111
<% end -%>
12+
<%# Ensure any cached paths are cleared; otherwise behaviour can be indeterminate if the paths have already been read %>
13+
# Gem.clear_paths

lib/warbler/templates/war.erb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
if $servlet_context.nil?
22
ENV['GEM_HOME'] <%= config.override_gem_home ? '=' : '||=' %> File.expand_path(File.join('..', '..', '<%= config.gem_path %>'), __FILE__)
3-
<% if config.override_gem_home -%>
4-
<% # GEM_HOME/GEM_PATH are set as .war gets extracted (on java -jar ...)
5-
# ... thus setting `ENV['GEM_PATH'] = nil` would cause a boot failure
6-
-%>
7-
<% end -%>
83
<% if config.bundler && config.bundler[:gemfile_path] -%>
94
ENV['BUNDLE_GEMFILE'] ||= File.expand_path(File.join('..', '..', '<%= config.bundler[:gemfile_path] %>'), __FILE__)
105
<% end -%>
@@ -17,3 +12,5 @@ else
1712
ENV['BUNDLE_GEMFILE'] ||= $servlet_context.getRealPath('/<%= config.bundler[:gemfile_path] %>')
1813
<% end -%>
1914
end
15+
<%# Ensure any cached paths are cleared; otherwise behaviour can be indeterminate if the paths have already been read %>
16+
Gem.clear_paths

spec/rails7_stub/Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ GEM
190190
PLATFORMS
191191
universal-java-1.8
192192
universal-java-21
193+
universal-java-8
193194

194195
DEPENDENCIES
195196
activerecord-jdbcpostgresql-adapter (~> 70.0)

spec/sample_bundler/Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ GEM
66
PLATFORMS
77
universal-java-1.8
88
universal-java-21
9+
universal-java-8
910

1011
DEPENDENCIES
1112
rake (= 13.3.0)

0 commit comments

Comments
 (0)