Unable to deploy Ruby App to Heroku - ruby-on-rails

I'm a noob to this stuff. I just deployed a different app prior to this one so I don't know if that could be the reason. Anyway, I did the standard Heroku steps to deploy but I am getting the following error:
remote: /tmp/build_70ac51f84d237880d076a5b324fee21c/vendor/bundle/ruby/2.4.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
remote: Tasks: TOP => environment
remote: (See full trace by running task with --trace)
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to glacial-island-90844.
remote:
To https://git.heroku.com/glacial-island-90844.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/glacial-island-90844.git'
Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
gem 'sqlite3'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
Heroku Logs:
2018-06-16T11:26:38.801026+00:00 app[api]: Release v1 created by user sbeezynen#gmail.com
2018-06-16T11:26:38.801026+00:00 app[api]: Initial release by user sbeezynen#gmail.com
2018-06-16T11:26:38.953219+00:00 app[api]: Enable Logplex by user sbeezynen#gmail.com
2018-06-16T11:26:38.953219+00:00 app[api]: Release v2 created by user sbeezynen#gmail.com
2018-06-16T11:28:14.000000+00:00 app[api]: Build started by user sbeezynen#gmail.com
2018-06-16T11:28:49.000000+00:00 app[api]: Build failed -- check your build logs
2018-06-16T11:33:13.000000+00:00 app[api]: Build started by user sbeezynen#gmail.com
2018-06-16T11:33:48.000000+00:00 app[api]: Build failed -- check your build logs
Any idea what could be causing this? I can see the heroku app from the Heroku Dashboard. I already did the 'git add -A' 'git commit' and 'git push' too.

There may be some CSS or JS which were enable to compile by precompiler of Heroku(Ruby on Rails). So first try to compile the files locally with enabling production mode and see if it is compiling or not if not then look for the errors it throwing. If not then it must be some configuration issue on heroku.

You can validate your css file or code on given
link
If any error in code then it's show or highlight on line number.

Related

rails cannot load such file -- rake (LoadError)

I want to push my first application in Heroku, but my push failed. I have this error in my shell;
Bundle completed (197.95s)
remote: Cleaning up the bundler cache.
remote: -----> Installing node-v12.16.2-linux-x64
remote: -----> Installing yarn-v1.22.4
remote: Detected manifest file, assuming assets were compiled locally
remote: -----> Detecting rails configuration
remote: -----> Detecting rake tasks
remote:
remote: !
remote: ! Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
remote: ! /tmp/build_edcc391d/bin/rake:4:in `require': cannot load such file -- rake (LoadError)
remote: ! from /tmp/build_edcc391d/bin/rake:4:in `<main>'
remote: !
remote: /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/helpers/rake_runner.rb:106:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
remote: ensure you can run `$ bundle exec rake -P` against your app
remote: and using the production group of your Gemfile.
remote: /tmp/build_edcc391d/bin/rake:4:in `require': cannot load such file -- rake (LoadError)
remote: from /tmp/build_edcc391d/bin/rake:4:in `<main>'
remote: from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:1106:in `rake'
remote: from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails2.rb:85:in `has_jobs_work_task?'
bla bla bla
So, this is my Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.0'
# Use postgresql as the database for Active Record
gem 'pg', '~> 1.1'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
gem 'bcrypt'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
#gem 'bootsnap', '>= 1.5.1', require: true
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'rack-mini-profiler', '~> 2.0'
gem 'listen', '~> 3.3'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'faker'
gem 'table_print'
gem 'bootstrap'
gem 'jquery-rails'
gem 'rake'
gem 'rack-timeout'
I think I tried everything. Here is what I tried for resolve this error;
add gem 'rake' and gem 'rack-timeout' in my Gemfile
bundle install
git commit -m "Modified Gemfile.lock"
add RAILS_SERVE_STATIC_FILES env. to yr server.
RAILS_ENV=production bundle exec rake assets:precompile
(If I run RAILS_ENV=production bundle exec rake assets:precompile, I have this)
sh: /Users/mac/Library/Mobile: No such file or directory
sh: /Users/mac/Library/Mobile: No such file or directory
Warning: you are using an unstable release of Node.js (v15.4.0). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node
Everything's up-to-date. Nothing to do
git add public/assets
git commit -m "vendor compiled assets"
...
But nothing, I have this error again and again ...
If anyone can help me I will be very grateful.
Thank you.
Could you please share your Gemfile.lock?
I faced the same problem and solved it by changing PLATFORMS from x86_64-darwin-19 to ruby.

git push heroku master fails by "HTTP 400 curl 22 The requested URL returned error"

