pglombardo / PasswordPusher

🔐 Securely share sensitive information with automatic expiration & deletion after a set number of views or duration. Track who, what and when with full audit logs.
https://docs.pwpush.com
Apache License 2.0
2.07k stars 358 forks source link

Heroku: Upgrade Ruby Version #441

Open bprobst-msis opened 2 years ago

bprobst-msis commented 2 years ago

Attempted a new deployment to Heroku and it failed when configuring Ruby.

-----> Building on the Heroku-22 stack -----> Determining which buildpack to use for this app ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. Detected buildpacks: Ruby,Node.js See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order -----> Ruby app detected -----> Installing bundler 2.3.10 -----> Removing BUNDLED WITH version in the Gemfile.lock -----> Compiling Ruby/Rails Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/heroku-22/ruby-3.0.4.tgz -s -o - | tar zxf - ' failed on attempt 1 of 3. Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/heroku-22/ruby-3.0.4.tgz -s -o - | tar zxf - ' failed on attempt 2 of 3. ! ! The Ruby version you are trying to install does not exist on this stack. !
! You are trying to install ruby-3.0.4 on heroku-22. !
! Ruby ruby-3.0.4 is present on the following stacks: !
! - heroku-18 ! - heroku-20 !
! Heroku recommends you use the latest supported Ruby version listed here: ! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes !
! For more information on syntax for declaring a Ruby version see: ! https://devcenter.heroku.com/articles/ruby-versions ! ! Push rejected, failed to compile Ruby app. ! Push failed

As per documentation linked in the error:

Supported runtimes Heroku supports the following Ruby versions and the associated Rubygems. A supported version means that you can expect our tools and platform to work with a given version. It also means you can receive technical support. Here are our supported Ruby versions:

MRI:

2.7.6, Rubygems: 3.1.6 (Heroku-18 & Heroku-20 only) 3.0.4, Rubygems: 3.2.33(Heroku-18 & Heroku-20 only) 3.1.2, Rubygems: 3.3.7

I am unfortunately not proficient with Ruby at all, otherwise I would probably attempt to update the version requirement myself.

pglombardo commented 2 years ago

Hi @bprobst-msis - thanks for the report and apologies for the issue. The heroku deploy file hasn't been updated in a while. I'll see if I can resurrect it soon.

pglombardo commented 2 years ago

This may be a Heroku issue as the app.json file for these Heroku deploys hasn't changed in quite a while. See linked issue above.

bprobst-msis commented 1 year ago

After specifying a specific stack to build with by adding "stack": "heroku-20", to app.json and also when attempting to update my current instance I am getting the following build error:

   Running: rake assets:precompile
   rake aborted!
   LoadError: Error loading the 'postgresql' Active Record adapter. Missing a gem it depends on? pg is not part of the bundle. Add it to your Gemfile.

   Caused by:
   Gem::LoadError: pg is not part of the bundle. Add it to your Gemfile.

Attached is the output from creating a new instance in Heroku

pwpush_custom_heroku_v1.25.2.txt

I have been unable to update since Mid-November, and would like to try out some of the features you have added to the repo, just can't in Heroku apparently.

pglombardo commented 1 year ago

Apologies for the ongoing Heroku issues @bprobst-msis. I can't even test Heroku now because they require a credit card for the paid dynos.

There was a recent change to the app where you have to run bundle config set with 'postgres' (other values are sqlite or mysql) before bundle install. You can see this in the postgres Dockerfile.

I think for heroku there is no app.json setting for this but instead you have to add an environment variable BUNDLE_WITH=postgres.

I hope this helps. Heroku is going to be challenging to support going forward but I'll do my best for as long as I can.

bprobst-msis commented 1 year ago

Thank You for providing the BUNDLE_WITH=postgres environment variable, that allowed me to update my current instance with no issues (except one of my own making on one of the pages, silly apostrophe had to be escaped).

At least now I can complete a build again!

bprobst-msis commented 1 year ago

I was just able to confirm forcing the stack to heroku-20 and setting bundle_with=postgres in the app.json file allowed a new dyno to be deployed (at least it should work until that stack is retired).

[...]
"scripts": {
    "postdeploy": "bundle exec rake db:migrate"
  },
  "stack": "heroku-20",
  "env": {
    "BUNDLE_WITH": "postgres",
    "BUNDLE_WITHOUT": "development:test:private",
    [...]
pglombardo commented 1 year ago

! The Ruby version you are trying to install does not exist on this stack. ! ! You are trying to install ruby-3.0.4 on heroku-22. ! ! Ruby ruby-3.0.4 is present on the following stacks: ! ! - heroku-18 ! - heroku-20

If you set the environment variable CUSTOM_RUBY_VERSION=3.2.0 and set the stack to "heroku-22" it should work.

From this doc:

If your Gemfile does not contain a ruby entry, you will get MRI 3.1.2.

Default rubies are locked into the app until you specify a Ruby version. For example, if your app is using a default Ruby version of 3.0.3, you will continue to stay on 3.0.3.

We highly recommend specifying a Ruby version in your Gemfile and not relying on the default Ruby version.

The Password Pusher Gemfile contains ruby ENV['CUSTOM_RUBY_VERSION'] || '>=2.7.0'. We can't call out a single Ruby version due the large number of pwpush users running in various environments.

But I believe if you set CUSTOM_RUBY_VERSION it should get around this issue.

Could you give that a try and let me know?

bprobst-msis commented 1 year ago

From what I have been able to determine so far, the Gemfile.lock file version will always "win" any version declarations, which is why it is trying to utilize ruby 3.0.4 as defined in that file.

I have still not found a way around this.

pglombardo commented 1 year ago

From what I have been able to determine so far, the Gemfile.lock file version will always "win" any version declarations, which is why it is trying to utilize ruby 3.0.4 as defined in that file.

But doesn't the buildpack run bundle install anyways? It should rewrite that Gemfile.lock I would think.

When I ran on Heroku, I was able to set a config var CUSTOM_RUBY_VERSION=3.1.2 and it used the right Ruby. This was more than a year ago though...