Deploying PhantomJS 2.5 beta on Heroku. How can I see what's failing? - heroku

I'm trying to make a custom buildpack to deploy PhantomJS 2.5 beta version on Heroku. This is my buildpack based on Stomita's Phantomjs Buildpack which runs version 2.1.1 and works fine.
This is what I get in the building process:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> PhantomJS app detected
remote: -----> Fetching PhantomJS 2.5.0-beta binaries at https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.5.0-beta-linux-ubuntu-trusty-x86_64.tar.gz
remote: ! Push rejected, failed to compile PhantomJS app.
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to rp-phantom.
remote:
As you can see, not much information. The binary is downloaded fine, I checked that omitting the -s flag in the curl command, but can't figure out what's failing.
This is my compile file:
#!/bin/sh
set -e
BUILD_DIR=$1
CACHE_DIR=$2
# config
VERSION="2.5.0-beta"
# Buildpack URL
ARCHIVE_NAME=phantomjs-${VERSION}-linux-ubuntu-trusty-x86_64
FILE_NAME=${ARCHIVE_NAME}.tar.gz
BUILDPACK_PHANTOMJS_PACKAGE=https://bitbucket.org/ariya/phantomjs/downloads/${FILE_NAME}
mkdir -p $CACHE_DIR
if ! [ -e $CACHE_DIR/$FILE_NAME ]; then
echo "-----> Fetching PhantomJS ${VERSION} binaries at ${BUILDPACK_PHANTOMJS_PACKAGE}"
curl $BUILDPACK_PHANTOMJS_PACKAGE -L -s -O $CACHE_DIR/$FILE_NAME
fi
echo "-----> Extracting PhantomJS ${VERSION} binaries to ${BUILD_DIR}/vendor/phantomjs"
mkdir -p $CACHE_DIR/$ARCHIVE_NAME
mkdir -p $BUILD_DIR/vendor
tar -xvf $CACHE_DIR/$FILE_NAME -C $CACHE_DIR
mv $CACHE_DIR/$ARCHIVE_NAME $BUILD_DIR/vendor/phantomjs
echo "-----> exporting PATH and LIBRARY_PATH"
PROFILE_PATH="$BUILD_DIR/.profile.d/phantomjs.sh"
mkdir -p $(dirname $PROFILE_PATH)
echo 'export PATH="$PATH:$HOME/vendor/phantomjs/bin"' >> $PROFILE_PATH
echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:vendor/phantomjs/lib"' >> $PROFILE_PATH
Thanks in advance!

I was able to get 2.5.0 beta working on Heroku. Here is my answer from my own post:
Ultimately, I was able to figure it out! There are a few things that you have to do...
Dependencies: You have to use the Heroku Apt buildpack to install the missing dependencies. First, you need to add the buildpack to your app:
heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
Next, you'll create a file in your project root called Aptfile. Here's where we add the missing dependencies for PhantomJS 2.5.0 Beta. 2.5.0 introduces webp support, so we need that. libhyphen0 is required as well, though I'm not sure how it us used. Finally, we use gcc-5 and the latest libstdc++6. Contents should look like this:
webp
libhyphen0
https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/gcc-5_5.4.1-8ubuntu1_amd64.deb
https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.4_amd64.deb
PhantomJS: Next we grab the latest version of PhantomJS. I've created a fork of the most popular PhantomJS buildpack and updated it for use with 2.5.0 beta. 2.5.0 beta has builds for trusty as well as xenial, so the build pack will detect the Heroku stack and use the appropriate one (though the cedar-16 stack is still in beta at the time of this post). So, add it to your app:
heroku buildpacks:add https://github.com/lookitsatravis/heroku-buildpack-phantomjs.git
Deploy: All that's left is deployment! Commit the Aptfile to your repo, make sure the build packs are setup, and then push to Heroku.
Took a bit of trial and error, but ultimately I was able to get it up and running. Hope this helps others until the final candidate is released.

Related

