moloch-- / RootTheBox

A Game of Hackers (CTF Scoreboard & Game Manager)
http://root-the-box.com/
Apache License 2.0
915 stars 292 forks source link

UnboundLocalError: local variable 'path' referenced before assignment #547

Closed aztr4x closed 1 year ago

aztr4x commented 1 year ago

webapp_1 | [I 230305 21:25:23 rootthebox:262] Environment Configuration (SQL_DIALECT): sqlite webapp_1 | [I 230305 21:25:23 rootthebox:1139] Running Docker Setup webapp_1 | [I 230305 21:25:23 ConfigHelpers:15] Saving current config to: files/rootthebox.cfg webapp_1 | [] Switching CWD to '/opt/rtb' webapp_1 | [] 21:25:23 : Creating the database ... webapp_1 | Traceback (most recent call last): webapp_1 | File "/opt/rtb/rootthebox.py", line 1147, in webapp_1 | setup() webapp_1 | File "/opt/rtb/rootthebox.py", line 100, in setup webapp_1 | from setup.create_database import create_tables, engine, metadata webapp_1 | File "/opt/rtb/setup/create_database.py", line 21, in webapp_1 | from models import engine webapp_1 | File "/opt/rtb/models/init.py", line 75, in webapp_1 | engine = create_engine(str(db_connection), pool_pre_ping=True) webapp_1 | File "/opt/rtb/libs/DatabaseConnection.py", line 63, in str webapp_1 | db_conn = self._sqlite() webapp_1 | File "/opt/rtb/libs/DatabaseConnection.py", line 112, in _sqlite webapp_1 | logging.debug("Created rootthebox database at: %s" % path) webapp_1 | UnboundLocalError: local variable 'path' referenced before assignment rootthebox_webapp_1 exited with code 1

2023-03-05 15_25_58-

eljeffeg commented 1 year ago

Thanks for the report - I pushed a fix.

aztr4x commented 1 year ago

Thanks for the report - I pushed a fix.

I did a system build and then tried the new changes

webapp_1 | [I 230305 21:47:19 rootthebox:262] Environment Configuration (SQL_DIALECT): sqlite webapp_1 | [I 230305 21:47:19 rootthebox:1139] Running Docker Setup webapp_1 | [I 230305 21:47:19 ConfigHelpers:15] Saving current config to: files/rootthebox.cfg webapp_1 | [*] Switching CWD to '/opt/rtb' webapp_1 | [*] 21:47:19 : Creating the database ... webapp_1 | Traceback (most recent call last): webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3361, in _wrap_pool_connect webapp_1 | return fn() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 327, in connect webapp_1 | return _ConnectionFairy._checkout(self) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout webapp_1 | fairy = _ConnectionRecord.checkout(pool) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 493, in checkout webapp_1 | rec = pool._do_get() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 256, in _do_get webapp_1 | return self._create_connection() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection webapp_1 | return _ConnectionRecord(self) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 388, in __init__ webapp_1 | self.__connect() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 691, in __connect webapp_1 | pool.logger.debug("Error on connect(): %s", e) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ webapp_1 | compat.raise_( webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ webapp_1 | raise exception webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 686, in __connect webapp_1 | self.dbapi_connection = connection = pool._invoke_creator(self) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 578, in connect webapp_1 | return dialect.connect(*cargs, **cparams) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 598, in connect webapp_1 | return self.dbapi.connect(*cargs, **cparams) webapp_1 | sqlite3.OperationalError: unable to open database file webapp_1 | webapp_1 | The above exception was the direct cause of the following exception: webapp_1 | webapp_1 | Traceback (most recent call last): webapp_1 | File "/opt/rtb/rootthebox.py", line 1147, in <module> webapp_1 | setup() webapp_1 | File "/opt/rtb/rootthebox.py", line 102, in setup webapp_1 | create_tables(engine, metadata, options.log_sql) webapp_1 | File "/opt/rtb/setup/create_database.py", line 28, in create_tables webapp_1 | sqla_metadata.create_all(sqla_engine) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/sql/schema.py", line 4930, in create_all webapp_1 | bind._run_ddl_visitor( webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3227, in _run_ddl_visitorwebapp_1 | with self.begin() as conn: webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3143, in begin webapp_1 | conn = self.connect(close_with_result=close_with_result) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3315, in connect webapp_1 | return self._connection_cls(self, close_with_result=close_with_result) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 96, in __init__ webapp_1 | else engine.raw_connection() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3394, in raw_connection webapp_1 | return self._wrap_pool_connect(self.pool.connect, _connection) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3364, in _wrap_pool_connect webapp_1 | Connection._handle_dbapi_exception_noconnection( webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2198, in _handle_dbapi_exception_noconnection webapp_1 | util.raise_( webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ webapp_1 | raise exception webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3361, in _wrap_pool_connect webapp_1 | return fn() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 327, in connect webapp_1 | return _ConnectionFairy._checkout(self) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout webapp_1 | fairy = _ConnectionRecord.checkout(pool) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 493, in checkout webapp_1 | rec = pool._do_get() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 256, in _do_get webapp_1 | return self._create_connection() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection webapp_1 | return _ConnectionRecord(self) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 388, in __init__ webapp_1 | self.__connect() webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 691, in __connect webapp_1 | pool.logger.debug("Error on connect(): %s", e) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__ webapp_1 | compat.raise_( webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ webapp_1 | raise exception webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 686, in __connect webapp_1 | self.dbapi_connection = connection = pool._invoke_creator(self) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 578, in connect webapp_1 | return dialect.connect(*cargs, **cparams) webapp_1 | File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 598, in connect webapp_1 | return self.dbapi.connect(*cargs, **cparams) webapp_1 | sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file webapp_1 | (Background on this error at: https://sqlalche.me/e/14/e3q8) rootthebox_webapp_1 exited with code 1

2023-03-05 15_50_01- 2023-03-05 15_49_51-

eljeffeg commented 1 year ago

Dang, ok thought that would be a quick fix. I'll spin up a docker and see what is going on with that location change for the db.

eljeffeg commented 1 year ago

Ok, let's try this again. Should be fixed now. I had broken it a couple weeks ago with this edit - thanks for reporting the bug. https://github.com/moloch--/RootTheBox/commit/c268eb292f3b0ab05e956844ac7565c29adcc2aa#diff-28b75ddf0a306d002a27fd3a8374104223982c8b8f757021f6324ad1666bb8f3