Heroku push rejected because gems fail to install - ruby-on-rails

I need some help with this small app I am trying to push to heroku after doing
git add .
git commit -m "message here"
git push heroku master
I get the following error message:
Enumerating objects: 174, done.
Counting objects: 100% (174/174), done.
Delta compression using up to 12 threads
Compressing objects: 100% (156/156), done.
Writing objects: 100% (174/174), 38.41 KiB | 2.40 MiB/s, done.
Total 174 (delta 62), reused 36 (delta 3)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.3.10
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.6.6
remote: -----> Installing dependencies using bundler 2.3.10
remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote: /usr/bin/env: ‘ruby\r’: No such file or directory
remote: Bundler Output: /usr/bin/env: ‘ruby\r’: No such file or directory
remote:
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to damp-spire-06287.
remote:
To https://git.heroku.com/damp-spire-06287.git
! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/damp-spire-06287.git
I am not sure if it is an issue with the bundler version or something else but I need any help if possible. I have tried doing
bundle install and bundle update
and the bundle completes without a hitch. I have been stuck for a while and tried replacing the bundle version to no avail. Thanks in advance!

This error is caused because you have incorrect line endings (CRLF vs. LF) in your repo, which is generally caused when you are working/deploying across Windows and Unix-like environments. Mac/Unix/Linux environments -- which Heroku uses -- use a single linefeed (usually denoted \n) character to terminate a line while Windows uses a carriage return/linefeed pair (\r\n).
If your local repo is on a Windows machine you'll need to convert the files in your repo before pushing to Heroku. You can configure Git to handle the auto-conversion so that you have Windows terminators when you checkout on Windows but maintain the repo with just linefeeds.
To set up the automatic conversion:
% git config --global core.autocrlf input
Git also provides a way to refresh your repo to ensure all the line endings are correct. This can cause merge headaches since this can affect every line in some/all files, so you preferably want to do this on a fully up-to-date repo (i.e., no un-pushed changes).
% git add --renormalize .
% git commit -m "Normalize all the line endings"
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings

Related

How Can I Push My Ruby/Rails App To Heroku?

I'm very new to software programming, so bear with me. I'm taking an online web development course that uses Ruby on Rails via AWS on Cloud9. I've gotten to a point in the course where it's time to push my program to Heroku, but it's not working. As you'll see in the code I attached below, it states "The Ruby version you are trying to install does not exist: ruby-2.3.0." It's an old version of Ruby, so that's understandable. It's an old course, after all.
Naturally, I tried to install a more updated version of Ruby (Ruby 2.7.6) in my virtual workstation, and I received confirmation from my command line that it had installed successfully. Or so I thought. After attempting to deploy the code again to Heroku, I received the same notification - that Ruby 2.3.0 doesn't exist. But I thought I had updated my Ruby version? Meanwhile, I cannot continue the course until this is resolved. Any help would be greatly appreciated. Thank you!
ec2-user:~/environment/saasapp (master) $ git push heroku master
Enumerating objects: 15518, done.
Counting objects: 100% (15518/15518), done.
Compressing objects: 100% (8189/8189), done.
Writing objects: 100% (15518/15518), 38.29 MiB | 42.71 MiB/s, done.
Total 15518 (delta 5945), reused 15518 (delta 5945), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-18 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Ruby app detected
remote: -----> Installing bundler 1.17.3
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: 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-18/ruby-2.3.0.tgz -s -o - | tar zxf - ' failed on attempt 1 of 3.
remote: 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-18/ruby-2.3.0.tgz -s -o - | tar zxf - ' failed on attempt 2 of 3.
remote:
remote: !
remote: ! The Ruby version you are trying to install does not exist: ruby-2.3.0
remote: !
remote: ! Heroku recommends you use the latest supported Ruby version listed here:
remote: ! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
remote: !
remote: ! For more information on syntax for declaring a Ruby version see:
remote: ! https://devcenter.heroku.com/articles/ruby-versions
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 0c41dc02b467640a074f0ffcb8c93cf034e44fad
remote: !
remote: ! We have detected that you have triggered a build from source code with version 0c41dc02b467640a074f0ffcb8c93cf034e44fad
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to secret-shelf-76327.
remote:
To https://git.heroku.com/secret-shelf-76327.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/secret-shelf-76327.git'
The rails version you are currently working in and the rails version present in your bin/rails file is different. you just need to regenerate the binstubs file with your local ruby version.
Run this command to regenerate your bundler file.
bundle binstubs bundler --force
for more info refer the doc here.
https://bundler.io/man/bundle-binstubs.1.html
You can define the ruby version in the Gemfile itself.
source 'https://rubygems.org'
ruby "2.6.5"
Add these lines at the top of your Gemfile and do a bundle install again.

