I'm using the meteor buildpack to deploy my meteor app.
I would like to be able to run a migration with knex at the end of the buildpack installation.
I forked the buildpack to add a shell script in the extra directory (as mentioned in the README) that contains: cd .knex && knex migrate:latest --env staging
Unfortunately, there isn't any .knex directory in the buildpack current directory.
I run ls -a during the heroku buildpack to display the content of the current directory and there isn't a .knex directory:
remote: .
remote: ..
remote: app
remote: assets
remote: boot.js
remote: boot-utils.js
remote: config.json
remote: mini-files.js
remote: node_modules
remote: npm
remote: npm-shrinkwrap.json
remote: package.json
remote: packages
remote: program.json
remote: shell-server.js
Any suggestions?
If you have a migrations folder, created initially at the CLI with: knex migrate:make migration_name then you can trigger a migration to the latest within the app itself using: knex.migrate.latest([config]) as per the documentation: http://knexjs.org/#Migrations-latest
The config should be as per a knexfile.js, I followed an example here for reference: http://www.dancorman.com/knex-your-sql-best-friend/
Related
I'm trying to deploy a React Web app on Heroku using the Heroku CLI. However when I run,
git push heroku master
from my project folder it throws an error as:
Counting objects: 213, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (212/212), done.
Writing objects: 100% (213/213), 515.89 KiB | 0 bytes/s, done.
Total 213 (delta 40), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Build failed
remote: ! Two different lockfiles found: package-lock.json and
yarn.lock
remote:
remote: Both npm and yarn have created lockfiles for this
application,
remote: but only one can be used to install dependencies.
Installing
remote: dependencies using the wrong package manager can
result in missing
remote: packages or subtle bugs in production.
remote:
remote: - To use npm to install your application's
dependencies please delete
remote: the yarn.lock file.
remote:
remote: $ git rm yarn.lock
remote:
remote: - To use yarn to install your application's
dependences please delete
remote: the package-lock.json file.
remote:
remote: $ git rm package-lock.json
remote:
remote: https://kb.heroku.com/why-is-my-node-js-build-
failing-because-of-conflicting-lock-files
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to MyAPP.
remote:
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'
I did rm and removed the yarn lock file since I use npm. Still the same error shows up. Now when I actually do rm yarn.lock I get a no entry found in the terminal. Idk why Heroku CLI insists that I still have yarn lock file in the directory.
If you use npm:
git rm yarn.lock
git commit -m "Remove yarn lock file"
git push heroku master
If you use yarn:
git rm package-lock.json
git commit -m "Remove npm lock file"
git push heroku master
Are you committing back to your master branch before pushing it up to Heroku?
Most often for me, problems like this arise when I make a code change and then 'git push heroku master' but my master branch has not been updated as I haven't yet committed my local changes.
Try
git commit -m 'some changes'
then
git push heroku master
delete both yarn.lock and package-lock.json and after it:
git add --all
git commit -a -m "Delete yarn lock and package lock"
git push
git push heroku master
that works for me!
I had the same problem, but the above suggestions didn't help. What I did was to delete yarn.lock (git rm yarn.lock) and the error was gone.
I had the same issue, but in my case I was pushing the master branch which contained both package-lock.json and yarn.lock. I fixed this by using the command git push heroku branch-name:master.
If you use npm please follow this :
rm yarn.lock
git add .
git commit -m 'remove yarn.lock file'
git push origin
git push heroku origin
Had the same issue. Not sure how package-lock is being recreated upon deploying to heroku but thats what seems to be happening. Try creating a .npmrc file and adding package-lock=false This fixed the issue for me.
Also check if you need a buildpack for deploying to heroku.
For example for meteor you need to add a buildpack
heroku buildpacks:set https://github.com/AdmitHub/meteor-buildpack-horse.git
if you have multiple apps for that git make sure to add --app foobar as your app name to your heroku command
In my case, I had to checkout main branch and run
git push heroku main.
this solved my problem
josh#josh:~/my_projects/la_manne$ git push heroku master
Énumération des objets: 3, fait.
Décompte des objets: 100% (3/3), fait.
Écriture des objets: 100% (3/3), 230 octets | 230.00 Kio/s, fait.
Total 3 (delta 0), réutilisés 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 73ed9a909f2a7e80a0a45f0f5d86aa6c7fdd70c1
remote: !
remote: ! We have detected that you have triggered a build from source code with version 73ed9a909f2a7e80a0a45f0f5d86aa6c7fdd70c1
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to lamanne.
remote:
To https://git.heroku.com/lamanne.git
! [remote rejected] master -> master (pre-receive hook declined)
error: impossible de pousser des références vers 'https://git.heroku.com/lamanne.git'
remote: -----> Building on the Heroku-20 stack
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
https://github.com/heroku/heroku-buildpack-php#usage
You'll need to use at least an empty composer.json in your
application.
$ echo '{}' > composer.json
$ git add composer.json
$ git commit -m "add composer.json for PHP app detection"
If you also have files from other frameworks or languages that could
trigger another buildpack to detect your application as one of its
own, e.g. a package.json which might cause your code to be detected
as a Node.js application even if it is a PHP application, then you
need to manually set your application to use this buildpack:
$ heroku buildpacks:set heroku/php
This will use the officially published version. To use the default
branch from GitHub instead:
$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-php
Please refer to Dev Center for further usage instructions.
I'm trying to run geodjango application on heroku and i added a build pack to make gdal available
https://github.com/cyberdelia/heroku-geo-buildpack.git. During push it's says that gdal and other geotools successfully installed
remote: -----> geos/gdal/proj app detected
remote: Using geos version: 3.6.1
remote: Using gdal version: 2.1.3
remote: Using proj version: 4.9.3
remote: -----> Vendoring geo libraries done
remote: -----> Python app detected
remote: ! The latest version of Python 3 is python-3.6.4 (you are using python-3.6.2, which is unsupported).
remote: ! We recommend upgrading by specifying the latest version (python-3.6.4).
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing requirements with pip
remote:
remote: -----> $ python manage.py collectstatic --noinput
remote: 1018 static files copied to '/tmp/build_2e0a13e9519778105269a34/test/staticfiles', 1158 post-processed.
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 235.8M
remote: -----> Launching...
remote: Released v60
remote: https://test.herokuapp.com deployed to Heroku
remote:
remote: Verifying deploy... done.
When i request page it says that application error.
from heroku logs
2018-03-19T14:25:00.614100+00:00 app[web.1]: from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
2018-03-19T14:25:00.614103+00:00 app[web.1]: from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
2018-03-19T14:25:00.614104+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/gis/gdal/libgdal.py", line 43, in <module>
2018-03-19T14:25:00.614106+00:00 app[web.1]: % '", "'.join(lib_names)
2018-03-19T14:25:00.614813+00:00 app[web.1]: [2018-03-19 14:25:00 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-03-19T14:25:00.746744+00:00 app[web.1]: [2018-03-19 14:25:00 +0000] [4] [INFO] Shutting down: Master
2018-03-19T14:25:00.746839+00:00 app[web.1]: [2018-03-19 14:25:00 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-03-19T14:25:00.614110+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0", "gdal1.10.0", "gdal1.9.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.>
Should i specify some path in settings or may be i'm using incompatible versions? (i'm using Django==2.0.2)
From Heroku's docs, add the following to your settings.py:
import dj_database_url
DATABASES['default'] = dj_database_url.config()
DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
GDAL_LIBRARY_PATH = os.getenv('GDAL_LIBRARY_PATH')
GEOS_LIBRARY_PATH = os.getenv('GEOS_LIBRARY_PATH')
Here is the correct Heroku Documentation on how to include gdal in your Heroku app. In brief, in your Django App root:
1. Create an empty file called Aptfile
2. In that file, include the line `gdal-bin` and save
Then:
$ git add Aptfile
$ git commit -m "Add apt dependency"
$ git push heroku master
This should have gdal running and accessible on your dyno.
Module not found: Error: Can't resolve 'babel-polyfill' in
'/tmp/build_7f85e1e4173bfdceff6d0abd745c2646/src' remote:
remote: error Command failed with exit code 1. remote:
info Visit https://yarnpkg.com/en/docs/cli/install for documentation
about this command. remote: remote: -----> Build failed remote:
remote: We're sorry this build is failing! You can troubleshoot
common issues here: remote:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
This is the error I get when I try to deploy my app to heroku.
"babel-polyfill": "^6.23.0",
is in my dependencies (not devDependencies).
I require babel in my index.js file on the first line:
import 'babel-polyfill';
Why cant heroku resolve the babel-polyfill ?
Heroku does not see my Procfile and begins installing the wrong version of py.
I'm trying to upload an extremely basic flask app using Heroku. As per other suggestions on SO, I've created my Procfile, runtime.txt, and requirements.txt using the command line, rather than through an editor. I've also ensured that they are located in the base git directory. When I enter
$ git push heroku master
I get the following:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: ! Warning: Your application is missing a Procfile. This file tells Heroku how to run your application.
remote: ! Learn more: https://devcenter.heroku.com/articles/procfile
remote: -----> Installing python-2.7.13
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote: Invalid requirement: 'Python 3.6.1'
remote: Traceback (most recent call last):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip/req/req_install.py", line 82, in __init__
remote: req = Requirement(req)
remote: File "/app/.heroku/python/lib/python2.7/site-package/pip/_vendor/packaging/requirements.py", line 96, in __init__
remote: requirement_string[e.loc:e.loc + 8]))
remote: InvalidRequirement: Invalid requirement, parse error at "u'3.6.1'"
remote:
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to salty-springs-82445.
remote:
To https://git.heroku.com/salty-springs-82445.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/salty-springs 82445.git'
Contents of Procfile:
web: python run.py
Here is the project structure:
▾ Random_world/
▸ __pycache__/
▾ app/
▸ __pycache__/
▸ static/
▸ templates/
__init__.py
main.py*
test.txt
▸ venv/
config.py
d.py*
os
Procfile
randomizer.py
randomizer.pyc
README.md
requirements.txt
run.py*
runtime.txt
test.txt
word_blocks.py
word_blocks.pyc
Thanks.
Figured it out. The Procfile was in my .gitignore, stupidly added by me.
Sidenote: the app wouldn't deploy at all because I was pushing from the wrong branch.
My guess is you forgot to add and commit your Procfile to git.