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

can't launch pgadmin4 on master #169322

Closed
teto opened this issue Apr 19, 2022 · 12 comments
Closed

can't launch pgadmin4 on master #169322

teto opened this issue Apr 19, 2022 · 12 comments
Labels

Comments

@teto
Copy link
Member

teto commented Apr 19, 2022

Describe the bug

on master b07f020, trying to run pgadmin4 fails:

❯ nix shell .#pgadmin
nixpkgs2 on  master 
➜ pgadmin
pgadmin: command not found
nixpkgs2 on  master 
❯ pgadmin4
Traceback (most recent call last):
  File "/nix/store/4cbmq2dxcfrb5yfbpdv92fq8qk9zg483-pgadmin-6.7/bin/.pgadmin4-wrapped", line 6, in <module>
    from pgadmin4.pgAdmin4 import main
  File "/nix/store/4cbmq2dxcfrb5yfbpdv92fq8qk9zg483-pgadmin-6.7/lib/python3.9/site-packages/pgadmin4/pgAdmin4.py", line 98, in <module>
    app = create_app()
  File "/nix/store/4cbmq2dxcfrb5yfbpdv92fq8qk9zg483-pgadmin-6.7/lib/python3.9/site-packages/pgadmin4/pgadmin/__init__.py", line 233, in create_app
    app.jinja_env.trim_blocks = True
  File "/nix/store/q07dwn6b7rl574ka43xq5f8d7j17apzd-python3.9-Flask-2.1.1/lib/python3.9/site-packages/flask/helpers.py", line 752, in __get__
    return super().__get__(obj, type=type)
  File "/nix/store/0gyvjdji4rwslg7gmib2x7i1gnm4vbw3-python3.9-werkzeug-2.1.0/lib/python3.9/site-packages/werkzeug/utils.py", line 107, in __get__
    value = self.fget(obj)  # type: ignore
  File "/nix/store/q07dwn6b7rl574ka43xq5f8d7j17apzd-python3.9-Flask-2.1.1/lib/python3.9/site-packages/flask/app.py", line 602, in jinja_env
    return self.create_jinja_environment()
  File "/nix/store/q07dwn6b7rl574ka43xq5f8d7j17apzd-python3.9-Flask-2.1.1/lib/python3.9/site-packages/flask/app.py", line 694, in create_jinja_environment
    rv = self.jinja_environment(self, **options)
  File "/nix/store/q07dwn6b7rl574ka43xq5f8d7j17apzd-python3.9-Flask-2.1.1/lib/python3.9/site-packages/flask/templating.py", line 42, in __init__
    BaseEnvironment.__init__(self, **options)
  File "/nix/store/4yicnl0ycpjqb5z3np5c53y619p5zv3s-python3.9-Jinja2-3.1.1/lib/python3.9/site-packages/jinja2/environment.py", line 363, in __init__
    self.extensions = load_extensions(self, extensions)
  File "/nix/store/4yicnl0ycpjqb5z3np5c53y619p5zv3s-python3.9-Jinja2-3.1.1/lib/python3.9/site-packages/jinja2/environment.py", line 117, in load_extensions
    extension = t.cast(t.Type["Extension"], import_string(extension))
  File "/nix/store/4yicnl0ycpjqb5z3np5c53y619p5zv3s-python3.9-Jinja2-3.1.1/lib/python3.9/site-packages/jinja2/utils.py", line 149, in import_string
    return getattr(__import__(module, None, None, [obj]), obj)
AttributeError: module 'jinja2.ext' has no attribute 'autoescape'

another issue is that nix run .#pgadmin wont work, we could set mainProgram.

@teto teto added the 0.kind: bug Something is broken label Apr 19, 2022
@teto
Copy link
Member Author

teto commented Apr 19, 2022

cc maintainer @gador

@gador
Copy link
Member

gador commented Apr 19, 2022

Hi, thanks for the bug report and ping.

This seems to be culprit.

The new version of pgadmin4 seems to have addressed the issue here.

I'll update the pgadmin4 package and see if the error persists.

@gador
Copy link
Member

gador commented Apr 19, 2022

Alright. Even with an update to 6.8 the tests partially fail for pgadmin.
Trying the updated pgadmin in a VM results in me not being able to login. I just get a json response.

The reason are the updates of Flask and Werkzeug.
When reverting those to the version 2.0.3 pgadmin4 v6.8 is able to pass the tests and I can login within a VM.

