Class: Kompo::BundleInstall::FromSource
- Inherits:
-
Taski::Task
- Object
- Taski::Task
- Kompo::BundleInstall::FromSource
- Includes:
- Kompo::BundleCacheHelpers
- Defined in:
- lib/kompo/tasks/bundle_install.rb
Overview
Run bundle install and save to cache
Instance Method Summary collapse
Instance Method Details
#clean ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/kompo/tasks/bundle_install.rb', line 137 def clean work_dir = WorkDir.path return unless work_dir && Dir.exist?(work_dir) [@bundle_ruby_dir, @bundler_config_path].each do |path| next unless path FileUtils.rm_rf(path) if File.exist?(path) end puts "Cleaned up bundle installation" end |
#run ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/kompo/tasks/bundle_install.rb', line 100 def run work_dir = WorkDir.path bundler = InstallRuby.bundler_path ruby_major_minor = InstallRuby.ruby_major_minor @bundle_ruby_dir = File.join(work_dir, "bundle", "ruby", "#{ruby_major_minor}.0") @bundler_config_path = File.join(work_dir, ".bundle", "config") puts "Running bundle install --path bundle..." gemfile_path = File.join(work_dir, "Gemfile") # Clear Bundler environment and specify Gemfile path explicitly Bundler.with_unbundled_env do ruby = InstallRuby.ruby_path env = {"BUNDLE_GEMFILE" => gemfile_path} # Suppress clang 18+ warning that causes mkmf try_cppflags to fail # This flag is clang-specific and not recognized by GCC if clang_compiler? env["CFLAGS"] = "-Wno-default-const-init-field-unsafe" env["CPPFLAGS"] = "-Wno-default-const-init-field-unsafe" end # Set BUNDLE_PATH to "bundle" - standard Bundler reads .bundle/config # and finds gems in {BUNDLE_PATH}/ruby/X.X.X/gems/ # Use ruby to execute bundler to avoid shebang issues system({"BUNDLE_GEMFILE" => gemfile_path}, ruby, bundler, "config", "set", "--local", "path", "bundle") or raise "Failed to set bundle path" system(env, ruby, bundler, "install") or raise "Failed to run bundle install" end puts "Bundle installed successfully" # Save to cache save_to_cache(work_dir) end |