Heroku: push failing due to gem file - ruby

I have a very simple application that I am trying to push to Heroku and having issues. I don't have any special Gems installed and doing nothing special, but keep getting an error parsing my Gemfile.
I have seen examples adding Gem 'rails_12factor' defining Bundler version, Ruby version, updating bundler, updating system. The error doesn't change after doing any of these fixes. I installed with RailsInstaller recently, so I am running current versions of everything.
Here is my Gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
ruby '~> 2.3.3'
gem 'bundler', '~> 2.0.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.7'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and viewrubys
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', '11.0.1'
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.3.6"
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
This the error I am gettting:
$ git push herokustaging master
Enumerating objects: 300, done.
Counting objects: 100% (300/300), done.
Delta compression using up to 8 threads
Compressing objects: 100% (275/275), done.
Writing objects: 100% (300/300), 59.91 KiB | 1.50 MiB/s, done.
Total 300 (delta 96), 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:
remote: !
remote: ! There was an error parsing your Gemfile, we cannot continue
remote: ! /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
remote: ! from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
remote: ! from /tmp/d20190618-120-vf683l/bundler-2.0.1/bin/bundle:23:in `<main>'
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to sojournsb.

The relevant part of the error message appears to be
can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
You shouldn't need to install bundler on Heroku, and I'm not sure how helpful it is to have in your Gemfile even in development. If you don't have Bundler, how will you run bundle install in the first place?
Try taking bundler out of your Gemfile (and Gemfile.lock), then redeploy.

My problem was that I was using an older version of Ruby that was not compatible with Heroku. I installed the latest version of Ruby, and rebuilt my app. I was then able to push to Heroku successfully.
A pretty simple thing to catch really, but the error message wasn't totally helpful.
Anywho, thanks!

Related

Heroku assets are not loading and seems assets are out of date

I am having an issue where images on my Heroku production site are not being found. I have tracked it down to the digest being different in the file system from what it is looking for in the app. For example, in the logs I see the following errors:
app[web.1]: Started GET "/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg" for 24.55.52.101 at 2016-09-08 23:10:18 +0000
app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg"):
app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/rack/logger.rb:38:in `call_app'
And when I go to the Heroku console and look up the asset using asset_path() I get the following:
$ heroku run rails console
Running rails console on ⬢ fbpm... up, run.7463
Loading production environment (Rails 4.2.5)
irb(main):001:0> puts helper.asset_path("nfl_teams/nfcn/chi.jpg")
/assets/nfl_teams/nfcn/chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
=> nil
irb(main):002:0>
and finally looking at the heroku bash and checking the file in the directory I get:
$ heroku run bash
Running bash on ⬢ fbpm... up, run.7321
cd public~ $ cd public/assets/nfl_teams/nfcn
~/public/assets/nfl_teams/nfcn $ ls chi*.jpg
chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
~/public/assets/nfl_teams/nfcn $
So, in the console looking at the asset path I get the following file:
/assets/nfl_teams/nfcn/chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
And I get the same file when I look in the directory structure. Yet for some reason the application is looking for this file:
/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg
Which doesn't exist and throws a routing error.
Here is my Gemfile:
source 'https://rubygems.org'
ruby '2.2.4'
#ruby-gemset=Rails_fb
gem 'rails','4.2.5'
gem 'bcrypt', '3.1.11'
gem 'annotate'
gem 'faker', '1.6.3'
gem 'select2-rails'
gem 'simple_form', '3.1.1'
gem 'cocoon'
#
# Bootstrap support gems
#
gem 'bootstrap-sass'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'font-awesome-sass', '4.6.2'
gem 'font-awesome-rails'
gem 'sass-rails', '~> 5.0.4'
#gem 'select2-sass-bootstrap-rails'
# The following Gem is used to parse the NFL page for schedules to build
# a season.
gem 'nokogiri'
# Database. Using the same database for production/development
gem 'pg'
group :development, :test do
gem 'rspec-rails', '~>3.0'
gem 'factory_girl_rails', '4.7.0'
gem 'capybara', '2.7.1'
gem 'database_cleaner'
gem 'guard-rspec', '~> 4.2'
gem 'spork-rails'
gem 'guard-spork'
gem 'childprocess', '0.5.8'
gem 'letter_opener_web', '~>1.2.0'
end
group :test do
gem 'pry'
gem 'selenium-webdriver', '2.53.0'
gem 'libnotify', '0.9.1'
end
gem 'uglifier', '2.7.2'
gem 'coffee-rails', '4.1.1'
gem 'jquery-rails', '3.1.4'
gem 'jquery-turbolinks', '2.1.0'
gem 'turbolinks', '2.5.3'
gem 'jbuilder', '2.4.1'
group :doc do
gem 'sdoc', '0.4.1', require: false
end
group :production do
gem 'rails_12factor'
end
# To use debugger
# gem 'debugger'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
And here is the code I'm using to access the images in my views(I've tried it both with and without the asset_path() call):
<%= image_tag(asset_path(team.imagePath), size: "40") %>
Can anyone tell me why the app is looking for the wrong file? Obviously there is some disconnect in the asset pipeline but I can't figure where?
And this problem started after I upgraded from Ruby 2.0.0 to Ruby 2.2.4 which caused me to update a number of my Gems.
Hopefully this helps. In order to force a new precompile of assets on Heroku in Rails 4 you need to do the following:
rake assets:clobber
Rake assets:precompile
Then git commit/push to master and push to Heroku and it should do a new precompile that hopefully will sync up the asset pipeline. Don't use rake assets:clean as it doesn't force a new compile.

