Pushing my Python Discord Bot onto Heroku - heroku

I wrote a program in VS Code for a Discord bot, and I am trying to run it in Heroku. I was using the Heroku CLI and navigated to the folder with the code in my Command Prompt (I'm on Windows). I tried to add and push my main code, but I got the error in the picture below.
How can I resolve this issue? I am using Windows and my code is in VS Code.

The error states that heroku is unable to determine the language of your project.
You should add a requirements.txt file with the python package names used in your project to allow heroku to detect it as a python project.
Other options include using a setup.py file or Pipfile.
You can also manually set the buildpack using
heroku buildpacks:set heroku/python
in the heroku CLI
For more information check the documentation

Related

Heroku Deployment Error *heroku open* command Clojure app

Hi i am trying to deploy my project i develop in Clojure to heroku. it created and build too but
when i write heroku open it gives error and logs saying missing build
You are using heroky "autodetect" and it's detecting your npm file and trying to start it as a npm project.
You need to specify to use clojure buildpack in somewhere inside heroku settings.
I recommend you to move into "docker mode" in heroku, that will give you more control about how to build/run your project.

Drush and Drupal commands on Heroku instances

I'm working on a Drupal 8 site which is deployed on Heroku, how would I run Drush or Drupal commands on here? When I try it with the built in command line on the Heroku site it complains about MySQL not being present. Is it possible to run Drush or Drupal commands on Heroku? Could I run the commands locally but somehow connect to the Heroku boxes?
I got in touch with Heroku support and managed to resolve the problem, in order to install MySQL you have to use their buildpacks.
If you go to your App > Settings > Buildpacks section you can add https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku-community/apt.tgz which from what I understand allows you to install packages using an Aptfile in your repository.
Once that Buildpack has been added in the root of your code that's deployed to Heroku add a file named "Aptfile", no extension and add the following two lines to it:
mysql-common
mysql-client
I'm not sure if mysql-common is needed but mysql-client certainly is. Deploy this to your Heroku environment and you should be able to run Drush commands now, be sure to add that Buildpack before adding the Aptfile as adding the Buildpack only adds it on the next environment build which happens with a new commit.
Running Drush is pretty easy ones you've done this. To do it via the web interface click the "More" button near the top right of the screen when you're looking at your app in Heroku and select "Open Console" then enter bash in the new panel and click "Run". Now you should be able to run Drush commands from here.
If you want to run the from your local terminal use https://devcenter.heroku.com/articles/one-off-dynos#an-example-one-off-dyno in the Heroku CLI (which you'll have to install). You may have to use the --dyno or --app flags to run Drush in the correct place.

Heroku fails to detect Hugo app matching buildpack

I created a Hugo application which I wanted to deploy through Heroku.
Following Hugo's instructions on their github readme, it says to create a Heroku app with the command:
$ heroku create --buildpack https://github.com/roperzh/heroku-buildpack-hugo.git
followed by:
$ git push heroku master
$ heroku open
Upon doing so, however, I keep getting an error:
remote: -----> Failed to detect app matching https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/go.tgz buildpack
and the push ultimately fails.
Most of what I've looked up tells me that it needs a specification of what language is being used, which in this case is Go.
But even when doing:
heroku buildpacks:set -a myproject heroku/go
It tells me:
! The buildpack heroku/go is already set on your app.
So, if it's already set on my app, then why can't it detect an app matching the buildpack?
Check your hugo version using
hugo version
and then set your hugo version on heroku
for example 0.40
heroku config:set HUGO_VERSION=0.40 -a <your app name>

Heroku CLI error

Unable to use Heroku CLI anymore:
Error
Installing Heroku Toolbelt v4... done.
For more information on Toolbelt v4: https://github.com/heroku/heroku-cli
Setting up node-v4.1.1... ! rename C:\Users\Me\AppData\Local\heroku\tmp\download200968087\file C:\Users\Me\AppData\Local\heroku\node-v4.1.1-windows-x86\bin\node.exe: Access is denied.
error loading plugin commands
error loading plugin topics
error loading plugin commands
I reinstalled git then heroku toolbelt.
Ran git bash as admin.
Im on windows 8.1
Delete the executable under C:\Users\Me\AppData\Local\heroku\node-v4.1.1-windows-x86\bin\node.exe and you should be able to proceed.
This is a permission error. The environment under which the script runs doesn't have permission to delete that file. You, however, likely do.

Getting PDFTK installed on heroku Cedar Stack for use in my app

so I have building management app, which locally uses the pdftk to generate pdf forms (prefilled with tenant/expense data). Works like magic on my local machine.
However, on Heroku I get the error:
pdftk executable /usr/local/bin/pdftk not found
in the logs when I try to generate the pdf file. I realize that I need to install pdftk on my heroku app using a buildpack. I've tried following some tutorials with Vulcan, but vulcan is deprecated and they say use heroku run, however I can't find much documentation of how to install the pdftk-source: https://github.com/millie/pdftk-source using heroku run.
I'm going to try https://github.com/millie/heroku-buildpack-ruby-pdftk, but if there is an easier/less messy way let me know, thanks!
EDIT:
Tried the above method, and now my heroku logs say:
RuntimeError (pdftk executable /app/vendor/pdftk/bin not found)
So I'm thinking the buildpack didn't include pdftk to begin with, which doesn't make sense.
I must be doing something wrong, but I followed the instructions exactly, only difference is I used dropbox instead of S3 to store the tar.gz file (the pdftk source)
EDIT:
OK, I figured out how to include pdftk executable in the heroku buildpack and upload it successfully as part of the app environment. HOWEVER, for some very strange reason, in the heroku bash console, when I cd into pdftk directory and try to run the executable, heroku bash says pdftk executable not found.
It works on my local machine, when cd into the pdftk directory and run pdftk, it runs the executable, so its not the executable..so why isn't it working inside the heroku bash directory?
SOLUTION:
Was missing setting LD_LIBRARY_PATH in my config vars on heroku, because pdftk relies on a library file. Also, remember to tar the tar.gz to the root directory and set a PATH to /bin/pdftk. Just check out #heroku on IRC, that's where I got my answer.
Was missing setting LD_LIBRARY_PATH in my config vars on heroku, because pdftk relies on a library file. Also, remember to tar the tar.gz to the root directory and set a PATH to /bin/pdftk. Just check out #heroku on IRC, that's where I got my answer.
This is how i setup pdftk in nodejs app in heroku
Create heroku app
heroku create
Set buildpack for pdftk
BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-apt
Set buildpack for nodejs
heroku buildpacks:add --index 1 heroku/nodejs
Add the libgcj.so.* to your search path:
heroku config:set LD_LIBRARY_PATH=/app/bin
Turn on at least one dyno
heroku ps:scale web=1
Create a Procfile in the root of your project and define the following:
web: node server.js
Push changes in heroku
git push heroku master
Adding answer that worked as of July 2019
Note: Thanks to shake-apps for creating the Buildpack https://elements.heroku.com/buildpacks/shake-apps/heroku-buildpack-pdftk
If you need to have PDFtk installed on Heroku for a Node JS Application, follow these instructions:
Heroku Installation
You'll need to set the base nodejs buildpack, and the pdftk buildpack by shake-apps.
Set them by running the following:
heroku buildpacks:set heroku/nodejs;
heroku buildpacks:add --index 1 https://github.com/shake-apps/heroku-buildpack-pdftk.git;
After build packs are set, the server can be deployed normally with
git push heroku master
If you have any issues with the deploy it could be your previous buildpack. You can clear it to start fresh with:
heroku buildpacks:clear

Resources