I am unsure how to continue from here. Adding an override for Flask and/or Werkzeug within the pgadmin4 derivation results in duplicate packages and errors.

@SuperSandro2000 maybe you have an idea? I can only think of downgrading Nix-wide

@FRidh
Copy link
Member

FRidh commented Apr 19, 2022

@gador you can cherry-pick #169354 and test whether that works on top of your version bump.

@gador
Copy link
Member

gador commented Apr 19, 2022

@gador you can cherry-pick #169354 and test whether that works on top of your version bump.

Thanks a lot! That was really helpful!

@teto
Copy link
Member Author

teto commented May 20, 2022

I added locally mainProgram = "pgadmin4"; but other than that thanks for the fix

@teto teto closed this as completed May 20, 2022
@teto
Copy link
Member Author

teto commented May 25, 2022

NOTE: mainProgram set in #174010

Sorry to bump the thread for an unrelated issue but I am a bit puzzled by pgadmin4 on nixos and thought you might know since it's a silly question.

First of all it's weird that -h or --help is useless:

$ pgadmin4 --help
ERROR  : Failed to create the directory /var/lib/pgadmin:
           [Errno 13] Permission denied: '/var/lib/pgadmin'
HINT :   Create the directory /var/lib/pgadmin, ensure it is writeable by
         'teto', and try again, or, create a config_local.py file
         and override the SQLITE_PATH setting per
         https://www.pgadmin.org/docs/pgadmin4/6.8/config_py.html

Seems like the path on unstable is rather /var/lib/postgresql/13 so I followed the hint, added the config_local.py with SQLITE_PATH="/var/lib/postgresql/13" to no avail. How do you use pgadmin @gador ? do you use it on non-nixos then ?

@gador
Copy link
Member

gador commented May 25, 2022

The /var/lib/postgresql/13 path has basically nothing to do with pgadmin4, but with postgresql.

The directory /var/lib/pgadmin and /var/log/pgadmin need to exist first and permission need to be set to the user running pgadmin4.
I did run pgadmin4 without the systemd service before and this is what worked for me.

Setting another directory for Pgadmin is described in their docs.

@teto
Copy link
Member Author

teto commented May 25, 2022

I've created the /etc/pgadmin/config_system.py and it seems to take it into account since it triggers errors when badly formatted but I can't manage to disable SERVER_MODE (setting it to None or False accomplishes nothing).

reading https://www.pgadmin.org/docs/pgadmin4/6.9/desktop_deployment.html#desktop-runtime-standalone-application it seems like the packaging should contain something that can be run in desktop mode without any pyuthon overrides (no critique, just trying to understand how it works).

@gador
Copy link
Member

gador commented May 25, 2022

Desktop Mode didn't work for me. It just disables the multi-user Mode and one cannot set a user/pw programmatically. Se the discussion around it here.
There is no reason (IMHO) to not use SERVER_MODE. Even for single-user usecase.

What exactly do you mean with python overrides?

If you are on a non-nixos system and can't use the systemd service, I'd suggest creating the directories mentioned above and starting pgadmin4. This is how it worked for me before the systemd service got introduced. Theoretically you can override the directories pgadmin4 uses with the config file. However, I found it easiest to just use /var/lib/pgadmin and /var/log/pgadmin

@teto
Copy link
Member Author

teto commented May 25, 2022

sry I didn't get straightaway that there was a service to run too.
So I had to create /var/lib/pgadmin and /var/log/pgadmin, assign them to pgadmin:pgadmin and add my current user to the pgadmin group.

To troubleshoot the numerous errors (first my password was not readable etc), I ran the systemd prescript as
sudo -u pgadmin /nix/store/id8fxhjslmcqwbvhlaqmqwmqr1q86az5-unit-script-pgadmin-pre-start/bin/pgadmin-pre-start

Finally when trying to run pgadmin4 as my user, it failed to read /etc/pgadmin/config_system.py because its permissions are 0600 so I had to run sudo -u pgadmin pgadmin4. To sum up, I was looking for a desktop program to see my postgres database but ended up with a really strange software. Thanks for the help. I will play with it but I think I may just try to bump dbeaver to see if it fixes crashes.

@gador
Copy link
Member

gador commented May 26, 2022

Glad it finally worked for you!

I just assigned the directories to my user name and ran pgadmin from my user account.
As far as I remember I didn't have to fiddle with the config.py file either (and I certainly didn't run the pre script, since it didn't exist back then).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants