Ticket #2498 (closed defect: fixed)
Opened 6 years ago
Last modified 6 years ago
Logging error with initenv
| Reported by: | Manuzhai | Owned by: | daniel |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.10 |
| Component: | admin/console | Version: | devel |
| Severity: | normal | Keywords: | |
| Cc: | manuzhai@… | ||
| Release Notes: | |||
| API Changes: | |||
Description
When there is a central trac.ini (in /etc) that enables logging to a file in the environment, initenv fails because it cannot find the file. Makes some sense, since it's looking for a directory that still has to be written, probably.
Failed to create environment. [Errno 2] No such file or directory: '/var/trac/life/log/trac.log'
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/trac/scripts/admin.py", line 570, in do_initenv
options=options)
File "/home/manuzhai/dev/trac/trac/env.py", line 78, in __init__
self.setup_log()
File "/home/manuzhai/dev/trac/trac/env.py", line 232, in setup_log
self.log = logger_factory(logtype, logfile, loglevel, logid)
File "/home/manuzhai/dev/trac/trac/log.py", line 26, in logger_factory
hdlr = logging.FileHandler(logfile)
File "/usr/lib/python2.4/logging/__init__.py", line 753, in __init__
stream = open(filename, mode)
IOError: [Errno 2] No such file or directory: '/var/trac/life/log/trac.log'
Failed to initialize environment. 1
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/trac/scripts/admin.py", line 574, in do_initenv
sys.exit(1)
SystemExit: 1
Attachments
Change History
comment:1 Changed 6 years ago by Manuzhai
- Milestone set to 0.10
comment:2 Changed 6 years ago by anonymous
- Version changed from 0.9.2 to devel
comment:3 Changed 6 years ago by Manuzhai
I looked into this some more. I think I fixed the problem, but then trac-admin crashes with a seemingly unrelated exception, see below:
Creating and Initializing Project
Failed to create environment. local variable 'connector' referenced before assignment
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/trac/scripts/admin.py", line 584, in do_initenv
options=options)
File "/usr/lib/python2.4/site-packages/trac/env.py", line 82, in __init__
self.create(options)
File "/usr/lib/python2.4/site-packages/trac/env.py", line 193, in create
DatabaseManager(self).init_db()
File "/usr/lib/python2.4/site-packages/trac/db/api.py", line 52, in init_db
connector, args = self._get_connector()
File "/usr/lib/python2.4/site-packages/trac/db/api.py", line 77, in _get_connector
if not connector:
UnboundLocalError: local variable 'connector' referenced before assignment
Failed to initialize environment. 1
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/trac/scripts/admin.py", line 588, in do_initenv
sys.exit(1)
SystemExit: 1
I'll attach my "fix".
comment:4 Changed 6 years ago by Manuzhai
Okay, here's another one that actually works.
Changed 6 years ago by Manuzhai
- Attachment patch-2498.2.diff added
Fix #2498 by delaying the database initialization.
comment:5 Changed 6 years ago by mgood
- Resolution set to fixed
- Status changed from new to closed
The patch didn't quite work for me since some things were still looking for the log before it was initialized. Instead in [3277] I made sure the default config options are loaded for new environments before setting up logging.



This is still here! Just ran into it again today.
Assigning to 0.10, as it shouldn't be too hard.