jruby Bundler could not find compatible versions json

New to jruby. I am getting error when trying to run
jruby -S bundle exec rake assets:precompile
Bundler could not find compatible versions for gem "json":
In snapshot (Gemfile.lock):
json (1.8.1)
In Gemfile:
carrierwave (>= 0) ruby depends on
json (>= 1.7) ruby
I have tried removing Gemfile.lock and run "jruby -S bundle install", did not help.
I am using jruby 1.7.3 and ruby 1.8.7 on a Mac. I have successfully run precompile before and have not made any changes to the Gemfile.
My Gemfile (has not been changed since last Oct., used to work):
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'activerecord-jdbcmysql-adapter'
gem 'jruby-openssl'
gem 'mini_magick'
gem 'carrierwave'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'bourbon'
#gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyrhino'
gem 'uglifier', '>= 1.0.3'
end
gem 'uuidtools'
gem 'amazon-ses-mailer'
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
Thanks
This looks like a bundler issue. Update Bundler to 1.5.2 and trying again:
jruby -S gem install bundler

Rails 4 - Bundler could not find compatible versions for gem "railties"

I'm having some incompatibility issues with rails and coffee-rails:
Bundler could not find compatible versions for gem "railties":
In Gemfile:
rails (= 4.0.0) x86-mingw32 depends on
railties (= 4.0.0) x86-mingw32
coffee-rails (= 4.0.0) x86-mingw32 depends on
railties (4.0.1)
Here is my Gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
# Version required for this application
gem 'rails', '4.0.0' # Rails framework
gem 'bootstrap-sass', '2.3.2.0' # Used for advanced CSS: open-source Sass add on from Twitter
gem 'bcrypt-ruby', '3.0.1' # Used for password encryption
gem 'pg', '0.15.1' # Used for connection to Postgres
gem 'jquery-ui-rails' # Used to create user interfaces
gem 'crypt' # Used for message encryption
gem 'http_parser.rb', '0.6.0.beta.2' # EM-Websocket dependancy
gem 'eventmachine' # EM-Websocket dependancy
group :assets do
gem 'haml_coffee_assets' # Used for Coffescript template generation
gem 'execjs' # Javascript helper
end
group :development, :test do # Groups define the environment in which the Gem will be needed
gem 'rspec-rails', '2.13.1' # Used for testing/TDD
gem 'guard-rspec', '2.5.0' # Used for automated RSpec testing
end
group :test do # Used within the test environment
gem 'selenium-webdriver', '2.0.0' # Used with RSpec to create automated tests
gem 'capybara', '2.1.0' # Adds more natural syntax to RSpec test scripts, and allows webpage tests
gem 'libnotify', '0.8.0' # Automatic notifications of Guard RSpec test results
gem 'spork-rails' # Used to speed up testing
gem 'guard-spork', '1.5.0' # Required for Guard/Spork compatibility: autostarts a Spork server with Guard
gem 'childprocess', '0.3.6' # Controls external programs
gem 'factory_girl_rails', '4.2.1' # Used mainly for testing Model management
end
gem 'sass-rails', '4.0.0' # Advanced CSS styling
gem 'uglifier', '2.1.1' # minifies Javascript code
gem 'coffee-rails', '4.0.0' # Allows CoffeeScript to adapt to the Assets pipeline
gem 'coffee-script-source', '1.5.0'
gem 'jquery-rails', '2.2.1' # Advanced Javascript functions: added ease of use
gem 'turbolinks', '1.1.1' # Makes following links faster: uses Assets pipeline
gem 'jbuilder', '1.0.2' # Creates JSON structures
group :doc do # required gem
gem 'sdoc', '0.3.20', require: false
end
group :production do # used only within deployment
gem 'rails_12factor', '0.0.2'
end
And gem list railties shows:
PS C:\Users\HP\Ubuntu One\A2 Computing Project\Software Development\Client> gem list railties
*** LOCAL GEMS ***
railties (4.0.1, 4.0.0)
The answer to a previous question I found said that running gem install railties fixed it, but it didnt for me. Any help?
try running bundle update if you had a older version of railtie before.