Failed build in Heroku master push

I'm trying to deploy my project to Heroku, and my build failed. When it is deployed locally, I have no problem. When I apply git push heroku master and look at the build log on Heroku, this is what I get.
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> PHP app detected
! ERROR: Basic validation for 'composer.json' failed!
!
! It must be a valid JSON document compatible with Composer.
!
! You most likely created or edited the file by hand, and it now
! contains a syntax error. Please refer to the documentation at
! https://getcomposer.org/doc/ for information on the format.
!
! You can run 'composer validate' locally on your computer for
! further diagnosis. Remember to also always keep your lock file
! up to date with any changes according to the instructions at
! https://getcomposer.org/doc/01-basic-usage.md
! Push rejected, failed to compile PHP app.
! Push failed

How to fix YouTube-dl Invalid parameters. on Heroku

When I try to download a song with youtube-dl.rb gem it works locally, but when I do it on Heroku it says this:
Terrapin::ExitStatusError - Command '/app/vendor/bundle/ruby/2.6.0/gems/youtube-dl.rb-0.3.1.2016.09.11.1/vendor/bin/youtube-dl --no-color --no-progress --print-json "ytsearch:notion hooked"' returned 1. Expected 0
It also says something about cocaine being deprecated like this:
DEPRECATION: The cocaine gem is deprecated. Please upgrade to terrapin. See https://github.com/thoughtbot/terrapin/ for further instructions.
This is my code that is running this gem:
song_list.each { |song|
# formatted_command = 'youtube-dl -o "' + __dir__.to_s + '/' + temp_dir_name + '/%(title)s.%(ext)s" -x --audio-format mp3 "ytsearch:' + song + '"'
# system formatted_command
options = {
audio_format: :mp3,
extract_audio: true,
output: "#{__dir__.to_s}/#{temp_dir_name}/%(title)s.%(ext)s",
}
YoutubeDL.download "ytsearch:#{song}", options
}
I commented two lines above that were downloading songs with the CLI tool, that worked as well, but I can't download that tool on a Heroku machine, so I have to use this Ruby wrapper.
Here are some instructions to running youtube-dl on your Heroku server:
create a requirements.txt file in the root of your repo, with content:
youtube-dl
Run the following three commands to set up Python buildpack as well as Ruby buildpack, making sure Ruby is the primary buildpack:
heroku buildpacks:add heroku/ruby
heroku buildpacks:add --index 1 heroku/python
heroku buildpacks:set heroku/ruby
Commit and deploy, test by opening heroku run bash and running youtube-dl. If it works here, you can also call it from Ruby.

Create-react-app build failing on heroku when using absolute paths

