Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git is not available at run time in Heroku Stack-24 by default #334

Closed
dbeatty10 opened this issue Nov 8, 2024 · 0 comments · Fixed by #335
Closed

git is not available at run time in Heroku Stack-24 by default #334

dbeatty10 opened this issue Nov 8, 2024 · 0 comments · Fixed by #335

Comments

@dbeatty10
Copy link
Contributor

Reason

Starting with Heroku Stack-24, if git is needed at runtime, then it has to be installed using the APT buildpack.

hupcap.py definitely needs git at run time!

Instructions

https://devcenter.heroku.com/articles/heroku-24-stack#upgrading-to-heroku-24

Git is now only available at build time and not also at app run time.

If your app needs Git at run time for other purposes, install it using the APT buildpack:

Add the buildpack (if you are not already using it), with: heroku buildpacks:add --index 1 heroku-community/apt
Create a file named Aptfile in the root of your app source code, containing the package name git on its own line.
Add export GIT_EXEC_PATH=/app/.apt/usr/lib/git-core to any Bash scripts that call Git at run time, so that Git can find the custom installation. (This step is only necessary until heroku/heroku-buildpack-apt#137 is fixed, and prevents a git: 'remote-https' is not a git command error.)

Logs

Since I didn't do any of the steps above as part of the upgrade process to Heroku Stack-24, here's the error logs I got:

Starting process with command `python3 hubcap.py` by user [email protected]
Starting process with command `python3 hubcap.py`
State changed from starting to up
Traceback (most recent call last):
  File ""/app/.heroku/python/lib/python3.9/site-packages/git/__init__.py"", line 89, in <module>
    refresh()
  File ""/app/.heroku/python/lib/python3.9/site-packages/git/__init__.py"", line 76, in refresh
    if not Git.refresh(path=path):
  File ""/app/.heroku/python/lib/python3.9/site-packages/git/cmd.py"", line 392, in refresh
    raise ImportError(err)
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File ""/app/hubcap.py"", line 6, in <module>
    from hubcap import package
  File ""/app/hubcap/package.py"", line 7, in <module>
    from git import Repo
  File ""/app/.heroku/python/lib/python3.9/site-packages/git/__init__.py"", line 91, in <module>
    raise ImportError(""Failed to initialize: {0}"".format(exc)) from exc
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception"

Example:
    export GIT_PYTHON_REFRESH=quiet
Process exited with status 1
State changed from up to complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant