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

qvm-features-request in archlinux template uses environment to locate python/cannot always locate qubesdb module #4027

Open
bx opened this Issue Jun 20, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@bx

bx commented Jun 20, 2018

Qubes OS version:

R4.0

Affected component(s):

/usr/bin/qubes-features-request in archlinux template-based VMs


Steps to reproduce the behavior:

  1. Setup and enter local python environment (using a tool such as pyenv) that does not depend on any of the system-defined python modules
  2. Execute qvm-features-request

Expected behavior:

qvm-features-request quietly succeeds

[user@foo ~]$ qvm-features-request 
[user@foo ~]$

Actual behavior:

qvm-features-request fails to import qubesdb module

[user@foo ~]$ qvm-features-request	
Traceback (most recent call last):
  File "/usr/bin/qvm-features-request", line 30, in <module>
    import qubesdb
ImportError: No module named qubesdb

General notes:

This fix is simple. The first line of qubes-features-request relies on /usr/bin/env to locate python:
#!/usr/bin/env python2
It should be changed to:
#!/usr/bin/python2


Related issues:

From what I can tell, this is the only qubes-related tool included in the archlinux template that has this problem.
A quick look at scripts in /usr/bin with qubes or qvm in its name shows that the other python-based tools explicitly set /usr/bin/python2 as their interpreter

[user@foo ~] find /usr/bin | grep -E "(qubes|qvm)" | xargs file | grep script | awk -F ":" '{print $1}' | xargs head -n 1
==> /usr/bin/qubes-set-monitor-layout <==
#!/bin/bash

==> /usr/bin/qubes-gpg-import-key <==
#!/bin/bash

==> /usr/bin/qvm-run-vm <==
#!/bin/sh

==> /usr/bin/qubes-firewall <==
#!/usr/bin/python2

==> /usr/bin/qvm-copy <==
#!/bin/sh

==> /usr/bin/qvm-features-request <==
#!/usr/bin/env python2

==> /usr/bin/qubes-serial-login <==
#!/bin/sh

==> /usr/bin/qubes-gpg-client-wrapper <==
#!/bin/bash

==> /usr/bin/qvm-open-in-dvm <==
#!/bin/sh

==> /usr/bin/qubes-change-keyboard-layout <==
#!/usr/bin/python2

==> /usr/bin/qubes-desktop-run <==
#!/usr/bin/python2

==> /usr/bin/qvm-open-in-vm <==
#!/bin/sh

==> /usr/bin/qubes-session-autostart <==
#!/usr/bin/env python2

==> /usr/bin/qvm-sync-clock <==
#!/bin/sh

==> /usr/bin/qvm-copy-to-vm <==
#!/bin/sh

==> /usr/bin/qubes-session <==
#!/bin/bash

==> /usr/bin/qubes-open <==
#!/bin/sh

==> /usr/bin/qubesdb-read-bool <==
#!/bin/sh

==> /usr/bin/qubes-run-xorg.sh <==
#!/bin/sh
@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Jun 21, 2018

Member

This fix is simple. The first line of qubes-features-request relies on /usr/bin/env to locate python:
#!/usr/bin/env python2
It should be changed to:
#!/usr/bin/python2

While I agree with the change, not really sure if that would help. In both cases it's python2 and the error message isn't about missing python binary, but python module. Do you have alternative python2 in that VM (manual build or sth)?

Member

marmarek commented Jun 21, 2018

This fix is simple. The first line of qubes-features-request relies on /usr/bin/env to locate python:
#!/usr/bin/env python2
It should be changed to:
#!/usr/bin/python2

While I agree with the change, not really sure if that would help. In both cases it's python2 and the error message isn't about missing python binary, but python module. Do you have alternative python2 in that VM (manual build or sth)?

@bx

This comment has been minimized.

Show comment
Hide comment
@bx

bx Jun 21, 2018

Yes, I have a few VMs I use as development environments where have a pyenv setup to override the system-wide python environment. In such cases, the python modules installed along with /usr/bin/python2 do not get searched/loaded.

bx commented Jun 21, 2018

Yes, I have a few VMs I use as development environments where have a pyenv setup to override the system-wide python environment. In such cases, the python modules installed along with /usr/bin/python2 do not get searched/loaded.

@ptitdoc

This comment has been minimized.

Show comment
Hide comment
@ptitdoc

ptitdoc Jul 19, 2018

For python virtualenv you often have to initialise your environment with --system-site-packages if you want to inherit existing system packages. If not used you ends up with an isolated python environment with à minimal set of python modules.

In consequence when you run python, your virtualenv python is started which is linked to this few set of modules.

ptitdoc commented Jul 19, 2018

For python virtualenv you often have to initialise your environment with --system-site-packages if you want to inherit existing system packages. If not used you ends up with an isolated python environment with à minimal set of python modules.

In consequence when you run python, your virtualenv python is started which is linked to this few set of modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment