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
Related
Something has changed recently on Heroku. I can't deploy my app as I've done before:
me#host my-project (master) $ git push staging master
Counting objects: 52, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (52/52), 159.47 KiB | 0 bytes/s, done.
Total 52 (delta 42), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Deleting 4 files matching .slugignore patterns.
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.0
remote: -----> Installing dependencies using bundler 1.13.6
remote: Your app was upgraded to bundler 1.13.6.
remote: Previously you had a successful deploy with bundler 1.11.2.
remote:
remote: If you see problems related to the bundler version please refer to:
remote: https://devcenter.heroku.com/articles/bundler-version
remote: Ruby version change detected. Clearing bundler cache.
remote: Old: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
remote: New: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Your Ruby version is 2.3.0, but your Gemfile specified 2.2.0
remote: Bundler Output: Your Ruby version is 2.3.0, but your Gemfile specified 2.2.0
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 my-project-staging.
remote:
To https://git.heroku.com/my-project-staging.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-project-staging.git'
I don't get it, i'm using ruby 2.2.0 since the beginning:
me#host my-project (master) $ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
me#host my-project (master) $ cat .ruby-version
2.2.0
me#host my-project (master) $ cat Gemfile | grep 'ruby'
ruby '2.2.0'
I don't know how to tell bundler I'm still using ruby 2.2.0. My bundler have this in the bottom:
RUBY VERSION
ruby 2.3.0p0
BUNDLED WITH
1.12.1
Why bundler doesn't use the ruby 2.2.0 version? It's using 2.3.0 instead...
Check your Gemfile.lock. Recent versions of bundler add both the ruby version and bundler version that were used install the gems (and generate the Gemfile.lock).
At the bottom you'll find:
RUBY VERSION
ruby 2.3.0
BUNDLED WITH
1.13.1 # or whatever version of bundler you're using
Remove this, and re-run bundle install with the correct version of ruby - you may need to remove + re-add a gem to trigger a re-build of the Gemfile.lock file.
Finally I add to remove bundler and install the same version as Heroku.
Sometimes bundler doesn't generate in Gemfile.lock
RUBY VERSION
ruby 2.x.x
In that case, just add that entry manually inside the Gemfile.lock file commit and push it to master. Heroku will take that version and build.
I have a sinatra rack ruby app that I want to deploy on heroku. The app needs to connect to an SQL Server Database. For that I need the TinyTds gem.
Gemfile
source 'http://rubygems.org'
ruby "1.9.3"
gem 'sinatra'
gem 'tiny_tds'
Gemfile.lock after bundle install
GEM
remote: http://rubygems.org/
specs:
rack (1.6.0)
rack-protection (1.5.3)
rack
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
tilt (1.4.1)
tiny_tds (0.6.2)
PLATFORMS
ruby
DEPENDENCIES
sinatra
tiny_tds
TinyTds requires FreeTDS which heroku doesn't have apparently. So there are some crazy solutions on the internet with static compiles in heroku-similar VMs and stuff like that. The most reasonable solution was to set a custom buildpack for my app that includes FreeTDS:
heroku create my_new_app --buildpack https://github.com/firmhouse/heroku-buildpack-ruby-freetds.git
However
$ git push heroku master
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching custom git buildpack... done
remote: -----> Ruby/Rack app detected
remote: Installing freetds into /tmp/build_7b7e059c43475a97d6c091bcf9162e16/vendor/freetds
remote:
remote: % Total % Received % Xferd Average Speed Time Time Time Current
remote: Dload Upload Total Spent Left Speed
remote: 100 3590k 100 3590k 0 0 17.8M 0 --:--:-- --:--:-- --:--:-- 17.8M
remote:
remote: -----> Using Ruby version: ruby-1.9.3
remote: -----> Installing dependencies using Bundler version 1.7.12
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --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 http://rvm.io/packages/openssl.
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote:
remote: ! Push rejected, failed to compile Ruby/Rack app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to my_new_app.
remote:
To https://git.heroku.com/my_new_app.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my_new_app.git'
Edit: My question is how do I get heroku to work with tiny_tds.
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.
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
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.