Can't deploy Rails app to Heroku, "Invalid RUBY_VERSION" - ruby-on-rails

I'm trying to push my app to Heroku, but I can't get past this error:
Delta compression using up to 2 threads.
Compressing objects: 100% (1554/1554), done.
Writing objects: 100% (1652/1652), 23.93 MiB | 369 KiB/s, done.
Total 1652 (delta 859), reused 0 (delta 0)
-----> Ruby/Rails app detected
!
! Invalid RUBY_VERSION specified: There-was-an-error-in-your-Gemfile,-and-Bundler- cannot-continue.
! Valid versions: ruby-2.0.0, ruby-1.9.3, ruby-1.9.2, ruby-1.8.7, ruby-1.9.3-jruby- 1.7.0, ruby-1.8.7-jruby-1.7.0, ruby-1.9.3-jruby-1.7.1, ruby-1.8.7-jruby-1.7.1, ruby-1.9.3-rbx-2.0.0dev, ruby-1.8.7-rbx-2.0.0dev
!
! Push rejected, failed to compile Ruby/Rails 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'm running ruby 1.9.3p448. I followed the steps here, and the top of my Gemfile includes:
source 'http://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.13'
When I run "heroku run 'ruby -v'" it returns ruby 1.9.2p290. What's going on?
Edit: Here's my whole Gemfile:
source 'http://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.13'
gem 'pg'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'devise'
gem 'nokogiri'
gem 'i18n'
gem 'paperclip'
gem 'kaminari'
gem 'rest-client'
require 'addressable/uri'
group :development do
gem 'better_errors'
end

You have an error in your Gemfile, in the line require 'addressable/uri'. You can’t use require inside a Gemfile. The load path hasn’t been set up yet, so you get a LoadError which Bundler catches and produces an error message.
Heroku is trying to use bundle platform --ruby to determine the version of Ruby you want to use, but is not properly detecting the error condition and treating the error message as the version. This is obviously not a valid version, and so it produces the error you are seeing.
I’m guessing you’re using require because to use the Addressable gem you need to require either addressable/uri or addressable/template (or both) and you can’t just use require 'addressable'. In this case you can use the :require option of Bundler:
gem 'addressable', :require => 'addressable/uri'
If you do need to require more than one thing, you can use an array:
gem 'addressable', :require => ['addressable/uri', 'addressable/template']

Just wondering if this changes your situation, as your Gemfile almost looks like mine, but for these changes.
1)Of course, assuming you are in your Rails Root folder and your less Gemfile is the actual one above. You did also bundle too after changes.
2) change
source 'https://rubygems.org'
3) optional Heck, try switching version to ruby '2.0.0' just to get passed it.
4) I think this is needed too:
gem 'rails_12factor'
All these tricks should make it work at least.
EDIT
Why is require 'addressable/uri' there? remove this and add gem 'addressable' instead.

Related

Bundler Rails 4.0 App Error When Pushing to Heroku

Before this question gets closed as duplicate let me first say that I have tried multiple solutions presented in questions of similar nature. I am working through the Ruby on Rails 4.0 Tutorial and I have gotten as far as pushing my code to Heroku. However, whenever I run the following:
$ git push heroku master
I get the following:
Counting objects: 74, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (63/63), done.
Writing objects: 100% (74/74), 15.59 KiB, done.
Total 74 (delta 11), reused 0 (delta 0)
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
/usr/bin/env: ruby1.9.1: No such file or directory
Bundler Output: /usr/bin/env: ruby1.9.1: No such file or directory
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby/Rails app
To git#heroku.com:example.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:example.git'
I have tried several things including changing my Gemfile (see below)
Gemfile :
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3'
end
# Use SCSS for stylesheets
gem 'sass-rails', '4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.1.1'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails', '2.2.1'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks', '1.1.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '1.0.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
end
gem 'rails_12factor', group: :production
and editing the configuration variables
$ heroku config:set GEM_PATH = vendor/bundle/ruby/1.9.1
$ heroku config:set PATH = bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
I have also tried running bundle from Heroku using
$ heroku run "bundle update"
However I get this error
bash: bundle: command not found
I have also checked my logs but those are only good for post deployment problems.
Does anyone know how to fix this problem?
Perhaps there is a missing file or directory on the Heroku side of things.
It appears that in order to solve this problem you need to turn off Bundler's stub generator, because Rails 4 apps do not store stubs in the app's bin/ directory. In order to do this use the following commands:
$ bundle config --delete bin
Then you need to update the bin directory to use the new Rails 4 executables
$ rake rails:update:bin
Then add the new bin/ directory to your version control using:
$ git add bin
Commit the changes and push your code to Heroku

heroku push rejected, failed to compile Ruby/rails app