I'm trying to push rails application that shows just "hello, world.".
Then I met an error like below.
I would like to know how to solve this problem.
$git push heroku master
Enumerating objects: 88, done.
Counting objects: 100% (88/88), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (73/73), done.
Writing objects: 100% (88/88), 22.29 KiB | 1.71 MiB/s, done.
Total 88 (delta 2), reused 0 (delta 0)
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400 Bad Request
fatal: The remote end hung up unexpectedly
Everything up-to-date
My procedures are below.
1.create rails application like below.
rails new sample
2.fix routes and application_controller to show hello, world.
3.change Gemfile.
3-1.declare sqlite3 in development and test group
gem 'sqlite3'
3-2.declare pg in production group
gem 'pg', '0.20.0'
4.execute bundle install --without production
5.execute git add .
6.execute git commit -m "initial commit for heroku"
7.confirm if it works by rails s and access to localhost:3000
8.execute heroku login and enter id and password.
9.execute heroku keys:add and the SSH key is created by this operation.
10.execute heroku create
11.execute git push heroku master and then I got the error
Each programs' version is below.
* Rails 5.1.6
* heroku/7.14.1 win32-x64 node-v10.9.0
What is this error and how can I avoid this error?
Please tell me if you need more information.
I added my gem file below.
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
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.6'
# 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
gem 'rails_12factor'
# Use CoffeeScript for .coffee assets and views
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
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
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', '0.20.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
In my case, I had to both change the remote URL to use the git: protocol instead of https:, and I also had to create a public key.
To get the current URL:
git remote get-url heroku
Supposing your URL is something like https://git.heroku.com/your-repo-here.git, you should use this command to use the git: protocol:
git remote set-url heroku git#heroku.com:your-repo-here.git
Create public key:
heroku keys:add
Reference links:
https://stackoverflow.com/a/6059231/679240
https://stackoverflow.com/a/19466075/679240
Run the following command to increase the buffer to 500MB after navigating to the repository:
git config http.postBuffer 524288000
In case it helps anyone, I had this exact same error pushing to Azure. It turned out I'd filled my App Service storage quota.
I deleted a bunch of big files and the problem was solved.

Not being able to push Git files to Heroku

I am new to Ruby on Rails and I am faced with an error message every time I push my git files to Heroku.
The steps I have taken are:
heroku login
heroku keys:add
heroku create
git push heroku master
The error message is as follows:
Could not detect rake tasks
remote: ! ensure you can run `$ bundle exec rake -P` against your app
remote: ! and using the production group of your Gemfile.
remote: ! rake aborted!
Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to project1-app.
remote:
To https://git.heroku.com/project1-app.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project1-app.git'
Gem file:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# 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'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
It looks like you have not updated your bundle may be after some editing in gem file. In order to make your bundle up-to date with your current gem file run below command
(1) bundle install
(2) bundle update
once your bundle is updated you can run
(3) heroku login
(4) heroku create
(5) git add .
(6) git commit -am "some comment"
(7) git push heroku master
(8) heroku open

heroku failing to deploy my app

I am not able to push my rails app on heroku. Below is error message i get when i try to push rails app on heroku.
Ruby app detected Compiling Ruby/Rails sh: 1: Gemfile: not found ! !
There was an error parsing your Gemfile, we cannot continue ! !
[!] There was an error parsing Gemfile: syntax error, unexpected
':', expecting end-of-input - group: production do ! ^. Bundler
cannot continue. ! ! # from
/tmp/build_c114d933dd903e377866500bea22e827/Gemfile:50 ! #
------------------------------------------- ! # ! > group: production do ! # gem 'pg' ! #
------------------------------------------- ! ! Push rejected, failed to compile Ruby app.
This is what my gemfile looks like.
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use sqlite3 as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
gem 'sqlite3'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group: production do
gem 'pg'
gem 'rails_12factor'
end
here was an error parsing Gemfile: syntax error, unexpected ':', expecting end-of-input - group: production
As above log...It is Just syntax error
group: production do
gem 'pg'
gem 'rails_12factor'
end
update it from
group :production do
gem 'pg'
gem 'rails_12factor'
end
Ok I figured it out. You are getting this error because of two mistakes you made in your gem file
(1) you forgot to define version of your gem 'byebug' in your gem file.
(2) you wrotegroup: production do which suppose to be group :production doI am pretty sure you will not be able to run your app locally either until you fix these both issues.
Add gem 'byebug', '3.4.0' in your gem file. you only have gem 'byebug' if you just add '3.4.0' secondly write group :production do instead of group: production do at 4th line from bottom of your gem file
once you add make these changes to your gem file make sure you run bundle install then bundle update
after successfully you do above process you can run below command to upload your app to heroku.
git init
git add .
git commit -am "some comment"
git push heroku master
heroku open

I can't do "git push heroku master"

I get error below when I hit git push heroku master.
remote: Tasks: TOP => assets:precompile
remote: (See full trace by running task with --trace)
remote: !
remote: ! Precompiling assets failed.
remote: !
remote:
remote: ! Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy....
remote:
remote: ! Push rejected to xxx
remote:
To https://git.heroku.com/xxx.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/xxx.git'
My gem file is below.
source 'https://rubygems.org'
ruby '2.3.0'
gem 'rails_12factor', group: :production
gem 'bootstrap-sass'
gem 'rails', '4.2.5.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :production, :staging do
gem 'unicorn'
end
group :development, :test do
gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-rbenv'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
gem 'sqlite3'
end
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
I don't know why I got rejected to push my rails app to heroku. I think my Gemfile is alright though. if someone knows solutions for this. I would really appreciate.
The error indicates that there are changes which are newer than commits you have in local.
To solve this:
Pull merge heroku to your local first, then try push to heroku again
Push force to heroku if you are sure that your local is the newest one!
I'll add onto Heiu Pham's answer and say that in Heroku, you may have problems with pushing to the master branch (if you are behind in history for example). What you can do is to start a new branch using
git checkout -b tempbranch and then push using
git push heroku tempbranch
If you are absolutely sure there are no newer refs, you can try
git push heroku -f
If this still doesn't work, check $ heroku logs for a hint to what the problem may be.

Resources