Home>

In Chapter 11 of Rails Tutorial, when I tried to push the changes to heorku, a syntax error occurred. From the content of the error message, I assume that the changed part of config/environments/producion.rb is wrong, but no mistakes are made even if I look back many times.

remote: SyntaxError: /tmp/build_50d32a6a729bafe6d9fadc4d8759a19e/config/environments/production.rb:73: syntax error, unexpected tSYMBEG, expecting'}'
remote: :port =>'587'
remote: ^
remote: /tmp/build_50d32a6a729bafe6d9fadc4d8759a19e/config/environments/production.rb:74: syntax error, unexpected =>, expecting end-of-input
remote: :user_name =>ENV['SENDGRID_USERNAME'],
remote: ^~
:
:
remote: Tasks: TOP =>environment
remote: (See full trace by running task with --trace)
remote:
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 fast-depths-48015.

Error message
```

Applicable source code

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host ='fast-depths-48015.herokuapp.com'
config.action_mailer.default_url_options = {host: host}
ActionMailer::Base.smtp_settings = {
:address =>'smtp.sendgrid.net',
:port =>'587',
:authentication =>:plain,
:user_name =>ENV['SENDGRID_USERNAME'],
:password =>ENV['SENDGRID_PASSWORD'],
:domain =>'heroku.com',
:enable_starttls_auto =>true
}

What I tried

I tried copying the Rails Tutorial sample code published on GitHub (rewriting the URL with my own) and got the same error.

Supplementary information (FW/tool ​​version, etc.)

ruby 2.6.5p114
Rails 5.1.6
VSCode,WSL:Debian

  • Answer # 1

    I didn't know the cause, but I was able to deploy it.
    Thank you for all the answers.

  • Answer # 2

    Original answer

    Is the error message and code correctly copied and pasted into the question field?

    The code required here is not the code currently expanded in the working tree,
    The revision code pointed to by the branch you are pushing to Heroku

    The branch you are pushing to Heroku points toRevisionWith the code
    If the code pasted in the question field is different,
    Working treeCheck the code that is deployed to
    On Heroku side, different code may be processed, causing problems

    syntax error, unexpected tSYMBEG, expecting'}'

    A common cause of this error message is
    At the end of the previous line,Seems to have forgotten

    Ruby on Rails-I'm not sure about Rails email sending settings. |stackoverflow

    Addendum

    "The revision code pointed to by the branch you're pushing to Heroku" is
    How do you check?
    I can't find it, even if I look for it in a bad way.

    Chapter 11. Activating accounts-Rails tutorial

    $git push heroku

    If you get an error when running the above command,
    "HerokuThe revision code pointed to by the branch you pushed to
    Of the branch you were checking out when you ran the command
    Latest revision at the time the command was executed

    In the tutorial, the last stepgit checkout masterSince we are carrying out
    If you haven't made a mistakemasterThe latest revision of the branch

    How to check if there is any difference between the code you are pushing to Heroku and the code you are referencing

    1
    masterBranchcheckoutTo do:

    git checkout master

    2
    masterBranchpushTo do:

    git push heroku

    3
    Check if similar error occurs

    Four
    If you get a similar error,
    Localproduction.rbBefore you check
    Check your working tree for changes from the latest revision:

    git status

    If you see production.rb here
    HerokuTopushThere is a difference between what you are doing and what you can check locally
    To see the differences, run the following command:

    git diff path/to/production.rb

Related articles