How to debug custom Heroku buildpack: release script not being driven - heroku

I am developing an Eclipse Virgo buildpack but when I try it with Heroku and push a trivial app, detection fails:
-----> Fetching custom git buildpack... done
! Heroku push rejected, no Cedar-supported app detected
The buildpack's detect script works fine locally in the root directory of the app:
$[...]virgo-buildpack/bin/detect .
Virgo Web
Any tips on how to debug this? I tried having the detect script write to stdout and stderr, but the output doesn't appear under "heroku logs".
I am running Mac OS X 10.8.2, Ruby 1.9.3p374, and gems 1.8.23.
Update: following the first two answers, I used a bash detect script to install the missing gem before driving a detect.rb script. I also changed the buildpack scripts to write to standard output.
The heroku push gets a lot further, but still fails. I can see the compile script exiting, but the release bash script has an echo command right at the start and this does not appear in the output.
So it seems that the release script is not being called.
The output is as follows (# indicates comments to avoid clutter):
-----> Fetching custom git buildpack... done
# detect script enter and exit
Virgo Web app detected
# compile script enter and exit
-----> Discovering process types
Procfile declares types
-> (none)
# detect script enter and exit (again)
Virgo Web -> web
-----> Compiled slug size: 60.4MB
-----> Launching... ! Heroku push rejected, failure releasing code
heroku logs --tail simply shows:
2013-03-06T10:53:48+00:00 heroku[slugc]: Slug compilation started
2013-03-06T10:54:27+00:00 heroku[slugc]: Slug compilation failed: failure releasing code

For a custom buildpack, the detect script doesn't really need to be that complicated because users will be specifying it manually with BUILDPACK_URL anyway. A sophisticated detect script really only makes sense for the default Heroku buildpacks because they need to detect if the buildpack applies for any given app.
If you want to completely punt on detection, you can get away with something like this:
#!/usr/bin/env bash
# bin/detect <build-dir>
echo "Vergo"
exit 0
Once you get that working (and work out any issues with compile and release), you can make it a little more intelligent. For example, you could detect if a certain file pattern exists:
#!/usr/bin/env bash
# bin/detect <build-dir>
if [ -f $1/index.jsp ]; then
echo "Vergo" && exit 0
else
echo "no" && exit 1
fi
Also, speaking of simplicity, it looks like you are basing your buildpack on the Ruby buildpack, which is one of the most complicated ones out there. You may want to take a look at the list of third-party buildpacks to see how most are done in simple bash.

Currnetly there are a few tools to make this much easier.
This build pack https://github.com/kr/heroku-buildpack-inline (A build pack to help construct buildpack)
heroku run bash Is your best friend.
Push your build pack on to the platform using the inline buildpack so that you can get good logging, and use heroku run bash so that you can actaully tinker with your buildpack in the environment that you will be using it in.

Related

Getting PDFTK installed on Heroku 18 for use in my Laravel app

I have added this pdftk buildpack to my free app on Heroku: https://github.com/fxtentacle/heroku-pdftk-buildpack.git.
I am unable to deploy my application to Heroku:
Preparing runtime environment...
-----> Checking for additional extensions to install...
-----> heroku-pdftk-buildpack app detected
cp: cannot stat 'binaries-heroku-18/*': No such file or directory
! Push rejected, failed to compile heroku-pdftk-buildpack app.
! Push failed
Also, I have added heroku/php and set the index of this buildpack to 1. When I go to my app's temporary URL, Laravel runs, but for some reasons, pdftk doesn't seem to run. Has anybody faced the same issue?
That buildpack hasn't been updated for the heroku-18 stack. Its compile script tries to copy precompiled binaries from binaries-$STACK/ into /app/bin/, but only contains binary directories for cedar-14 and heroku-16.
You could roll your app back to heroku-16, which will be supported until April, 2021, but of course this will also change other package versions:
heroku apps:stacks:set heroku-16 --app myapp
This would be very similar to going from Ubuntu 18.04 to Ubuntu 16.04, but it's likely to be your simplest solution.
Alternatively, you could fork the pdftk buildpack you found and update it for Ubuntu 18.04, but that isn't likely to be straightforward.
pdftk was removed from Ubuntu's official repositories because it depends on a deprecated library called gcj. The buildpack you're trying to use includes libgcj for cedar-14 and heroku-16 in their respective binary directories. You'll have to include that as well if you want to update the buildpack.
Also, I have added heroku/php and set the index of this buildpack to 1. When I go to my app's temporary URL, Laravel runs, but for some reasons, pdftk doesn't seem to run. Has anybody faced the same issue?
The error you're seeing is preventing your application from being deployed. You're not seeing a new version of the application with pdftk, but whatever was last deployed successfully. You'll have to resolve the build issue before you can use pdftk.
I followed this article (http://derekbarber.ca/blog/2014/11/20/using-pdftk-with-rails-on-heroku/) and got PDFTK working on Heroku-18, though on a Rails app.
Code excerpted below, HT #derek-barber.
mkdir -p [my_project]/vendor/pdftk/lib [my_project]vendor/pdftk/bin
cd /tmp
git clone https://github.com/millie/pdftk-source.git
cd pdftk-source
tar xzvf pdftk.tar.gz
mv bin/pdftk [my_project]/vendor/pdftk/bin/
mv lib/libgcj.so.12 [my_project]/vendor/pdftk/lib/
cd [my_project]
git add -f vendor/pdftk/
git commit -m "Add pdftk dependencies"
git push heroku master
heroku config:set LD_LIBRARY_PATH=/app/.heroku/vendor/lib:/app/vendor/pdftk/lib
heroku config:set PATH=/app/.heroku/python/bin:/usr/local/bin:/usr/bin:/bin:/app/vendor/p
Once this PR is merged: https://github.com/fxtentacle/heroku-pdftk-buildpack/pull/9 then the buildpack should work with heroku-18 stack.
Maybe leave a comment to the repo owner asking them to merge?
For now, you could use the forked & updated version: https://github.com/Aesthetikx/heroku-pdftk-buildpack which works with heroku-18 stack.
If you are using an app.json file, then point the pdftk buildpack to the forked version:
"buildpacks": [
...,
{
"url": "https://github.com/fxtentacle/heroku-pdftk-buildpack.git"
}
]

Xcode server bot error "Trigger exited with non zero status 2"

Hey I wanna set up a Xcode server, in order to work properly I need to get the extension "Siren" to get installed before the bot runs and tests the Xcode project.
The problems here is that every time I integrate the bot to test my app it resets my installed Carthage extensions...
I think I need a pre integration script who installs the missing extensions into the bot when it starts.
At the moment I wrote as pre integration script (called "Install dependencies"):
#!/bin/sh
cd /Users/catrobat/Library/Caches/XCSBuilder/Bots/9194b282ad9904370a8be66eb400f02d/Source/Catty
make init
The folder dictionary is where my bot gets created and make init is the command in order to get home-brew to install "Siren" and more in the make file.
But it doesn't work and I get the error "Trigger exited with non-zero status 2"
Does anyone know how to fix this?
Xcode Server exposes XCS_PRIMARY_REPO_DIR which is just what you need:
#!/usr/bin/env bash
set -e
pushd "${XCS_PRIMARY_REPO_DIR}"
make init

Heroku Deployment Error: Cannot detect 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.
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

Install wkhtmltopdf on heroku using a java application

I manged to get my spring boot website online on Heroku. But I also use wkhtmltopdf to create a pdf. This works locally but now I have some problems.
Offline it works as follow :
ProcessBuilder pb = new ProcessBuilder
("cmd.exe",
"/c",
" cd C:\\Program Files\\wkhtmltopdf\\bin && wkhtmltopdf.exe "
+ "http://google.com C:\\MainWebApps\\TestApp\\src\\main\\resources\\userstorage\\Google2.pdf");
But how do I install this on Heroku?
Where do I store the temporarily html page so I can create a pdf from it ?
And where is wkhtmltopdf installed on Heroku ?
Can I call the wkhtmltopdf with a processbuilder on heroku?
EDIT
So after the comment of ceejayoz I googled a bit more and did find some interesting stuff.
So for Compile the binaries on Heroku I used this:
heroku run /bin/bash
Then I did a curl of wkhtmltopdf like this:
curl -O http://download.gna.org/wkhtmltopdf/0.12/0.12.0/wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
Then I tried to extract it on the server but without success:
$ tar -xjvf wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
tar (child): wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
EDIT2
I also found this https://github.com/dscout/wkhtmltopdf-buildpack on github.
So I did following :
heroku buildpacks:set 'https://github.com/heroku/heroku-buildpack-multi.git'
echo 'https://github.com/dscout/wkhtmltopdf-buildpack.git' >> .buildpacks
This created a file named .buildpacks but how do I proceed from there on ?
I also found this post but vulcan is deprecated and uses ruby
Using Wkhtmltopdf with Nodejs on Heroku
Can somebody provide me with good information because I am completely stuck with this?
You actually have two problems that you need to solve -
How to install/invoke the executable
How to handle the generated .pdf
Assuming you have the basics of Heroku deployment (push to the Heroku git remote), for #1, #ceejayoz is right - check the binary into your git repository. For example, under a ./bin directory. The root of your project (where the Procfile is) will be your working directory, and you should be able to invoke the program with ProcessBuilder using relative paths.
Caveat - since it looks like you are developing on Windows, you will need to pay attention to ensuring both platform-specific binaries are available, and add some logic to know which one to invoke (for example, by setting/checking a specific environment variable).
I recommend against trying to build with a custom build pack - you will spend a lot of energy for little to no benefit. Aside from the platform issue, you don't need to rebuild a third party tool when your code changes...
The second problem is that you can't leave the generated PDF in place. It will go away when the dyno is restarted (see https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem). Thus, the first thing you should do when the process completes is move the generated file to an external storage service (Amazon S3 is a good starting point).
Hope this helps.
You might want to use wkhtmltopdf-binary. With that solution, you do not need to put wkhtmltopdf executable into your VCS. You can use it for example with Maven or Gradle.

Heroku - Binary only buildack?

I'm attempting to upload a Play! 2.1 Project to Heroku, however the build keeps timing out after 15 minutes. (During the javascript minification/uglification stage).
Plan B is to simply compile it ourselves locally (play dist) and upload the resulting compiled package with a Procfile to launch it.
This fails, however, as Heroku seems intent on detecting source code and compiling it, and doesn't seem to be happy with executing a simple shell script.
Heroku push rejected, no Cedar-supported app detected
Is it possible to have heroku ignore the build process and simply execute my Procfile?
You'll have to push your zip file into a git repo, and then you'll have to use a special buildpack, and a special Procfile.
Maybe it can help : https://stackoverflow.com/a/16580332/320180

Resources