When using absolute paths in my CRA, the build step fails on heroku.
NODE_PATH=src/
Is in my .env.local file and also use this env var in my heroku settings.
I try to build my app on heroku using the "heroku-postbuild" script (which just runs "react-scripts build". I am using an express server to serve this build folder and to proxy requests to various API's.
this is the error I get:
remote: Running heroku-postbuild (yarn) remote: yarn run
v1.14.0 remote: $ react-scripts build remote: Creating
an optimized production build... remote: Failed to compile.
remote: remote: ./src/app/App.js remote: Cannot find
module: 'checklist/Checklist'. Make sure this package is installed.
remote: remote: You can install this package by running: yarn
add checklist/Checklist. remote: remote: remote: error Command failed
with exit code 1.
the Checklist.js file is located under: "src/checklist/Checklist.js"
Any idea what I need to do to make this work?
I had this issue and it seemed to be a result of my local file having a different casing than the one committed to git. i.e. if you have a file Checklist.js committed to git and are trying to import checklist from 'checlist/checklist.js', run git mv [...]/checklist.js [...]/Checklist.js.
See this issue comment for the original answer that got me here.
Just create a jsconfig.json file on the root of your project and paste this(if you use src as the starting point for your absolute imports
{
"compilerOptions": {
"baseUrl": "./src"
}
}

heroku push rejected, failed to compile Python app

I have created a python application using "Flask" a python framework. I used the following documentation https://devcenter.heroku.com/articles/python
When I run this:
git push heroku master
I'm getting the following error after pushing to heroku.
Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (8/8), 1.62 KiB, done.
Total 8 (delta 0), reused 0 (delta 0)
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.4.
-----> Preparing Python runtime (python-2.7.4)
-----> Installing Distribute (0.6.36)
-----> Installing Pip (1.3.1)
-----> Installing dependencies using Pip (1.3.1)
Downloading/unpacking BeautifulSoup==3.2.1 (from -r requirements.txt (line 1))
Downloading BeautifulSoup-3.2.1.tar.gz
Running setup.py egg_info for package BeautifulSoup
Downloading/unpacking CDApplet==1.0 (from -r requirements.txt (line 2))
Could not find any downloads that satisfy the requirement CDApplet==1.0 (from -r requirements.txt (line 2))
No distributions at all found for CDApplet==1.0 (from -r requirements.txt (line 2))
Storing complete log in /app/.pip/pip.log
! Push rejected, failed to compile Python app
To git#heroku.com:frozen-brushlands-5131.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:frozen-brushlands-5131.git'
Any help is appreciated.
Looks like there is not a Python package called CDApplet. When your Heroku app tries to install CDApplet it fails and gives you this error.
I tried it locally and could not find a Python package called CDApplet either.
I encountered the same error, try removing the concerned dependency (or add a correct name).
After that, do:
git add .
git commit -m "commit-message"
git push heroku master
You should be ready to go now.
i have same problem and fixed with
git add *
git commit -m "initial commit"
git push heroku master
i hope this'll help you.
I also ran into this problem, luckily, I found a fix. This are the steps I took.
Step 1
You need to upgrade the heroku app via command line interface
`$` heroku stack:set heroku-18 -a <app name>
Note that this will not affect previous apps that was built so you may need to rebuild the app. Remember to substitute "app name" with the name of the app
`$` git commit --allow-empty -m "Upgrading to heroku-18"
After the previous line, try pushing it again with:
`$` git push heroku master
Step 2
If this doesn't work remove the runtime.txt file containing the python version and remember to add and commit changes to git. Push once again and it should work, It worked for me!

git, Heroku: pre-receive hook declined

I am in the process of setting up a git repository and attempting to link it to Heroku. When I run the command
git push heroku master
I receive
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 714 bytes, done.
Total 7 (delta 1), reused 0 (delta 0)
-----> Heroku receiving push
! Heroku push rejected due to an unrecognized error.
! We've been notified, see http://support.heroku.com if the problem persists.
To git#heroku.com:morning-stream-3712.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:morning-stream-3712.git'
How can I get my application pushed to Heroku?
Make sure you are pushing a repo that contains a proper supported app ( Rails, Django etc.) and you are not just pushing some random repo to test it out.
Newbie in Heroku: Error when push my app to Heroku
If that is not the case and you are pushing what you think is a valid app, contact Heroku support and they will fix it for you.
Make sure that you are using either npm or yarn.lock file-
Two different lockfiles found: package-lock.json and yarn.lock
Both npm and yarn have created lockfiles for this application,
but only one can be used to install dependencies.
After deleting yarn.lock and pushing the code again to git, my issue resolved.
Deleting package-lock.json solved it for me
First, disable collectstatic:
heroku config:set DISABLE_COLLECTSTATIC=1
Then run:
git push heroku master
For more details and full steps, check here.
I faced the same problem:
! [remote rejected] vX.X.XX -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:[application-name]'
I realized that my heroku application Stack is 'cedar-10' and was deprecated from 04/11/2014 and disabled from 04/11/2015 (Cedar-14 is now Generally Available).
The solution was to upgrade the heroku application Stack following the guide:
Upgrading the production app to Cedar-14
Another issue could be that in a production environment, you can't use sqlite3, the default database when you make a rails app.
In order to fix this, just change the database your rails app uses to Postgres. This can easily be accomplished by editing your Gemfile
From your Gemfile, remove:
gem sqlite3;
and add the following:
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
I had the same problem but with a Django app, it turned out that pip wasn't able to download/install one of the dependencies of the requirements.txt file (it was eyeD3)
A little late to the game, one of my issues was I had an outdated sshkey. Just need to update that in the settings.
Another thing was I was pushing Python Django CMS, and it was running python manage.py collectstatic during deploy and it was failing. So make sure you check the log heroku logs --tail. That gave me another hint to turn off collectstatic, it event tells you what to type to turn it off.
Came across this same error when deploying a node app, but resolved with these two steps and thought I'd share in case anyone else runs into the same issues.
Make sure you aren't committing node_modules since heroku installs dependencies from package.json on push. Try adding node_modules/ to your .gitignore to ensure you don't accidentally commit it
Heroku uses Node v12 which node-sass 4.10.0 will fail to build with. Try increasing node-sass version by adding the following. This allowed it to build successfully for me:
"devDependencies": {
"node-sass": "^4.12.0"
}
In case if this needs anyone in future even though I am a beginner and doesn't know much about Heroku, you may have requested a version in runtime.txt file which the stack doesn't support.
python-3.8.2 to python-3.8.10
Changing from python-3.8.2 to python-3.8.10 helped me solved it. You may see the supported stacks here: https://devcenter.heroku.com/articles/python-support
I had this problem (same error with Heroku):
To https://git.heroku.com/myapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myapp.git'
The mistake
I made some changes to my code and removed some parameters, apparently I missed a simple comma (,) on a line. This caused a build error. Which was not visible in the console upon pushing, only the "pre-receive hook declined" error.
SOLUTION
I fixed the comma issue, rebuild and pushed to Heroku and now it works.
If you have an error in your css this error can also show up.
In one of my media queries I put
#media screen adn (min-width: 1000px) {
Instead of the "and" which gave me this error.
A good indicator that this may be the case is if you get an error that contains the message
"Tasks: TOP => assets:precompile ... Precompiling assets failed"
That was my first clue to look in my css.
I decided to read the logs line by line.
Below is part of the error logs:
remote: > gbt-ltd-website-frontend#0.1.0 build /tmp/build_c37edf59
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Failed to compile.
remote:
remote: Cannot read property 'toLowerCase' of undefined
remote: CompileError: Begins at CSS selector .Styles_hone__1Uuf2
remote:
remote:
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! gbt-ltd-website-frontend#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
...
remote: ! Push rejected to gbtstructurals.
remote:
To https://git.heroku.com/gbtstructurals.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/gbtstructurals.git'
From where the error started, "npm ERR! code ELIFECYCLE" I read up and I found the actual cause of the error. It was a CSS rule. I first removed the rule and it built. Then I checked my declarations and found out I was contradicting myself.
i thought , this will not be the error occured due to any app , or code changes.
i have same problem now this happen due to the following reason:
1) i have code on bitbucket/git i push the code to repository (this
repo is linked with the heroku app,meanse changes to this will
reflects on heroku)
2)after pushing code to repo , i am trying to push code on heroku
with "git push heroku master" but due to some reason i abort this
command, thats why code is not pushed to heroku
3)then i am agian triyng to push code to heroku it says same error
as above
4) the solution for this is "just pull yours last commited code"
and push the changes to heroku ..thats it thanks
I had this with a sinatra application. (Heroku does support Sinatra).
The instructions on the heroku blog post were incomplete
https://blog.heroku.com/32_deploy_merb_sinatra_or_any_rack_app_to_heroku
My program ran fine locally but I got that error when trying to push to heroku.
The heroku blogpost didn't include the need to make a gemfile and do bundle install. The program was running locally fine, but to make it work on heroku it needed a Gemfile and bundle install on it.
this link here https://teamtreehouse.com/community/how-can-i-make-my-sinatra-app-public mentioned that I needed a Gemfile, and mentioned the contents of the Gemfile. And then to do bundle install. Then once that is done, then follow the instructions on that heroku blog post, of making the program file, and the config.ru and the git repo and doing heroku create (which also creates the remote), then git push heroku master.
i.e.
Gemfile as mentioned at treehouse link
# define our source to look for gems
source "http://rubygems.org/"
# declare the sinatra dependency
gem "sinatra"
And bundle install to install that Gemfile.
bundle install
hello.rb (as mentioned on heroku blogpost)
require 'rubygems'
require 'sinatra'
get '/' do
"Hello from Sinatra on Heroku!"
end
config.ru
require './hello'
run Sinatra::Application
git
$ git init
Initialized empty Git repository in /Users/adam/hello/.git/
$ git add .
$ git commit -m "sinatra and heroku, two great tastes"
[master (root-commit)]: created 93a9e6d: "sinatra and heroku, two great tastes"
2 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 config.ru
create mode 100644 hello.rb
heroku create
$ heroku create
Created http://severe-spring-77.heroku.com/ | git#heroku.com:severe-spring-77.git
Git remote heroku added
the push to heroku
$ git push heroku master
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 385 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
-----> Heroku receiving push
-----> Verifying repository integrity... done, looks like a Rack app.
Compiled slug size is 0.1MB
-----> Launching....... done
App deployed to Heroku
To git#heroku.com:severe-spring-77.git
* [new branch] master -> master
For me it was an unused import in java app , removed the unused import and everything built fine.
In my case I had an npm script called "build" that had the as value npm run build --prefix client.
Heroku automatically executes the npm run build command and it couldn't build my React app. Probably because Heroku didn't install react-scripts module.
So I renamed the command to build-client and now I can push the changes to Heroku.
Checking you config vars (in heroku) may be a good idea.
I had the same error message, when I created a pipeline for my app and wanted to push to the newly created staging app. It didn't work because the config vars I had previously set were not transferred to the new staging app (obviously). After I added the variables once more, pushing to heroku git worked flawlessly again.
I had a similar issue with a recent application after running:
git push heroku master
The error:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to stormy-escarpment-13653.
remote:
To https://git.heroku.com/stormy-escarpment-13653.git
! [remote rejected] master -> master (pre-receive hook declined)
The problem was that I was in the wrong directory when I ran the command. I needed to be in the root of the application.
So I ran a git rm --cached <app_name>, to clean up and the ran again and it worked as expected.
My issue was I forgot to bundle install before pushing.
The steps which work for me
1: I just remove package-lock.json and yarn.lock
2: user npm install command
3: then push the changes to the github
4: use "git push heroku main" command.
to know more you can visit the below links enter link description here
My issue is that there was one file which I did not add in my previous git commit. The problem was fixed after I added that last file, and pushed another commit.
When I checked the logs, it showed this error:
remote: -----> Build
remote: Running build
remote:
remote: > student-app-frontend#0.1.0 build
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Failed to compile.
remote:
remote: SassError: File to import not found or unreadable: ../../designUtils/fontDesign.
remote: on line 2 of src/components/studentCard/StudentCard.scss
remote: >> #import '../../designUtils/fontDesign.js';
remote:
remote: ^
remote:
remote:
remote:
remote: -----> Build failed
This shows that Heroku was not able to find the imported file 'designUtils/fontDesign.js'
This is because I used the command git commit -am 'latest changes' instead of using the commands git add., then git status to check if everything was added properly, and then git commit -m 'latest changes'
For me it solved by this command:
git push heroku master --force
or
git push heroku your_branch_name:master --force
Try Updating Node/php or any engines to latest version and then deploy again it will work for sure.
you need to mention the language in the root directory
how I fixed with
my python flask does not mention the requirments.text
Heroku detect the
Using buildpack: heroku/python
remote: -----> Python app detected
enter image description here

Resources