Hi,

I have a scripted install for pgadmin4 which worked as expected for
pgadmin7.7 when last used. I'm now trying to install 8.4 in a new VM, and
it fails like this:

$ sudo -i -u ubuntu PGADMIN_SETUP_EMAIL=x...@123.com
PGADMIN_SETUP_PASSWORD=abcd python3
/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/setup.py setup-db
2024-03-10 03:13:21,163: ERROR  pgadmin:        Database migration failed
2024-03-10 03:13:21,164: ERROR  pgadmin:        Traceback (most recent call
last):
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py",
line 386, in upgrade_db
   db_upgrade(app)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/setup/db_upgrade.py",
line 22, in db_upgrade
   flask_migrate.upgrade(migration_folder)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 111, in wrapped
   f(*args, **kwargs)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 198, in upgrade
   config = current_app.extensions['migrate'].migrate.get_config(directory,
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 96, in get_config
   for x in g.x_arg:
 File "/home/ubuntu/venv/lib/python3.10/site-packages/flask/ctx.py", line
54, in __getattr__
   raise AttributeError(name) from None
AttributeError: x_arg
...
ascii art traceback
...
AttributeError: x_arg

During handling of the above exception, another exception occurred:
...
ascii art traceback
...
FileNotFoundError: [Errno 2] No such file or directory:
'/var/lib/pgadmin/pgadmin4.db' ->
'/var/lib/pgadmin/pgadmin4.db.20240310031321'

Note: the argument "setup-db" was not previously used, but seems required
now. I've enclosed the output of "pip freeze" below. I have verified that
the directory "/var/lib/pgadmin" exists, and is writeable by the user
"ubuntu". In the same directory as setup.py is the following file:

$ cat
/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/config_local.py
LOG_FILE = '/var/log/pgadmin/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin/sessions'
STORAGE_DIR = '/var/lib/pgadmin/storage'
AZURE_CREDENTIAL_CACHE_DIR = '/var/lib/pgadmin/azurecredentialcache'
  <<< new entry
KERBEROS_CCACHE_DIR = '/var/lib/pgadmin/kerberoscache'
  <<< new entry
SERVER_MODE = True

Note: I have highlighted a couple of entries which I added after reading
the current installation documentation. I also tried launching the VM with
the previously working pgadmin4 7.7

$ sudo -i -u ubuntu PGADMIN_SETUP_EMAIL=1...@123.com
PGADMIN_SETUP_PASSWORD=abcdedg python3
/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/setup.py setup-db
2024-03-10 10:04:24,371: ERROR  pgadmin:        Database migration failed
2024-03-10 10:04:24,372: ERROR  pgadmin:        Traceback (most recent call
last):
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py",
line 390, in upgrade_db
   db_upgrade(app)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/setup/db_upgrade.py",
line 25, in db_upgrade
   flask_migrate.upgrade(migration_folder)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 111, in wrapped
   f(*args, **kwargs)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 198, in upgrade
   config = current_app.extensions['migrate'].migrate.get_config(directory,
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 96, in get_config
   for x in g.x_arg:
 File "/home/ubuntu/venv/lib/python3.10/site-packages/flask/ctx.py", line
52, in __getattr__
   raise AttributeError(name) from None
AttributeError: x_arg
Traceback (most recent call last):
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py",
line 390, in upgrade_db
   db_upgrade(app)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/setup/db_upgrade.py",
line 25, in db_upgrade
   flask_migrate.upgrade(migration_folder)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 111, in wrapped
   f(*args, **kwargs)
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 198, in upgrade
   config = current_app.extensions['migrate'].migrate.get_config(directory,
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py",
line 96, in get_config
   for x in g.x_arg:
 File "/home/ubuntu/venv/lib/python3.10/site-packages/flask/ctx.py", line
52, in __getattr__
   raise AttributeError(name) from None
AttributeError: x_arg
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/setup.py",
line 220, in <module>
   app = create_app()
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py",
line 477, in create_app
   run_migration_for_sqlite()
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py",
line 414, in run_migration_for_sqlite
   upgrade_db()
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py",
line 395, in upgrade_db
   backup_db_file()
 File
"/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py",
line 372, in backup_db_file
   os.rename(SQLITE_PATH, backup_file_name)
FileNotFoundError: [Errno 2] No such file or directory:
'/var/lib/pgadmin/pgadmin4.db' ->
'/var/lib/pgadmin/pgadmin4.db.20240310100424'

Note that 7.7 fails in the same way with or without the newly added
"setup-db" argument. Given this pattern, my guess is that flask-migrate or
flask is possibly the issue, rather than pgadmin4, but I have not been able
to debug/confirm that.

Any advice appreciated.

Thanks, Shaheed

Ecls: pip freeze output...

(venv) srhaque-paiyroll-28edd545c2 pip freeze
...
Flask==2.3.3
flask-babel==4.0.0
Flask-Compress==1.14
Flask-Gravatar==0.5.0
Flask-Login==0.6.3
Flask-Mail==0.9.1
Flask-Migrate==4.0.6
Flask-Paranoid==0.3.0
Flask-Principal==0.4.0
Flask-Security-Too==5.3.3
Flask-SocketIO==5.3.6
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.1
...
pgadmin4==8.4

Reply via email to