I can't deploy! Resolve an error that can't be pushed to heroku (Rails Tutorial Chapter 1)

Keep track of any errors that occur as you progress through the rails tutorial. The hardware uses MacBook Air, and the development environment uses VScode.

Rails Tutorial Chapter 1 1.5 Deploy

"OK, deploy! It's similar to pushing to GitHub!" "You can do this !!!!!!"

$ heroku login
$ git init
$ heroku git:remote -a app name
$ git add .
$ git commit -am "first commit"
$ git push heroku master

: small_red_triangle_down: Result

$ git push heroku master
~abridgement~
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
~abridgement~
remote:        Could not create Makefile due to some reason, probably lack of necessary
~abridgement~
remote:        An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.
~abridgement~
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     Detected sqlite3 gem which is not supported on Heroku:
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to tutorial-app-20200717.
remote: 
To https://git.heroku.com/app name.git
 ![remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/app name.git'

And you will have a headache.

After pushing to git, I'll deploy to heroku! It is an error that people who rushed forward as it is are addicted to.

This error occurs because ** Heroku doesn't support SQLite. So change the database to PostgreSQL. ** **

"OK! I'll do it because I know the solution!", 1.5.1 Heroku setup and Beginner .. Heroku keeps failing to build. .. , but it doesn't work ...

** If you haven't tried the methods on the above site, you'll have to start over, but as a last resort, try the following: ** **

Solution

Specify the database for PostgreSQL at the rails new stage!

Please note that it will be a solution to start over again ... "Everyone can do it!"

Let's do it right away.

Change before


$ rails _5.1.6_new app name

After change


$ rails _5.1.6_new app name--database=postgresql

Doing this will generate a rails framework with PostgreSQL specified from the beginning.

After that, you can proceed with the same procedure as before. Once you're done, try pushing to heroku.

At this point, you should be able to deploy to heroku without any problems.

If you find it useful, I would be grateful if you could click the ** LGTM button. ** ** Let's do our best to learn Rails together! : raised_hand_tone1:


By the way, if you do this operation in rails6 without specifying the version of rails, you will get the following error.

$ rails s

 Try to access [localhost: 3000](http: // localhost: 3000 /).

 > On the red error screen, you should see an error statement similar to the following:
 FATAL: database "app name" does not exist
ActiveRecord::NoDatabaseError

 > The solution in this case is summarized here.
 [Resolve ActiveRecord :: NoDatabaseError on rails6](https://qiita.com/satomomo0222/items/0d7f91b9c5403e9d2b68)


Recommended Posts

I can't deploy! Resolve an error that can't be pushed to heroku (Rails Tutorial Chapter 1)
I can deploy to heroku, but I get an error and can't open it [Cause: MySQL]
Rails tutorial Resolved an error deploying to Heroku, so note the solution
I can deploy Heroku, but I get an error and can't open it
How to deploy an app that references a local jar to heroku
Rails Tutorial Extension: I tried to create an RSS feed function
Deploy Rails on Docker to heroku
Deploy to heroku with Docker (Rails 6, MySQL)
Deploy to Heroku [Ruby on Rails] Beginner
Rails Tutorial Chapter 1 From Zero to Deployment [Try]
When deploying to Heroku, OpenApp causes an error
[Rails] What to do when you want to generate an error that cannot be destory when foreign key restrictions are applied
Error deploying rails5 + Mysql to heroku with Docker-compose
Resolve LoadError (cannot load such file --bcrypt) that occurs in rails test (Rails tutorial Chapter 6)
rails tutorial Chapter 6
rails tutorial Chapter 1
rails tutorial Chapter 7
rails tutorial Chapter 10
rails tutorial Chapter 9
rails tutorial Chapter 8
Resolve Gem :: FilePermissionError when running gem install rails (Rails Tutorial Chapter 1)
[Ruby on Rails Tutorial] Error in the test in Chapter 3
How to use Maven that I can't hear anymore
Rails6 I tried to introduce Docker to an existing application
Rails Tutorial 4th Edition: Chapter 1 From Zero to Deployment
Resolve ActiveRecord :: NoDatabaseError when doing rails test (Rails tutorial Chapter 3)
After git pull, I can't git checkout. (error: you need to resolve your current index first)
[Ruby on Rails] Since I finished all Rails Tutorial, I tried to implement an additional "stock function"