Herokuproblem pushing problem: error: failed to push some refs to 'https://git.heroku.com/wwwwwww.git'

I am trying to push my Rails app to Heroku but it is showing me this error again and again. What is the problem?
Enumerating objects: 140, done.
Counting objects: 100% (140/140), done.
Delta compression using up to 2 threads
Compressing objects: 100% (122/122), done.
Writing objects: 100% (140/140), 145.92 KiB | 1.50 MiB/s, done.
Total 140 (delta 10), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote: Detected buildpacks: Ruby,Node.js
remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.2.21
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-20/ruby-2.7.0.tgz -s -o - | tar zxf - ' failed on attempt 1 of 3.
remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-20/ruby-2.7.0.tgz -s -o - | tar zxf - ' failed on attempt 2 of 3.
remote:
remote: !
remote: ! The Ruby version you are trying to install does not exist on this stack.
remote: !
remote: ! You are trying to install ruby-2.7.0 on heroku-20.
remote: !
remote: ! Ruby ruby-2.7.0 is present on the following stacks:
remote: !
remote: ! - heroku-18
remote: !
remote: ! Heroku recommends you use the latest supported Ruby version listed here:
remote: ! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
remote: !
remote: ! For more information on syntax for declaring a Ruby version see:
remote: ! https://devcenter.heroku.com/articles/ruby-versions
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to first-rails-application11.
remote:
To https://git.heroku.com/first-rails-application11.git
! [remote rejected] dev -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/first-rails-application11.git'
I ran heroku login and heroku create, and after completing some steps I ran git push heroku main and got this error. I also tried git push heroku main: main, but that didn't change anything. Then I created a branch and then for example, dev then I ran git push heroku dev:main but its again failing.
This has nothing to do with how you are pushing to main. Creating a branch and explicitly naming the remote branch when you push won't help.
Take a closer look at the error message:
remote: ! The Ruby version you are trying to install does not exist on this stack.
remote: !
remote: ! You are trying to install ruby-2.7.0 on heroku-20.
remote: !
remote: ! Ruby ruby-2.7.0 is present on the following stacks:
remote: !
remote: ! - heroku-18
remote: !
remote: ! Heroku recommends you use the latest supported Ruby version listed here:
remote: ! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
remote: !
remote: ! For more information on syntax for declaring a Ruby version see:
remote: ! https://devcenter.heroku.com/articles/ruby-versions
remote: !
remote: ! Push rejected, failed to compile Ruby app.
Ruby 2.7.0 is not supported, but if you visit the page mentioned in the error message you should see that version 2.7.3 is supported (at the time of writing).
Update your Gemfile accordingly, commit, and redeploy.

Heroku push rejected because gem checksum failed

