NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.08k stars 14.13k forks source link

gyb: crashes on startup, complains about missing python module #329225

Open gdinh opened 3 months ago

gdinh commented 3 months ago

Describe the bug

Package gyb crashes on execute, complaining of missing python module.

Steps To Reproduce

Steps to reproduce the behavior:

$ nix-shell -p gyb
[nix-shell:~]$ gyb --version
Traceback (most recent call last):
  File "/nix/store/akild48w36i3k7pc6z8nj0qbp51vmzy4-gyb-1.81/bin/.gyb-wrapped", line 87, in <module>
    import google.oauth2.service_account
ModuleNotFoundError: No module named 'google.oauth2'

Oddly enough, trying the import in the python repl works.

[nix-shell:~]$ which python
/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python

[nix-shell:~]$ python
Python 3.12.4 (main, Jun  6 2024, 18:26:44) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.oauth2.service_account
>>> google.oauth2.service_account
<module 'google.oauth2.service_account' from '/nix/store/hcryx5gig96q4f4dhx3aphyc14x6pj8z-python3.12-google-auth-2.30.0/lib/python3.12/site-packages/google/oauth2/service_account.py'>

Notify maintainers

@austinbutler

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

Reproduced bug on two machines:

Machine 1:

 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.5.0, macOS 14.5`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.4`
 - channels(grace): `""`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/store/fwsfyb388gd6qfws95whlp77g3wymjxy-source`

Machine 2:

 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.0-182-generic, Ubuntu, 20.04.6 LTS (Focal Fossa), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.16.1`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/home/eecs/dinh/.nix-defexpr/channels/nixpkgs`

Add a :+1: reaction to issues you find important.

brookst commented 3 months ago

Weird. I'm just running into a different issue, but I can reproduce yours if I use an ephemeral shell.

> nix-shell -p gyb
[nix-shell:~]$ gyb --version
Traceback (most recent call last):
  File "/nix/store/akild48w36i3k7pc6z8nj0qbp51vmzy4-gyb-1.81/bin/.gyb-wrapped", line 87, in <module>
    import google.oauth2.service_account
ModuleNotFoundError: No module named 'google.oauth2'

However I first added it to systemPackages and it just worked.

> gyb --version
Got Your Back 1.81
jaylee.us/gyb
Jay Lee - jay0lee@gmail.com
Python 3.12.4 64-bit final
google-api-client 2.135.0
Linux-6.6.35-x86_64-with-glibc2.39 x86_64
Path: /nix/store/akild48w36i3k7pc6z8nj0qbp51vmzy4-gyb-1.81/bin
ConfigPath: /nix/store/akild48w36i3k7pc6z8nj0qbp51vmzy4-gyb-1.81/bin
OpenSSL 3.0.14 4 Jun 2024
gmail.googleapis.com connects using TLSv1.3 TLS_AES_256_GCM_SHA384

So maybe something else in my systemPackages is providing google.oauth2?

In any case, this didn't completely work. After setting things up, gyb tried to write to a json in the binary directory:

...
The authentication flow has completed.
Creating project "Got Your Back Project"...
Checking project status...
 enabling API drive.googleapis.com...
 enabling API gmail.googleapis.com...
 enabling API groupsmigration.googleapis.com...
 enabling API iap.googleapis.com...
 enabling API vault.googleapis.com...
Creating Service Account
ERROR: [Errno 30] Read-only file system: '/nix/store/akild48w36i3k7pc6z8nj0qbp51vmzy4-gyb-1.81/bin/oauth2service.json'
brookst commented 3 months ago

So after a lot of fiddling around with the Google API config, I managed to get a backup started.

The solution for the 'Read-only file system' error is to always explicitly specify the config directory with --config-folder and an appropriate path.

I'm not sure what makes gyb work when installed as a system package, but perhaps that will work for others.

AndrewKvalheim commented 2 months ago

Sounds like this is working as intended? 🤷