Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fluent-plugin-generate: fix crash bug without bundler #3444

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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