From 83413657855c1b725f2ff2672e3d23b96684958a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Wed, 14 Jun 2023 20:01:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=BE=A9require=20zip=E9=8C=AF?= =?UTF-8?q?=E8=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ad_banner.gemspec | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ad_banner.gemspec b/ad_banner.gemspec index 562dce7..e54af51 100644 --- a/ad_banner.gemspec +++ b/ad_banner.gemspec @@ -4,6 +4,21 @@ $:.push File.expand_path("../lib", __FILE__) require "ad_banner/version" bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install' if bundle_update_flag + env_pwd = ENV['PWD'] + begin + require ::File.expand_path('app/helpers/bundler_helper.rb', env_pwd) + extend BundlerHelper + rescue LoadError + def bundler_with_clean_env(&block) + if block_given? + if Bundler.respond_to?(:with_unbundled_env) + Bundler.with_unbundled_env(&block) + else + Bundler.with_clean_env(&block) + end + end + end + end require "fileutils" app_path = File.expand_path(__dir__) template_path = ENV['PWD'] + '/app/templates' @@ -40,7 +55,11 @@ if bundle_update_flag end save_zip_name = "#{ENV['PWD']}/tmp/ffmpeg-4.2-linux-64.zip" IO.copy_stream(download, save_zip_name) - require 'zip' + begin + require 'zip' + rescue LoadError + bundler_with_clean_env{system("gem install zip-zip")} + end FileUtils.mkdir_p(destination) Zip::File.open(save_zip_name) do |zip_file| zip_file.each do |f|