lib/language_pack/ruby.rb
# runs bundler to install the dependencies
runs bundler to install the dependencies
runs bundler to install the dependencies
def build_bundler
    log("bundle") do
      bundle_without = ENV["BUNDLE_WITHOUT"] || "development:test"
      bundle_command = "bundle install --without #{bundle_without} --path vendor/bundle --binstubs vendor/bundle/bin"
      unless File.exist?("Gemfile.lock")
        error "Gemfile.lock is required. Please run \"bundle install\" locally\nand commit your Gemfile.lock."
      end
      if has_windows_gemfile_lock?
        topic "WARNING: Removing `Gemfile.lock` because it was generated on Windows."
        puts "Bundler will do a full resolve so native gems are handled properly."
        puts "This may result in unexpected gem versions being used in your app."
        log("bundle", "has_windows_gemfile_lock")
        File.unlink("Gemfile.lock")
      else
        bundle_command += " --deployment"
        cache_load ".bundle"
      end
      version = run("env RUBYOPT=\"#{syck_hack}\" bundle version").strip
      topic("Installing dependencies using #{version}")
      load_bundler_cache
      bundler_output = ""
      Dir.mktmpdir("libyaml-") do |tmpdir|
        libyaml_dir = "#{tmpdir}/#{LIBYAML_PATH}"
        install_libyaml(libyaml_dir)
        yaml_include   = File.expand_path("#{libyaml_dir}/include")
        yaml_lib       = File.expand_path("#{libyaml_dir}/lib")
        pwd            = run("pwd").chomp
        env_vars       = "env BUNDLE_GEMFILE=#{pwd}/Gemfile BUNDLE_CONFIG=#{pwd}/.bundle/config CPATH=#{yaml_include}:$CPATH CPPATH=#{yaml_include}:$CPPATH LIBRARY_PATH=#{yaml_lib}:$LIBRARY_PATH RUBYOPT=\"#{syck_hack}\""
        puts "Running: #{bundle_command}"
        bundler_output << pipe("#{env_vars} #{bundle_command} --no-clean 2>&1")
      end
      if $?.success?
        log "bundle", :status => "success"
        puts "Cleaning up the bundler cache."
        pipe "bundle clean"
        cache_store ".bundle"
        cache_store "vendor/bundle"
        FileUtils.rm_rf("#{slug_vendor_base}/cache")
        bin_dir = "bin"
        FileUtils.mkdir_p bin_dir
        Dir["#{slug_vendor_base}/bin/*"].each do |bin|
          run("ln -s ../#{bin} #{bin_dir}") unless File.exist?("#{bin_dir}/#{bin}")
        end
      else
        log "bundle", :status => "failure"
        error_message = "Failed to install gems via Bundler."
        if bundler_output.match(/Installing sqlite3 \([\w.]+\) with native extensions\s+Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension./)
          error_message += <<ERROR
Detected sqlite3 gem which is not supported on Heroku.
http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development
ERROR
        end
        error error_message
      end
    end
  end
def build_bundler log ( "bundle" ) do bundle_without = ENV [ "BUNDLE_WITHOUT" ] || "development:test" bundle_command = "bundle install --without #{bundle_without} --path vendor/bundle --binstubs vendor/bundle/bin" unless File . exist? ( "Gemfile.lock" ) error "Gemfile.lock is required. Please run \"bundle install\" locally\nand commit your Gemfile.lock." end if has_windows_gemfile_lock? topic "WARNING: Removing `Gemfile.lock` because it was generated on Windows." puts "Bundler will do a full resolve so native gems are handled properly." puts "This may result in unexpected gem versions being used in your app." log ( "bundle" , "has_windows_gemfile_lock" ) File . unlink ( "Gemfile.lock" ) else bundle_command += " --deployment" cache_load ".bundle" end version = run ( "env RUBYOPT=\"#{syck_hack}\" bundle version" ) . strip topic ( "Installing dependencies using #{version}" ) load_bundler_cache bundler_output = "" Dir . mktmpdir ( "libyaml-" ) do | tmpdir | libyaml_dir = "#{tmpdir}/#{LIBYAML_PATH}" install_libyaml ( libyaml_dir ) yaml_include = File . expand_path ( "#{libyaml_dir}/include" ) yaml_lib = File . expand_path ( "#{libyaml_dir}/lib" ) pwd = run ( "pwd" ) . chomp env_vars = "env BUNDLE_GEMFILE=#{pwd}/Gemfile BUNDLE_CONFIG=#{pwd}/.bundle/config CPATH=#{yaml_include}:$CPATH CPPATH=#{yaml_include}:$CPPATH LIBRARY_PATH=#{yaml_lib}:$LIBRARY_PATH RUBYOPT=\"#{syck_hack}\"" puts "Running: #{bundle_command}" bundler_output << pipe ( "#{env_vars} #{bundle_command} --no-clean 2>&1" ) end if $? . success? log "bundle" , :status => "success" puts "Cleaning up the bundler cache." pipe "bundle clean" cache_store ".bundle" cache_store "vendor/bundle" FileUtils . rm_rf ( "#{slug_vendor_base}/cache" ) bin_dir = "bin" FileUtils . mkdir_p bin_dir Dir [ "#{slug_vendor_base}/bin/*" ] . each do | bin | run ( "ln -s ../#{bin} #{bin_dir}" ) unless File . exist? ( "#{bin_dir}/#{bin}" ) end else log "bundle" , :status => "failure" error_message = "Failed to install gems via Bundler." if bundler_output . match ( / Installing sqlite3  \( [ \w .]+ \)  with native extensions \s +Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. / ) error_message += <<ERROR 


Detected sqlite3 gem which is not supported on Heroku.
http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development
 ERROR end error error_message end end end
runs bundler to install the dependencies
runs bundler to install the dependencies
# using --deployment is preferred if we can # need to setup compile environment for the psych gem # we need to set BUNDLE_CONFIG and BUNDLE_GEMFILE for # codon since it uses bundler. # Keep gem cache out of the slug # symlink binstubs