BUNDLE_WITHOUT is not applied when deploying app on Heroku - heroku

My goal is to deploy an app on Heroku for the environment 'heroku_production'.
My Gemfile looks like this:
source 'https://rubygems.org'
gem 'rails', '3.2.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test, :production do
gem 'sqlite3'
end
# This is needed in case this app is deployed in Heroku - in order to make the Heroku deployment independent from the production environment
group :heroku_production do
gem 'pg'
end
...
I set the BUNDLE_WITHOUT variable to "development:test:production". Here is the output when calling heroku config --app my_app:
=== my_app Config Vars
BUNDLE_WITHOUT: development:test:production
DATABASE_URL: postgres://XXXXXXX....
HEROKU_POSTGRESQL_CYAN_URL: postgres://XXXXXXX....
RACK_ENV: heroku_production
RAILS_ENV: heroku_production
But when I push my stuff to Heroku the BUNDLE_WITHOUT var is not applied as you can see in the following error message (line 3: --without development:test):
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.4)
...
Using pg (0.14.1)
Installing sqlite3 (1.3.7)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.7'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
To git#heroku.com:my_app.git
! [remote rejected] 3dac67374c268d3bf9e051a6db39efc56ae81c76 -> master (pre-receive hook declined)
Why is Heroku doing that?
Googling didn't help as well.

Please note - for the time being, the Cedar stack does not support BUNDLE_WITHOUT.
From: https://devcenter.heroku.com/articles/bundler#specifying-gems-and-groups

I recently contacted Heroku about this issue, and they say that BUNDLE_WITHOUT now works!
Here's the response I got:
Hi,
user_env_compile is deprecated, but the functionality of this just became default for the Ruby buildpack - so you can use BUNDLE_WITHOUT config var.
I believe that you saw this article, but is that correct? https://devcenter.heroku.com/articles/bundler#specifying-gems-and-groups
Seems like we need to update that document!
Best,
[name redacted]
Haven't tried it yet but will soon.

Related

How do I fix a Bundler Conflict when pushing to Heroku?

I'm attempting to deploy a Sinatra app to Heroku. Everything works locally. However I get an issue with bundler when I try to push it successfully to Heroku.
I've tried to delete the Gemfile lock and then the following
bundle update
git add .
git push "Gemfile.lock"
git push heroku master
gem install bundler:2.0.1
bundle install
git add .
git push "Gemfile.lock"
git push heroku master
bundle update --bundler
git add .
git push "Gemfile.lock"
git push heroku master
Here is my gemfile
source "https://rubygems.org"
# gem "rails"
gem 'sinatra'
gem 'activerecord', '~> 5.2', '>= 5.2.2.1'
gem 'rake'
gem 'sinatra-activerecord'
gem 'require_all'
gem 'bcrypt'
gem 'rack-flash3'
gem 'rb-readline'
group :development, :test do
gem 'sqlite3'
gem 'shotgun'
gem 'pry'
end
group :production do
gem 'pg'
end
Here are the error messages
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rack
remote: -----> Using Ruby version: ruby-2.5.5
remote: -----> Installing dependencies using bundler 2.0.2
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Activating bundler (2.0.1) failed:
remote: Could not find 'bundler' (2.0.1) required by your /tmp/build_77505ef74596fc4dddd66c8b792d759b/Gemfile.lock.
remote: To update to the latest version installed on your system, run `bundle update --bundler`.
remote: To install the missing version, run `gem install bundler:2.0.1`
remote: Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information
remote:
remote: To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
remote: Bundler Output: Activating bundler (2.0.1) failed:
remote: Could not find 'bundler' (2.0.1) required by your /tmp/build_77505ef74596fc4dddd66c8b792d759b/Gemfile.lock.
remote: To update to the latest version installed on your system, run `bundle update --bundler`.
remote: To install the missing version, run `gem install bundler:2.0.1`
remote: Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information
remote:
remote: To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
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 infinite-waters-69714.
remote:
To https://git.heroku.com/infinite-waters-69714.git
! [remote rejected] master -> master (pre-receive hook declined)
Additionally, I've tried to remove sqlite3 altogether and repeat the above processes.
Any ideas on how to fix this?
I've ran into this issue some time ago: I contacted Heroku and they told me they have a locked version of Bundler, so your only option is to use the Bundler version they use:
gem uninstall bundler
gem install bundler -v 2.0.2
bundle update

Gemfile error when deploying GitHub repo to Heroku

