Skip to content

Commit

Permalink
Merge pull request #3444 from kenhys/fix-without-bundler
Browse files Browse the repository at this point in the history
fluent-plugin-generate: fix crash bug without bundler
  • Loading branch information
ashie committed Jul 5, 2021
2 parents 0a126d7 + 6de2b54 commit 57e729a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/fluent/command/plugin_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,13 @@ def lock_file_path
end

def locked_gem_version(gem_name)
d = Bundler::Definition.build(gem_file_path, lock_file_path, false)
d.locked_gems.dependencies[gem_name].requirement.requirements.first.last.version
if File.exist?(lock_file_path)
d = Bundler::Definition.build(gem_file_path, lock_file_path, false)
d.locked_gems.dependencies[gem_name].requirement.requirements.first.last.version
else
# fallback even though Fluentd is installed without bundler
Gem::Specification.find_by_name(gem_name).version.version
end
end

def rake_version
Expand All @@ -177,8 +182,13 @@ def test_unit_version
end

def bundler_version
d = Bundler::Definition.build(gem_file_path, lock_file_path, false)
d.locked_gems.bundler_version.version
if File.exist?(lock_file_path)
d = Bundler::Definition.build(gem_file_path, lock_file_path, false)
d.locked_gems.bundler_version.version
else
# fallback even though Fluentd is installed without bundler
Gem::Specification.find_by_name("bundler").version.version
end
end

def class_name
Expand Down

0 comments on commit 57e729a

Please sign in to comment.