简体   繁体   中英

Cedar-14 bundle fails: Could not load OpenSSL

I'm upgrading a production app on Heroku to Cedar-14. I forked my staging app heroku fork -a v-upgrade v-upgrade2 , verified that the forked version was up and running on Cedar-10, set the stack to Cedar-14, created a dummy commit, and upon pushing received the following:

~/documents/coding/cycling/velopro$ git push upgrade2 currentdev:master
Counting objects: 11833, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7014/7014), done.
Writing objects: 100% (11833/11833), 91.20 MiB | 1.05 MiB/s, done.
Total 11833 (delta 8521), reused 6407 (delta 4535)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Fetching custom git buildpack... done
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.0
remote: -----> Installing gsl
remote: -----> Installing dependencies using 1.9.7
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Could not load OpenSSL.
remote:        You must recompile Ruby with OpenSSL support or change the sources in your
remote:        Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using
remote:        RVM are available at rvm.io/packages/openssl.
remote:        Bundler Output:
remote:        Could not load OpenSSL.
remote:        You must recompile Ruby with OpenSSL support or change the sources in your
remote:        Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using
remote:        RVM are available at rvm.io/packages/openssl.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to v-upgrade2.
remote: 
To git@heroku.com:v-upgrade2.git
 ! [remote rejected] currentdev -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:v-upgrade2.git'

I reconfirmed that I could still push to the original staging app (v-upgrade) on Heroku without issue, so the only difference between them appears to be the Cedar stack.

Has anyone else encountered a bundler issue loading OpenSSL on Cedar-14? Is there a way to "recompile Ruby with OpenSSL support" on Heroku?

Thanks in advance for your help!

In the end, I punted. The buildpack I was using hadn't been updated in a while so instead of attempting to fix it, I simply forked heroku-buildpack-ruby and added a few lines of code to include the GSL library that I needed as follows:

/Rakefile

+  GSL_VENDOR_URL   = "https://s3.amazonaws.com/gsl_bin/gsl-1.15.tgz"

/lib/language_pack/ruby.rb

 class LanguagePack::Ruby < LanguagePack::Base
+  GSL_VENDOR_URL       = "https://s3.amazonaws.com/gsl_bin/gsl-1.15.tgz"
   NAME                 = "ruby"
   LIBYAML_VERSION      = "0.1.6"
   LIBYAML_PATH         = "libyaml-#{LIBYAML_VERSION}"
@@ -57,7 +58,8 @@ class LanguagePack::Ruby < LanguagePack::Base
   def default_config_vars
     instrument "ruby.default_config_vars" do
       vars = {
-        "LANG" => env("LANG") || "en_US.UTF-8"
+        "LANG" => env("LANG") || "en_US.UTF-8",
+        "LD_LIBRARY_PATH" => ld_path,
       }

       ruby_version.jruby? ? vars.merge({
@@ -88,6 +90,9 @@ class LanguagePack::Ruby < LanguagePack::Base
       setup_export
       setup_profiled
       allow_git do
+        install_gsl
+        run("cp -R vendor/gsl-1 /app/vendor/gsl")
+        run("cp -R vendor/gsl-1 /app/vendor/gsl-1")
         install_bundler_in_app
         build_bundler
         post_bundler
@@ -111,6 +116,7 @@ private
     paths         = [
       ENV["PATH"],
       "bin",
+      "/app/vendor/gsl-1/bin",
       system_paths,
     ]
     paths.unshift("#{slug_vendor_jvm}/bin") if ruby_version.jruby?
@@ -119,6 +125,10 @@ private
     paths.join(":")
   end

+  def ld_path
+    "/app/vendor/gsl-1/lib"
+  end
+
   def binstubs_relative_paths
     [
       "bin",
@@ -459,6 +469,15 @@ ERROR
     FileUtils.rm File.join('bin', File.basename(path)), :force => true
   end

+  def install_gsl
+    topic("Installing gsl")
+    bin_dir = "vendor/gsl-1"
+    FileUtils.mkdir_p bin_dir
+    Dir.chdir(bin_dir) do |dir|
+      run("curl #{GSL_VENDOR_URL} -s -o - | tar xzf -")
+    end
+  end

In the end, while it may not have been as emotionally satisfying to figure out what was wrong with loading OpenSSL, this is probably the better route anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM