Bug 248255 - net-mgmt/librenms: ./validate.php script cannot find python3
Summary: net-mgmt/librenms: ./validate.php script cannot find python3
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dan Langille
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-25 07:52 UTC by Alexander Moisseev
Modified: 2024-02-27 04:13 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (dvl)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Moisseev 2020-07-25 07:52:23 UTC
# /usr/local/www/librenms/validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.65.1
DB Schema | 2020_06_23_00522_alter_availability_perc_column (170)
PHP       | 7.2.31
Python    |
MySQL     | 5.7.31
RRDTool   | 1.7.2
SNMP      | NET-SNMP 5.7.3
====================================

[OK]    Installed from package; no Composer required
[OK]    Database connection successful
[OK]    Database schema correct
[WARN]  fping FAILURES can be ignored if running LibreNMS in a jail without ::1. You may want to test it manually: fping ::1
[FAIL]  /usr/local/sbin/fping could not be executed. /usr/local/sbin/fping must have CAP_NET_RAW capability (getcap) or suid. Selinux exclusions may be required.
 (This account is currently not available.)
[WARN]  fping FAILURES can be ignored if running LibreNMS in a jail without ::1. You may want to test it manually: fping ::1
[FAIL]  /usr/local/sbin/fping6 could not be executed. /usr/local/sbin/fping6 must have CAP_NET_RAW capability (getcap) or suid. Selinux exclusions may be required.
 (This account is currently not available.)
[FAIL]  python3 not found
        [FIX]:
        Install Python 3 for your system.

# pkg info -ox pyth
py37-python-dotenv-0.14.0      www/py-python-dotenv
python37-3.7.8_1               lang/python37

# whereis python37
python37: /usr/ports/lang/python37

# /usr/local/bin/python3.7 --version
Python 3.7.8

Creating soft link fixes the issue:
# ln -s /usr/local/bin/python3.7 /usr/local/bin/python3
Comment 1 Dan Langille freebsd_committer freebsd_triage 2020-07-25 12:22:20 UTC
I encountered the same error when updating to 1.65.1

The patch at https://svnweb.freebsd.org/ports/head/net-mgmt/librenms/files/patch-LibreNMS_Util_Version.php?revision=542675&view=markup#l7 tries to fix this:

-        $proc = new Process(['python3', '--version']);
+        $proc = new Process(['/usr/local/bin/python3', '--version']);

That worked in my situation because I had lang/python3 installed. The symlink made that work for you.

What is the best approach for detecting python?

This works from the command line:

[dan@besser:~] $ env python --version
Python 3.7.8

However, changing that in the code still fails:

        $proc = new Process(['env python', '--version']);