I'm trying to push my GitHub repo to Heroku.
Apparently my Gemfile is incorrect. I've checked it twice, and find no typos or anything, but it complains about rb-inotify being added and removed.
Here's the log:
Ruby app detected
Compiling Ruby
Using Ruby version: ruby-2.2.4
Installing dependencies using bundler 1.11.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
You have added to the Gemfile:
* rb-inotify
You have deleted from the Gemfile:
* rb-inotify
Bundler Output: You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
You have added to the Gemfile:
* rb-inotify
You have deleted from the Gemfile:
* rb-inotify
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app

Bundle fails, undefined method `ruby' when deploying to heroku

I'm trying to deploy a Rack app to heroku and it's failing on the bundle step:
-----> Fetching custom git buildpack... done
-----> Ruby/Rack app detected
-----> Using RUBY_VERSION: ruby-1.9.3-p0
-----> Installing dependencies using Bundler version 1.1.rc.7
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
/tmp/build_158s9o0ec0gdk/Gemfile:2:in `evaluate': undefined method `ruby' for #<Bundler::Dsl:0x00000001c7c418> (NoMethodError)
(...)
/app/bin/bundle:23:in `load'
/app/bin/bundle:23:in `<main>'
There was an error in your Gemfile, and Bundler cannot continue.
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rack app
The failure is undefined method 'ruby' for #<Bundler::Dsl:0x00000001c7c418> (NoMethodError)
This comes from my Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
I assume it's being caused by the fact that that method wasn't added to Bundler until version 1.2 and heroku seems to be using version 1.1.rc.7.
I don't know how to upgrade the heroku version of bundler. I'm already on the Cedar stack.
The log says Fetching custom git buildpack – it looks like you’re using a custom buildpack, which might explain why the old version of Bundler is being used.
Does
heroku config:get BUILDPACK_URL
show anything? You might just need to stop using the custom buildpack, try
heroku config:unset BUILDPACK_URL
to clear the config var and revert to the normal buildpack.

Bundle Install works - but git push heroku master gives errors

Bundle install worked. But when I git push heroku master, I got this:
C:\Sites\first_app>git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.132' t
list of known hosts.
Counting objects: 65, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (65/65), 26.10 KiB, done.
Total 65 (delta 3), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.2
Running: bundle install --without development:test --path vendor/bun
-binstubs bin/
Fetching gem metadata from https://rubygems.org/.........
Bundler could not find compatible versions for gem "railties":
In Gemfile:
rails (= 3.2.1) ruby depends on
railties (= 3.2.1) ruby
jquery-rails (= 2.0.0) ruby depends on
railties (3.2.3)
Failed to install gems via Bundler.
Heroku push rejected, failed to compile Ruby/rails app
To git#heroku.com:evening-frost-9408.git
[remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:evening-frost-9408.git'
Here is my Gem file:
source 'https://rubygems.org'
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do
gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
I'm basically following Ruby on Rails tutorial. But the rails I have is 3.2.1, but the online book says rails 3.2.3. I tried changing it to 3.2.3 and ~>3.2.3, I still get the same error message
Thanks
I had the same problem, I could not run 'bundle install' and same problem when trying to deploy on heroku (and I'm following the same tutorial).
Found a good answer here: rubygems.org does not serve HTTPS, so change the header of your gemfile from https://rubygems.org to http://rubygems.org.
I had a similar problem and figured I'd add my solution.
Originally my main project was seperated into gems that were included into the main project. As the coupling between the gems and the project increased, it made sense to bring the code for the gems directly into /lib of the main rails project. During the merge, the .gitignore files were merged without any conflicts. Unfortunately, a .gitignore for a gem is very different than for a standalone project. As I proceeded, when I updated a gem locally it would fail on the remote push deploy to Heroku. It turns out the .gitignore from the gem had things like Gemfile.lock and *.gem in it.
TLDR; make sure your .gitignore file is sane

Heroku Deploy can't find devise-1.4.6

Trying to deploy to Heroku but get the following error:
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
Fetching source index for http://rubygems.org/
Could not find devise-1.4.6 in any of the sources
FAILED: http(preventing hyperlink)://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
I have "gem 'devise'" in my gem file, have "source 'http://rubygems.org'" at the top, and have run both bundle install and bundle update. Not sure why Heroku is looking for 1.4.6. Any ideas?
Thanks!
John
Here is the gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.9'
gem 'devise'
gem 'sqlite3', '1.3.3', :group => :development
Looks like devise 1.4.6 is no longer at Rubygems.com: http://rubygems.org/gems/devise/versions
I tried using devise 1.4.5, but it didn't work either.
You need to update the locked version of Devise in your Gemfile.lock.
$ bundle update devise
Then commit, push and deploy to Heroku.

Resources