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
Related
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.
I am working through chapter 1 of Hartl's Rails 4.0 tutorial, and I'm stuck on Section 1.4.2, which is to push a black app into GitHub and Heroku.
I tried typing git push heroku master, but I get an error message, similar to a previous question on StackOverFlow:
Heroku push rejected - Hartl's Rails 3.2 tutorial
Heroku push rejected, railties dependency conflict? Ruby on Rails Tutorial Section 1.4.2
It's probably the same but I don't even realize it:
-----> Ruby/Rails app detected
-----> 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
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/Rails app
Here is the Gemfile I used:
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '4.0.0.rc1'
group :development do
gem 'sqlite3', '1.3.7'
end
gem 'sass-rails', '4.0.0.rc1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '2.2.1'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
end
UPDATE: The main error seems to be /usr/bin/env: ruby1.9.1: No such file or directory Is that folder on the Heroku machine or my home computer ?
I tried removing the line ruby '1.9.3' from my .gitignore but it still returns this message.
First, Remove ruby 1.9.3 from the Gemfile. You don't need it and may be the cause of your problem. Start of your Gemfile should look like this:
source 'https://rubygems.org'
gem 'rails', '4.0.0.rc1'
group :development do
gem 'sqlite3', '1.3.7'
end
etc........
Also, make sure you run
bundle install --without production
since you are using sqlite3 in :development and postgresql in :production
I had a similar problem. The issue is that Bundler is generating stubs. Rails 4 apps do not store stubs in the app's bin/ directory. In order to fix this problem you need to 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
i had the same problem and the problem was that i didn't chose the version of ruby that i want to use, so i did the following:
$rvm list
ruby-1.9.3-p392 [ i686 ]
ruby-2.0.0-p247 [ i686 ]
$rvm use ruby-1.9.3-p392
$rvm list
=> ruby-1.9.3-p392 [ i686 ]
ruby-2.0.0-p247 [ i686 ]
i'm new to Ruby on Rails, app is running on local machine
local bundle works
however when i try to git push heroku master, this is the error i get:
remote:
remote: -----> Ruby/Rails app detected
remote: -----> Using Ruby version: ruby-1.9.3
remote: -----> Installing dependencies using
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
remote: /usr/bin/env: ruby1.9.1: No such file or directory
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Heroku push rejected, failed to compile Ruby/rails app
remote:
my gemfile:
source 'http://rubygems.org'
ruby '1.9.3'
gem 'rails', '4.0.0.beta1'
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails'
end
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'
gem 'therubyracer', platforms: :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.0.1'
group :test do
gem 'capybara'
end
group :production do
gem 'pg'
end
what am i missing? thanks in advance!
I had a similar problem. The issue is that Bundler is generating stubs. Rails 4 apps do not store stubs in the app's bin/ directory. In order to fix this problem you need to 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
the issue is with your ruby PATH. so first see what happens when you run
$ heroku run "ruby -v"
Running `ruby -v` attached to terminal... up, run.8734
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
Do you get similar output? If not, then check your path.
$ heroku config -s | grep PATH
GEM_PATH=vendor/bundle/ruby/1.9.1
PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
notice, how bin is in the path. in case its missing from yours, you can manually set PATH and add the bin by following command.
$ heroku config:set PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
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
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.