Heroku push rejected, failed to install gems via Bundler

I am having a problem with pushing my rails project back up to heroku. I was able to do this a few days ago. I made a few changes to my files and tried to re push using git push heroku. It starts the process then gives me these errors.
> Counting objects: 56, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (35/35), done.
Writing objects: 100% (37/37), 3.96 KiB, done.
Total 37 (delta 18), reused 0 (delta 0)
`-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
Fetching source index for https://rubygems.org/
Installing rake (0.9.2.2)
Installing ZenTest (4.7.0) /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:170:in `install': ZenTest requires RubyG
ems version ~> 1.8. Try 'gem update --system' to update RubyGems itself. (Gem::InstallError)
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `block in run'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `block in each'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/bin/bundle:13:in `<top (required)>'
from /usr/ruby1.9.2/bin/bundle:19:in `load'
from /usr/ruby1.9.2/bin/bundle:19:in `<main>'
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
`To git#heroku.com:mbartonsampleapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:mbartonsampleapp.git'
My Gem fils has
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'heroku'
group :development do
gem "ZenTest", "~> 4.7.0"
gem 'sqlite3'
gem 'autotest', '4.4.6'
gem 'rspec-rails', '2.9.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
group :production do
# gems specifically for Heroku go here
gem 'pg'
end
group :test do
gem 'autotest', '4.4.6'
gem 'rspec-rails', '2.9.0'
gem 'webrat', '0.7.3'
gem "spork", '0.9.0'
end
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platform => :ruby
gem 'execjs'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
Your Gemfile looks a bit messed up: the assets group isn’t closed (it’s missing an end), so your production and test groups are nested in it (there’s an extra end after gem 'uglifier' that eventually closes it).
This could be confusing Bundler, so that it doesn’t see ZenTest as being in the development group and tries to install it on Heroku.

Problems with sprockets when deploying Rails 3.1.rc4

I'm sure that I am just overlooking something simple here but this has been driving me crazy all night! When trying to deploy a Rails 3.1.rc4 application to the Cedar stack on Heroku (I did this successfully a month ago with a similar Gemfile) I am receiving this error:
Could not find sprockets-2.0.0.beta.10 in any of the sources
My Gemfile looks like this:
source 'http://rubygems.org'
# Core
gem 'rails', '3.1.0.rc4'
# Asset template engines
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-script'
gem 'uglifier'
# Misc
gem 'devise'
gem 'jquery-rails'
gem 'omniauth'
gem 'fb_graph'
gem 'compass', git: 'https://github.com/chriseppstein/compass.git', branch: 'rails31'
gem 'haml'
gem 'cancan'
gem 'kaminari'
gem 'friendly_id', '~> 3.3.0', git: 'https://github.com/norman/friendly_id.git'
gem 'recaptcha', :require => 'recaptcha/rails'
gem 'aws-ses', '~> 0.4.3', :require => 'aws/ses'
# Local Environment
group :test do
# Pretty printed test output
gem 'turn', :require => false
gem 'sqlite3'
end
# Heroku Environment
group :production do
gem 'pg'
gem 'execjs'
gem 'therubyracer'
end
After searching around and finding this article on Google Groups, I determined that this must be fixable by adding this line
gem 'sprockets', '2.0.0.beta10'
to my Gemfile and then running
bundle update sprockets
This failed with
Could not find gem 'sprockets (= 2.0.0.beta10, runtime)' in any of the gem sources listed in your Gemfile.
and at this point I don't know what to do or how to handle this. Is it possible that I need to upgrade to Rails 3.1.rc5 and if so how may I do that without starting over from scratch?
Thank you for any help that you can provide!
-Robert
Just bump your rails version up to rc5
gem 'rails', '3.1.0rc5'
then:
bundle update

Resources