sahib / rmlint

Extremely fast tool to remove duplicates and other lint from your filesystem
http://rmlint.rtfd.org
GNU General Public License v3.0
1.86k stars 128 forks source link

scons cannot find json-glib on Alpine Linux #592

Closed eddsalkield closed 1 year ago

eddsalkield commented 1 year ago

Currently on Alpine Linux 3.16, the test test_size.test_replay_size fails silently with exit code 1.

======================================================================
ERROR: test_size.test_replay_size
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/edd/dev/aports/testing/rmlint/src/rmlint-2.10.1/tests/test_options/test_size.py", line 102, in test_replay_size
    head, *data, footer = run_rmlint('--replay {p} --size 1-10B'.format(
  File "/home/edd/dev/aports/testing/rmlint/src/rmlint-2.10.1/tests/utils.py", line 295, in run_rmlint
    return run_rmlint_once(*args, **kwargs)
  File "/home/edd/dev/aports/testing/rmlint/src/rmlint-2.10.1/tests/utils.py", line 160, in run_rmlint_once
    output = subprocess.check_output(cmd, env=env)
  File "/usr/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/home/edd/dev/aports/testing/rmlint/src/rmlint-2.10.1/rmlint', '-V', '/tmp/rmlint-unit-testdir', '--replay', '/tmp/replay.json', '--size', '1-10B', '-o', 'json:/tmp/out.json', '-c', 'json:oneline']' returned non-zero exit status 1.
cebtenzzre commented 1 year ago

Are you on a 32-bit or 64-bit platform? And have you checked out a particular branch or commit or just the 2.10.1 release tag? What is the exact command you used to run the testsuite? There are some known issues with the --size code but I don't think I've seen that failure before.

 tests/test_options/test_size.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test_options/test_size.py b/tests/test_options/test_size.py
index 51de398d..7940ca25 100644
--- a/tests/test_options/test_size.py
+++ b/tests/test_options/test_size.py
@@ -101,7 +101,7 @@ def test_replay_size():

     head, *data, footer = run_rmlint('--replay {p} --size 1-10B'.format(
         p=replay_path
-    ))
+    ), verbosity='-vv')

     assert [e["type"] for e in data] == \
            ["emptydir"] + (["emptyfile"] * 2) + (["duplicate_file"] * 4)

If you put the above in a file called verbosity.patch and then run the following commands in the rmlint-2.10.1 directory, what output do you get? You should see [okay] on several lines and not [nope: bad size].

$ patch -Np1 <verbosity.patch
$ RM_TS_PRINT_CMD=1 nosetests -d tests/test_options/test_size.py:test_replay_size

This is the output I get with latest master on 64-bit Arch Linux:

INFO: Loading json-results `/tmp/rmlint-unit-testdir/replay.json'
Checking `/tmp/rmlint-unit-testdir/empty_dir`: [okay]
Checking `/tmp/rmlint-unit-testdir/empty2`: [okay]
Checking `/tmp/rmlint-unit-testdir/empty1`: [okay]
Checking `/tmp/rmlint-unit-testdir/b/yyy`: [okay]
Checking `/tmp/rmlint-unit-testdir/a/yyy`: [okay]
Checking `/tmp/rmlint-unit-testdir/b/xxx`: [okay]
Checking `/tmp/rmlint-unit-testdir/a/xxx`: [okay]
.
----------------------------------------------------------------------
Ran 1 test in 0.112s

OK
eddsalkield commented 1 year ago

Sorry for the lack of specificity in the initial report.

Are you on a 32-bit or 64-bit platform?

I'm on x86_64.

And have you checked out a particular branch or commit or just the 2.10.1 release tag?

This is the 2.10.1 release.

What is the exact command you used to run the testsuite?

scons test

I've run with the verbose patch, and the error became immediately apparent - a lack of json-glib libraries:

test_size.test_replay_size ... ERROR: json-glib is needed for using --replay.
ERROR: Please recompile `rmlint` with it installed.
WARNING: Loading /tmp/replay.json failed.
ERROR: No valid .json files given, aborting.
ERROR

However, I have these libraries currently installed. I think it's something to do with SConstruct checking for json-glib-1.0 instead of json-glib:

henleybeach:~$ pkg-config --exists json-glib-1.0
henleybeach:~$ echo $?
0
henleybeach:~$ pkg-config --exists json-glib
henleybeach:~$ echo $?
1

I tried modifying the SConstruct file with s/json-glib-1.0/json-glib/g but still getting:

henleybeach:~$ scons config
...
    Find non-stripped binaries (needs libelf)             : no
    Optimize using ioctl(FS_IOC_FIEMAP) (needs linux)     : yes
    Support for SHA512 (needs glib >= 2.31)               : yes
    Build manpage from docs/rmlint.1.rst                  : yes, using /usr/bin/sphinx-build
    Support for caching checksums in file's xattr         : yes
    Support for reading json caches (needs json-glib)     : no

Any further thoughts?

cebtenzzre commented 1 year ago

Based on the command output it looks like json-glib-1.0 does in fact exist (zero indicates success). The result of pkg-config is cached so you may need to clear the SCons cache if you have installed json-glib-dev since your first run:

$ rm -rf .sconf_temp .sconsign.dblite
$ scons -c
$ scons config

If that doesn't change anything then the output of these commands would be useful:

$ pkg-config --path json-glib-1.0
$ env | grep PKG_CONFIG
eddsalkield commented 1 year ago

Based on the command output it looks like json-glib-1.0 does in fact exist (zero indicates success).

It's bizarre since that zero for success is the usual convention, but I think it's actually the other way around in this case (or maybe I'm misreading): https://github.com/sahib/rmlint/blob/2711b84bb264b41015d718b06b0e5be065d42ebc/SConstruct#L81

The result of pkg-config is cached so you may need to clear the SCons cache if you have installed json-glib-dev since your first run

I ran it on a completely clean source directory and got the same result as I initially reported.

Command outputs:

henleybeach:~$ pkg-config --path json-glib-1.0
/usr/lib/pkgconfig/json-glib-1.0.pc
henleybeach:~$ env | grep PKG_CONFIG
henleybeach:~$ pkg-config --path json-glib

Thanks for helping me track this one down!

cebtenzzre commented 1 year ago

I finally got around to installing Alpine Linux 3.16 (alpine-standard-3.16.2-x86_64.iso) and testing this for myself. Here's what I did:

  1. Uncomment the community repo in /etc/apk/repositories
  2. doas apk update
  3. doas apk add git gcc scons libc-dev glib-dev json-glib-dev py3-nose py3-pip
  4. pip install xattr
  5. git clone https://github.com/sahib/rmlint.git
  6. cd rmlint
  7. scons config - shows this in the output:
    Support for reading json caches (needs json-glib)     : yes
  8. scons GDB=1
  9. nosetests tests/test_options/test_size.py:test_replay_size - shows this output:
    
    .
    ----------------------------------------------------------------------
    Ran 1 test in 0.113s

OK



So I cannot reproduce the issue. Let me know if there's anything special about your system configuration that's different from what I did here.