Any ideas anyone?
Comment 2 Alexander Moisseev 2020-07-25 13:50:18 UTC
(In reply to Dan Langille from comment #1)

I believe "$ env python --version" works just because you have the `python` executable or symlink somewhere in the searchable path.
It won't help to find `python3.7` without lang/python3.

Probably lang/python3 is the only option, but we can't add it as a port dependency. At least its pkg-descr says so.
Comment 3 Dan Langille freebsd_committer freebsd_triage 2020-07-25 14:55:31 UTC
(In reply to Alexander Moisseev from comment #2)
I also tried 'env python3', which works from the command line:

$ env python3 --version
Python 3.7.8

But not in the code.

A recent change allows lang/python3 to be added as a dependency, but it requires a configuration change and won't help in this situation:

https://svnweb.freebsd.org/ports?view=revision&revision=542671
Comment 4 Alexander Moisseev 2020-07-25 16:54:40 UTC
I have no idea how to invoke env in Python or is it possible, but it doesn't matter since `env pyhon3` won't help without lang/python3 anyway.

Hopefully the issue doesn't break anything except config validation, so as the last resort we can recommend to install lang/python3 in the pkg-message.
Comment 5 Alexander Moisseev 2020-07-25 17:16:35 UTC
Just FYI,
I've managed to get env working in the code like so:

$proc = new Process(['env', 'python3', '--version']);

but IMO

$proc = new Process(['/usr/local/bin/python3', '--version']);

is better since we generally don't want to execute python3 from non-default locations.
Comment 6 Dan Langille freebsd_committer freebsd_triage 2020-07-25 17:44:57 UTC
(In reply to Alexander Moisseev from comment #4)
FYI, the env is invoked in PHP
Comment 7 Dan Langille freebsd_committer freebsd_triage 2020-07-25 18:05:43 UTC
(In reply to Alexander Moisseev from comment #5)

re $proc = new Process(['/usr/local/bin/python3', '--version']);

I'm OK with that.  That's what the code has now, but it does require lang/python3

With that fix, at the end of the outpu, are you also seeing this? I am.

sh: pip3: not found
Comment 8 Alexander Moisseev 2020-07-25 18:10:36 UTC
(In reply to Dan Langille from comment #7)

Yes, I see this line too.
I don't have pip installed.
Comment 9 Dan Langille freebsd_committer freebsd_triage 2020-07-25 18:11:46 UTC
Fixing
Comment 10 Dan Langille freebsd_committer freebsd_triage 2020-07-25 18:20:55 UTC
Now it works:

$ sudo /usr/local/www/librenms/validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.65.1
DB Schema | 2020_06_23_00522_alter_availability_perc_column (170)
PHP       | 7.4.8
Python    | 3.7.8
MySQL     | 5.7.31
RRDTool   | 1.7.2
SNMP      | NET-SNMP 5.7.3
====================================

[OK]    Installed from package; no Composer required
[OK]    Database connection successful
[OK]    Database schema correct
[WARN]  fping FAILURES can be ignored if running LibreNMS in a jail without ::1. You may want to test it manually: fping ::1
[FAIL]  /usr/local/sbin/fping could not be executed. /usr/local/sbin/fping must have CAP_NET_RAW capability (getcap) or suid. Selinux exclusions may be required.
 (This account is currently not available.)
[WARN]  fping FAILURES can be ignored if running LibreNMS in a jail without ::1. You may want to test it manually: fping ::1
[FAIL]  /usr/local/sbin/fping6 could not be executed. /usr/local/sbin/fping6 must have CAP_NET_RAW capability (getcap) or suid. Selinux exclusions may be required.
 (This account is currently not available.)
Comment 11 Dan Langille freebsd_committer freebsd_triage 2020-07-25 18:21:47 UTC
This is how I think validation needs to be run. The pwd is not relevant.

[dan@besser:~] $ echo /usr/local/www/librenms/validate.php | sudo su -fm www
====================================
Component | Version
--------- | -------
LibreNMS  | 1.65.1
DB Schema | 2020_06_23_00522_alter_availability_perc_column (170)
PHP       | 7.4.8
Python    | 3.7.8
MySQL     | 5.7.31
RRDTool   | 1.7.2
SNMP      | NET-SNMP 5.7.3
====================================

[OK]    Installed from package; no Composer required
[OK]    Database connection successful
[OK]    Database schema correct
[dan@besser:~] $
Comment 12 Alexander Moisseev 2020-07-25 18:32:51 UTC
(In reply to Dan Langille from comment #11)

I prefer passing command as an argument

# su -m www -c /usr/local/www/librenms/validate.php
Comment 13 Dan Langille freebsd_committer freebsd_triage 2020-07-25 18:35:23 UTC
For some reason, I found that didn't work in some cases.

I use -fm because that's what I found in FreeBSD periodic scripts.
Comment 14 commit-hook freebsd_committer freebsd_triage 2020-07-25 19:15:58 UTC
A commit references this bug:

Author: dvl
Date: Sat Jul 25 19:15:50 UTC 2020
New revision: 543428
URL: https://svnweb.freebsd.org/changeset/ports/543428

Log:
  Add lang/pyton3 recommendation to pkg-message

  While here, patch pip3 warnings, which we don't use because we are a
  package and we don't do things like that.

  PR:		248255
  Submitted by:	Alexander Moisseev <moiseev@mezonplus.ru>

Changes:
  head/net-mgmt/librenms/Makefile
  head/net-mgmt/librenms/files/patch-LibreNMS_Validations_Python.php
  head/net-mgmt/librenms/files/pkg-message.in
Comment 15 Dan Langille freebsd_committer freebsd_triage 2020-07-25 19:16:47 UTC
(In reply to Alexander Moisseev from comment #12)
Do you have time to try the recent commit?
Comment 16 Alexander Moisseev 2020-07-26 06:40:57 UTC
(In reply to Dan Langille from comment #15)

It works, thank you!
Comment 17 Dan Langille freebsd_committer freebsd_triage 2020-07-26 12:54:13 UTC
Thank you.
Comment 18 agarioqv 2024-02-27 02:36:13 UTC
MARKED AS SPAM