I've been pushing updates to my app successfully all week. This morning I went to push another update (just some CSS changes) and suddenly I'm my pushes are being rejected because the checksums on numerous gems seem to be randomly failing. I say randomly because each time I've tried pushing, the failing checksums are for different gems.
I'm not sure if this is a problem with Bundler, RubyGems, or Heroku, but those all seem like obvious candidates. I can't find any mention of similar issues and Heroku seems to have eliminated the ability to submit a support ticket unless you pay for an enterprise support plan.
Any help is greatly appreciated!
Here is the log from the last attempt:
$ git push heroku master
Counting objects: 12, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 1.55 KiB | 1.55 MiB/s, done.
Total 12 (delta 10), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> nginx-buildpack app detected
remote: -----> nginx-buildpack: Installed nginx/1.5.7 to app/bin
remote: -----> nginx-buildpack: Added start-nginx to app/bin
remote: -----> nginx-buildpack: Default mime.types copied to app/config/
remote: -----> nginx-buildpack: Default config copied to app/config.
remote: -----> Image-Optim Buildback app detected
remote: -----> Adding Item-Optim binaries
remote: cp: omitting directory ‘jpegoptim’
remote: ‘advpng’ -> ‘/tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/vendor/image-optim/advpng’
remote: ‘gifsicle’ -> ‘/tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/vendor/image-optim/gifsicle’
remote: ‘jpegtran’ -> ‘/tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/vendor/image-optim/jpegtran’
remote: ‘optipng’ -> ‘/tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/vendor/image-optim/optipng’
remote: ‘pngcrush’ -> ‘/tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/vendor/image-optim/pngcrush’
remote: ‘jpegoptim/jpegoptim-cedar14’ -> ‘/tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/vendor/image-optim/jpegoptim’
remote: -----> Adding image-optim binaries symlink to make them available in next buildpacks
remote: -----> Adding image-optim binaries to PATH
remote: ‘image-optim.sh’ -> ‘/tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/.profile.d/image-optim.sh’
remote: -----> Gemfile detected, adding image-optim config file
remote: ‘image_optim.yml’ -> ‘/tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/.image_optim.yml’
remote: -----> Image-Optim binaries version
remote: advancecomp v1.18 by Andrea Mazzoleni
remote: LCDF Gifsicle 1.78
remote: jpegoptim v1.4.2 x86_64-unknown-linux-gnu
remote: libjpeg-turbo version 1.2.90 (build 20130305)
remote: OptiPNG version 0.7.4
remote: | pngcrush 1.7.15
remote: -----> ImageMagick app detected
remote: -----> Install ImageMagick
remote: -----> Extracting ImageMagick /app/tmp/cache/imagemagick-6.9.9-23.7z.tar.gz => /tmp/build_c96d18fd0f8c4e48e3ec30ced800682d/vendor
remote: -----> Writing policy file
remote: -----> Updating environment variables
remote: -----> ffmpeg app detected
remote: -----> Install ffmpeg
remote: DOWNLOAD_URL = https://www.johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz
remote: exporting PATH
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.5.0
remote: -----> Installing dependencies using bundler 1.15.2
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote: Fetching gem metadata from https://rubygems.org/.
remote: Retrying fetcher due to error (2/4): Bundler::HTTPError The checksum of /info/erubi does not match the checksum provided by the server! Something is wrong (local checksum is "\"a080a1775e4c3f8b72707ef6a2e071b4\"", was expecting "\"5512cda1-50280\"")..
remote: Retrying fetcher due to error (3/4): Bundler::HTTPError The checksum of /info/crass does not match the checksum provided by the server! Something is wrong (local checksum is "\"a080a1775e4c3f8b72707ef6a2e071b4\"", was expecting "\"5512cda1-50280\"")..
remote: Retrying fetcher due to error (4/4): Bundler::HTTPError The checksum of /info/sass-listen does not match the checksum provided by the server! Something is wrong (local checksum is "\"a080a1775e4c3f8b72707ef6a2e071b4\"", was expecting "\"5512cda1-50280\"")..
remote: The checksum of /info/et-orbi does not match the checksum provided by the
remote: server! Something is wrong (local checksum is
remote: "\"a080a1775e4c3f8b72707ef6a2e071b4\"", was expecting "\"5512cda1-50280\"").
remote: Bundler Output: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote: Fetching gem metadata from https://rubygems.org/.
remote: Retrying fetcher due to error (2/4): Bundler::HTTPError The checksum of /info/erubi does not match the checksum provided by the server! Something is wrong (local checksum is "\"a080a1775e4c3f8b72707ef6a2e071b4\"", was expecting "\"5512cda1-50280\"")..
remote: Retrying fetcher due to error (3/4): Bundler::HTTPError The checksum of /info/crass does not match the checksum provided by the server! Something is wrong (local checksum is "\"a080a1775e4c3f8b72707ef6a2e071b4\"", was expecting "\"5512cda1-50280\"")..
remote: Retrying fetcher due to error (4/4): Bundler::HTTPError The checksum of /info/sass-listen does not match the checksum provided by the server! Something is wrong (local checksum is "\"a080a1775e4c3f8b72707ef6a2e071b4\"", was expecting "\"5512cda1-50280\"")..
remote: The checksum of /info/et-orbi does not match the checksum provided by the
remote: server! Something is wrong (local checksum is
remote: "\"a080a1775e4c3f8b72707ef6a2e071b4\"", was expecting "\"5512cda1-50280\"").
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to fply.
remote:
To https://git.heroku.com/fply.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fply.git'

