duanpasi6287 2017-09-28 06:03 采纳率: 100%
浏览 578

Heroku部署错误:无法检测到buildpack

I'm trying to deploy my Discord Bot to Heroku and I've successfully linked my Github account to Heroku. It can successfully find the repository I'm trying to deploy, but when I try a manual deployment it gives me the error:

 !     No default language could be detected for this app.

        HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.

        See https://devcenter.heroku.com/articles/buildpacks

 !     Push failed

My bot is coded in Go, which is supported by Heroku. Could it be that my code has external libraries? If so, how can I add support for those libraries in Heroku? Thank you in advance.

  • 写回答

1条回答 默认 最新

  • dongxi3911 2017-09-28 07:26
    关注

    On Heroku projects are compiled / built using so called buildpacks. Specific buildpacks are created for projects using different languages. For Go projects there exists the heroku/go which knows how to get, compile and build Go projects, including getting their dependencies automatically as part of the build process.

    The buildpack selection can happen either manually or automatically. You see the error you posted because you have not set any buildpacks manually, and automatic detection failed for you. See reasons below.

    Manual buildpack selection

    For manual selection, download the Heroku CLI, and execute the following command:

    heroku buildpacks:set heroku/go
    

    Note: if you're using heroku cli for the first time, you may need to login using heroku login. Also if your app is not selected by default, you may specify it using the -a or --app argument, e.g.:

    heroku buildpacks:set heroku.go -a yourappname
    

    To see selected buildpacks, execute the heroku buildpacks command.

    Automatic buildpack detection

    Just because a project is using the Go language, the heroku/go buildpack does not get selected automatically.

    The actual detection whether heroku/go should be used is done by the script heroku-buildpack-go/bin/detect, the detection logic is:

    if test -f "${build}/Godeps/Godeps.json" || # godeps
       test -f "${build}/vendor/vendor.json" || # govendor
       test -f "${build}/glide.yaml" || # glide
       (test -d "${build}/src" && test -n "$(find "${build}/src" -mindepth 2 -type f -name '*.go' | sed 1q)") # gb
    then
      echo Go
    else
      exit 1
    fi
    

    So basically the Go language is detected and heroku/go buildpack is selected automatically if one of the following file is present in your project:

    • Godeps/Godps.json; used by godep
    • vendor/vendor.json; used by govendor
    • glide.yaml; used by glide
    • src/*/*/**/*.go; used by GB

    Further reading

    Official articles about working with Go and Heroku:

    Getting Started on Heroku with Go

    Heroku Go Support

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法