Having the following issue, BRAND NEW TO RoR, first time ever trying to upload an app to go live, first had hosting issues, then decided if i could fix them with heroku i would just use a custom domain with heroku...... No this isnt a test app "learning rails" thing, actual app i want to deploy for use within the business I own, any help would be great, I have searched and havent seen a solution to this problem.
Make sure '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:peaceful-chamber-6371.git
[remote rejected] master -> master <pre-receive hook declined>
error: failed to push some refs to 'git#heroku.com:peaceful-chamber-6371.git
Gem File
source 'https://rubygems.org'
gem 'rails', '3.2.12'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
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'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
gem 'twitter-bootstrap-rails'
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 'debugger'
try this,
remove Gemfile.lock file and do bundle install , then git add, git commit and git push .
Look though the all of the output that Heroku writes to the console -- your error is likely to be there somewhere. I ran into this and found that the precompile step had failed. That can be run locally as well:
rake assets:precompile
Although the question has an accepted answer, the answer did not help me,
I had the same problem. The following worked for me, hence contributing. Heroku does not support sqlite 3. In this case, I had sqlite3 gem in my gemfile, which you are supposed to put in development group, and put postgres gem (which heroku supports) in production group.
1) Delete the gemfile.lock file (from your project folder)
2) In the gemfile, remove gem sqlite3 or similar sqlite3 gem
3) Instead of that add following to the end of file:
group :development, :test do
gem 'sqlite3'
end
gem 'pg', group: :production`
Now, run the following commands in terminal:
bundle install
git add .
git commit
git push
git push heroku master
Although it was a silly mistake, It took me time to realize the same. Hope it helps someone.
Heroku's asset plugins no longer work since Rails 4 does not support plugins. You need to use Heroku's asset gems instead. Place this in your Gemfile:
group :production do
gem 'rails_12factor'
end
Answer found here: Heroku does NOT compile files under assets pipelines in Rails 4 worked for me
My issue was that I had my bower directory ignored in .gitignore.
So I either need to do bower install from my packages.json or check in my bower dir.
http://xseignard.github.io/2013/02/18/use-bower-with-heroku/
I chose to check in my bower dir for a quick solution right now.
Heroku does not like sqlite3, change gem 'sqlite3' with gem 'pg'
For M1 users,
bundle lock --add-platform x86_64-linux
to resolve the architecture conflict

Rails bundler: "Could not find tilt-1.3.5 in any of the sources"

I have never encountered this problem before so I really don't know where to start looking for answers... despite Google ofcourse which seems to be an empty road concerning this topic.
When I try to push my application to heroku I get this message:
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.3.0.pre.5
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/..
Could not find tilt-1.3.5 in any of the sources
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
I have destroyed my gemset and started over numerous amounts of times, as well as flat-out required tilt in my Gemfile, but no luck, I still get this message.
Like I said, I have never got this error until yesterday and assumed it was a minor bug that would be fixed. Seems as if that isn't the case, and I am scratching my head trying to figure out what needs to be done to fix this issue.
Any suggestions?
EDIT GEMFILE
source 'https://rubygems.org/'
gem 'rails', '3.2.12'
gem 'thin'
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'bootstrap-sass'
gem 'will_paginate'
gem 'bootstrap-will_paginate'
gem 'jquery-rails'
gem 'rails_autolink'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg', '0.14.1'
end
I am getting the same error. As iRichLau noted in this comment, locking to 1.3.4 or 1.3.6 works.
In Gemfile:
gem 'tilt', '1.3.4' # or '1.3.6' is now out and also works.
Then bundle:
bundle update tilt
Make sure the commit message is commensurate with the ridiculousness of this phantasmal error. ;)
running bundle update and then git add before pushing should fix it
This happened to me when I had 2 different version of the brightbox gem.
The newer brightbox gem requires a newer version of bundle.
So in the top of my deploy.rb I forced the brightbox gem version to be:
gem 'brightbox', '2.3.8'

Heroku push rejected: can't find jquery-rails-2.0.0 in sources

I'm trying to push an Enki gem blog to Heroku and I'm getting an error
Could not find jquery-rails-2.0.0 in any of the sources
However, in the Gemfile I had
`gem 'jquery-rails'`
and I've never had a problem pushing an Enki blog with this setup before. Here's the full error message
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Fetching gem metadata from https://rubygems.org/.......
Could not find jquery-rails-2.0.0 in any of the sources
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
After I got the error message I added this to the gemfile
gem 'jquery-rails-2.0.0'
I got this error message
Could not find gem 'jquery-rails-2.0.0 (>= 0) java' in the gems available on this machine.
I then tried to do
gem install jquery-rails
It gave me
Successfully installed jquery-rails-2.0.2
1 gem installed
Installing ri documentation for jquery-rails-2.0.2...
Installing RDoc documentation for jquery-rails-2.0.2...
But the push didn't work, same error
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.rc
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Fetching gem metadata from https://rubygems.org/.......
Could not find jquery-rails-2.0.0 in any of the sources
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
this is the gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem 'heroku'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# 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'
gem 'uglifier', '>= 1.0.3'
end
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :production do
gem 'thin'
end
platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
gem 'trinidad'
gem 'jruby-openssl'
end
gem 'jquery-rails'
#gem 'jquery-rails-2.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
# Bundle the extra gems:
gem 'RedCloth', '~> 4.2.9', :require => 'redcloth'
gem 'ruby-openid', :require => 'openid'
gem 'rack-openid', :require => 'rack/openid'
gem 'aaronh-chronic', :require => 'chronic' # Fixes for 1.9.2
gem 'coderay'
gem 'lesstile'
gem 'formtastic'
gem 'will_paginate', '~> 3.0.2'
gem 'exception_notification', '~> 2.5.2'
gem 'open_id_authentication'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :test do
gem 'database_cleaner'
gem 'cucumber-rails', :require => false
gem 'cucumber-websteps', :require => false
gem 'factory_girl'
gem 'rspec'
gem 'nokogiri', '~> 1.5.0'
gem 'webrat'
end
group :development, :test do
gem 'rspec-rails'
end
I was getting this same error and fixed it using:
bundle update jquery-rails
In looking into it, it appears that jquery-rails 2.0.0 was yanked from rubygems: http://d.pr/i/cLms/1ReBI4U8 for whatever reason. So you (and I) likely happened to install jquery-rails when that gem was the most current version.
It's also wise to note that deleting your Gemfile.lock can be dangerous and not recommended in most cases. This causes all the latest versions of every gem without a version number in your Gemfile to be downloaded. If gems have been updated with API-breaking changes (happens more often than you might think), your app could break. But it also might not. Just be careful, run test cases if you have them. This has caused me more than one headache.
You can read a bit more about how bundler, Gemfile, and Gemfile.lock work (as well as guidance on how to properly upgrade certain gems) here: http://viget.com/extend/bundler-best-practices
Worked for me:
delete the Gemfile.lock
removed the rails version from the line => gem 'rails' (jquery was already without a v number)
run the command "bundle install"
run also "bundle update jquery-rails" to make sure everything is updated
IMPORTANT, commit the new .lock file => run the "git add ." and "git commit ..."
push everything
Update:
I am going through mhartl's Rails Tutorials and had to update jquery-rails, '2.0.1' in the Gemfile, to get the bundle update jquery-rails going.
Thanks,
Jatin
i had similar issue by changing in Gemfile jquery-rails-2.0.0 to 2.0.1 will solved my problem.
Michael,
I had to remove the version number from my jquery gem from 2.0.0 and let it pull the latest for this to work. I am on rails 3.2.8.rc2 and running on the cedar stack of heroku. Best of luck!
Mark

Heroku push rejected - Hartl's Rails 3.2 tutorial

I am a ruby, ruby on rails and heroku greenhorn, which is trying to learn to code from Michael Hartl's Ruby on Rails 3.2 tutorial.
Now at the very beginning of this chapter I failed to deployed all to Heroku. This error message I got (but I have no plan what to do to solve this problem):
$ git push heroku master
Counting objects: 69, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (54/54), done.
Writing objects: 100% (69/69), 27.34 KiB, done.
Total 69 (delta 5), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.rc
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/
Fetching gem metadata from https://rubygems.org/........
Bundler could not find compatible versions for gem "railties":
In Gemfile:
rails (= 3.2.6) ruby depends on
railties (= 3.2.6) ruby
jquery-rails (= 2.0.0) ruby depends on
railties (3.2.7.rc1)
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
To git#heroku.com:pacific-anchorage-8098.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:pacific-anchorage-8098.git'
My Gemfile looks like this:
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.10.0'
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'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'capybara', '1.1.2'
end
group :production do
gem 'pg', '0.12.2'
end
# 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'
I hope someone could help me out (sorry, I am a beginner --> also at Stackoverflow, lol).
KR, Fabian
The default generated Gemfile (with rails 3.2.6) does not specify a jquery-rails version to use. I would recommend doing the same, like so:
# remove version number, just like you would see in a fresh rails app
gem 'jquery-rails'
The version you have required, 2.0.0, relies on railties 3.2.7.rc1 gem, which you can't use with rails 3.2.6.
I used your code in my app, and couldn't get it to bundle on my local host. This makes me wonder if you tried that too yourself before pushing to heroku. You should always bundle install on your local machine first.
Also, you appear to have bumped the required version numbers of sass-rails and coffee-rails. Here's what you'd expect in a clean rails app's Gemfile:
# 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'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
I could now solve the problem by myself. This was the way:
Go to Gemfile and change the section with gem 'rails', '3.2.6' to gem 'rails', '3.2.7rc1'.
save
run bundle install --without production
run git add .
commit to git like git commit -a -m "Heroku recommit
push to github like git push and follow the instruction for username and password
and last git push heroku master
Wow, this was hard, but very educational :-)
The problem is the jquery-rails gem needs a different version of railties than the rails gem in your bundle file. You can try to remove the "2.0.0" from jquery-rails and try again. Bundle will install a version of the gem which works wit version 3.2.6 of railties.

Resources