Reputation: 57391
I recently installed pybrake
for a Django app, and now when I run my development server, I see the following error:
2018-05-29 18:32:13,414 - pybrake - ERROR - get_git_revision failed: [Errno 2] No such file or directory: '/Users/kurtpeek/Documents/Dev/lucy2/lucy-web/.git/HEAD'
After that, however, the development server seems to start up normally; here is the full terminal response:
(venv) Kurts-MacBook-Pro-2:lucy-web kurtpeek$ python manage.py runserver
2018-05-29 18:32:13,414 - pybrake - ERROR - get_git_revision failed: [Errno 2] No such file or directory: '/Users/kurtpeek/Documents/Dev/lucy2/lucy-web/.git/HEAD'
2018-05-29 18:32:15,353 - pybrake - ERROR - get_git_revision failed: [Errno 2] No such file or directory: '/Users/kurtpeek/Documents/Dev/lucy2/lucy-web/.git/HEAD'
Performing system checks...
System check identified no issues (0 silenced).
(0.000) SELECT typarray FROM pg_type WHERE typname = 'citext'; args=None
(0.006)
SELECT c.relname, c.relkind
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'v')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid); args=None
(0.031) SELECT "django_migrations"."app", "django_migrations"."name" FROM "django_migrations"; args=()
May 29, 2018 - 18:32:17
Django version 1.11.9, using settings 'lucy.settings.development'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
The error still irks me a bit though and I'd like to remove it. It seems like this get_git_revision
function is looking in the wrong directory: the .git
directory is located in lucy2
, not in lucy2/lucy-web
.
However, I actually was unable to figure out where this error is coming from: I did a project-wide search for get_git_revision
but didn't find anything. How can I figure out the source of this error?
Upvotes: 0
Views: 278
Reputation: 57391
As suggested by the formatting of the error message, the error is actually thrown by pybrake
itself. By inspecting the source code (https://github.com/airbrake/pybrake/blob/master/pybrake/notifier.py), I found that it is possible to pass an (undocumented) root_directory
key to the AIRBRAKE
setting, like so:
AIRBRAKE = dict(
project_id=os.getenv('AIRBRAKE_API_KEY'),
project_key=os.getenv('AIRBRAKE_PROJECT_ID'),
root_directory=os.path.dirname(os.path.dirname(BASE_DIR)))
where the root_directory
is appropriately selected to contain the .git
directory. Now I can run the development server without errors:
(venv) Kurts-MacBook-Pro-2:lucy-web kurtpeek$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
(0.000) SELECT typarray FROM pg_type WHERE typname = 'citext'; args=None
(0.006)
SELECT c.relname, c.relkind
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'v')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid); args=None
(0.001) SELECT "django_migrations"."app", "django_migrations"."name" FROM "django_migrations"; args=()
May 29, 2018 - 19:12:30
Django version 1.11.9, using settings 'lucy.settings.development'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Incidentally, os.path.dirname(os.getcwd())
would also work here, as it goes one directory up from pybrake
's default, os.getcwd()
.
Upvotes: 1