Errors with "git push heroic master", what to do?

So i'm trying to deploy my rails app through heroku. But every time i run "git push heroic master", i run into this. I have searched around, but nothing seems to work. I have tried to "bundle update", "bundle install", but i still get this error when i run "git push heroic master"
Counting objects: 84, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (70/70), done.
Writing objects: 100% (84/84), 20.65 KiB | 1.88 MiB/s, done.
Total 84 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote: Detected buildpacks: Ruby,Node.js
remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.4
remote: -----> Installing dependencies using bundler 1.15.2
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote: You are trying to install in deployment mode after changing
remote: your Gemfile. Run `bundle install` elsewhere and add the
remote: updated Gemfile.lock to version control.
remote: The dependencies in your gemfile changed
remote: You have added to the Gemfile:
remote: * pg
remote: Bundler Output: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote: You are trying to install in deployment mode after changing
remote: your Gemfile. Run `bundle install` elsewhere and add the
remote: updated Gemfile.lock to version control.
remote:
remote: The dependencies in your gemfile changed
remote:
remote: You have added to the Gemfile:
remote: * pg
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to secret-mesa-55611.
remote:
To https://git.heroku.com/******
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/*******.git'
It seems that your Gemfile.lock is changed. Try running bundle install after cleaning the Gemfile.lock

Error in git push heroku master

I have seen many question on Stackoverflow a bit similar to my question but none have faced same problem which I am having while I try to push my app to heroku.
My Ruby On Rails app is created on rails 3.2.17 and ruby v. 1.9.3 and currently it is in local setup I want to push it to heroku server.. but always I keep getting the same error, this is the full response which I am getting in 'git Bash prompt'
$ git push heroku master
Initializing repository, done.
Counting objects: 1708, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1640/1640), done.
Writing objects: 100% (1708/1708), 47.02 MiB | 150.00 KiB/s, done.
Total 1708 (delta 207), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-1.9.3
-----> Warning:
Removing `Gemfile.lock` because it was generated on Windows
Bundler will do a full resolve so native gems are handled p
This may result in unexpected gem versions being used in yo
In rare occasions Bundler may not be able to resolve your d
all.
https://devcenter.heroku.com/articles/bundler-windows-gemfi
-----> Installing dependencies using 1.5.2
Running: bundle install --without development:test --path v
-binstubs vendor/bundle/bin -j4
Fetching git://github.com/gregbell/active_admin.git
Fetching source index from http://ruby.taobao.org/
Resolving dependencies.....................................
Network error while fetching
http://rubygems-china.oss.aliyuncs.com/quick/Marshal.4.8/tr
emspec.rz
Bundler Output: Fetching git://github.com/gregbell/active_a
Fetching source index from http://ruby.taobao.org/
Resolving dependencies.....................................
Network error while fetching
http://rubygems-china.oss.aliyuncs.com/quick/Marshal.4.8/tr
emspec.rz
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app
To git#heroku.com:myapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:myapp.git'
I have solved it by myself, actually in my Gemfile source was set as 'http://ruby.taobao.org' and i guess there was some kind of network conflict between http://ruby.taobao.org and heroku server during the process of installing gems. I changed the source to 'http://rubygems.org' and it worked.

Resources