Bug 477422 - If brew / linuxbrew is installed. KDE Partition Manager doesn't show any disk.
Summary: If brew / linuxbrew is installed. KDE Partition Manager doesn't show any disk.
Status: RESOLVED FIXED
Alias: None
Product: partitionmanager
Classification: Applications
Component: general (show other bugs)
Version: 23.08.3
Platform: Fedora RPMs Linux
: NOR major
Target Milestone: ---
Assignee: Andrius Štikonas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-23 15:22 UTC by badshah
Modified: 2023-11-26 01:12 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 24.02.0
Sentry Crash Report:


Attachments
empty partion manager (11.74 KB, image/webp)
2023-11-23 15:22 UTC, badshah
Details

Note You need to log in before you can comment on or make changes to this bug.
Description badshah 2023-11-23 15:22:05 UTC
Created attachment 163395 [details]
empty partion manager

Using Fedora Kinoite 39. When brew/linuxbrew is installed and source it in `.bashrc`. Partition Manager is empty. It literally shows no disk.
But when the source line is removed from .bashrc. Everything works correctly. 

My guess is when some libraries are installed from brew. Partition manager conflicts with it. Instead of using system library. It uses library from linuxbrew. And can't show any drive.

Several people using steam deck has faced similar issue.
https://www.reddit.com/r/SteamDeck/comments/13pix57/kde_partition_manager_is_not_displaying_any/
Comment 1 badshah 2023-11-23 15:23:52 UTC
If it helps. These are my brew libraries.

❯ brew list
alsa-lib         freetype    krb5        libsamplerate  libxcrypt      mbedtls       pixman              tree-sitter
aom              frei0r      ladspa-sdk  libsndfile     libxcursor     mpdecimal     pulseaudio          unbound
aribb24          fribidi     lame        libsodium      libxdmcp       mpfr          python-argcomplete  unibilium
berkeley-db@5    gcc         leptonica   libsoxr        libxext        mpg123        python-certifi      unzip
binutils         gettext     libarchive  libtasn1       libxfixes      msgpack       python-mutagen      util-linux
brotli           giflib      libass      libtermkey     libxi          ncurses       python-packaging    vamp-plugin-sdk
bzip2            glib        libb2       libtiff        libxinerama    neofetch      python@3.11         webp
c-ares           gmp         libbluray   libtirpc       libxml2        neovim        python@3.12         x264
ca-certificates  gnutls      libcap      libtool        libxrandr      nettle        rav1e               x265
cairo            graphite2   libedit     libunibreak    libxrender     node          readline            xinput
chezmoi          harfbuzz    libevent    libunistring   libxscrnsaver  open-mpi      rubberband          xorgproto
cjson            highway     libffi      libuv          libxv          opencore-amr  sdl2                xvid
dav1d            htop        libice      libvidstab     libxxf86vm     openexr       snappy              xz
dbus             hwloc       libidn2     libvmaf        little-cms2    openjpeg      speex               yt-dlp
expat            icu4c       libmpc      libvorbis      lm-sensors     openssl@3     speexdsp            zeromq
fastfetch        imath       libnghttp2  libvpx         luajit         opus          sqlite              zimg
ffmpeg           isl         libnsl      libvterm       luv            p11-kit       srt                 zlib
fftw             jpeg-turbo  libogg      libx11         lz4            pango         svt-av1             zstd
flac             jpeg-xl     libpng      libxau         lzo            pcre2         tesseract
fontconfig       json-c      librist     libxcb         m4             pipx          theora
Comment 2 Andrius Štikonas 2023-11-23 19:28:52 UTC
That links says it's util-linux. And that makes sense. util-linux is used to scan for devices.

In particular, to get device list partition manager runs:

lsblk --nodeps --paths --sort name --json --output type,name

What does it output on your system?
Comment 3 badshah 2023-11-23 19:36:29 UTC
(In reply to Andrius Štikonas from comment #2)
> That links says it's util-linux. And that makes sense. util-linux is used to
> scan for devices.
> 
> In particular, to get device list partition manager runs:
> 
> lsblk --nodeps --paths --sort name --json --output type,name
> 
> What does it output on your system?

I get this

```
❯ lsblk --nodeps --paths --sort name --json --output type,name
{
   "blockdevices": [
      {
         "type": "disk",
         "name": "/dev/sda"
      },{
         "type": "disk",
         "name": "/dev/sdb"
      },{
         "type": "disk",
         "name": "/dev/zram0"
      }
   ]
}
```
Comment 4 Andrius Štikonas 2023-11-23 19:42:56 UTC
Hmm, that does look fine, so that's strange...

Anything interesting stdout/stderr if you run
KPMCORE_DEBUG=1 partitionmanager

It should print the list of commands it  is running... We can then try to run them manually
Comment 5 Andrius Štikonas 2023-11-23 19:47:29 UTC
Oh, it's probably because of the prefix. That reddit thread says:
"/home/linuxbrew/.linuxbrew" prefix is not one of the trusted command prefixes

By default partitionmanager only allows calling commands from / and /usr prefixes. That is for security reasons, specifically to avoid accidentally running non-system commands (that might be malicious) as root.

Which is kind of exactly what you are trying to do with homebrew. Partition Manager notices that you are running it from somewhere untrusted and aborts. You need to add your prefix to src/util/trustedprefixes and recompile it.
Comment 6 Andrius Štikonas 2023-11-23 19:51:43 UTC
Or you can run it with PATH=/usr/bin:/bin:/sbin/:/usr/sbin partitionmanager
Comment 7 Andrius Štikonas 2023-11-23 20:05:35 UTC
What should be improved though is reporting back error to GUI rather than failing silently. That was already on the planned for future (but I have no ETA for it).
Comment 8 badshah 2023-11-23 20:16:08 UTC
(In reply to Andrius Štikonas from comment #6)
> Or you can run it with PATH=/usr/bin:/bin:/sbin/:/usr/sbin partitionmanager

This works. 
Can you force it automatically to use the system libraries? It should check if system path exist. And try to use them instead of user one.
Comment 9 Andrius Štikonas 2023-11-23 20:36:55 UTC
(In reply to Zihad from comment #8)
> (In reply to Andrius Štikonas from comment #6)
> > Or you can run it with PATH=/usr/bin:/bin:/sbin/:/usr/sbin partitionmanager
> 
> This works. 
> Can you force it automatically to use the system libraries? It should check
> if system path exist. And try to use them instead of user one.

Hmm, yes, I was just thinking about this too... I think it should be possible.
Comment 10 Andrius Štikonas 2023-11-26 01:11:24 UTC
Git commit 6e7efe97c29c4bdab38388a6931df379dd2a8d3b by Andrius Štikonas.
Committed on 26/11/2023 at 02:09.
Pushed by stikonas into branch 'master'.

Only search for binaries in trusted prefixes.

Untrusted prefixes are blocked by external command helper anyway.

M  +10   -3    src/util/externalcommand.cpp

https://invent.kde.org/system/kpmcore/-/commit/6e7efe97c29c4bdab38388a6931df379dd2a8d3b