Trouble updating server on Debian-based Raspbian

Server Version#: 1.18.6.2368
Player Version#: 4.20.2

I recently moved (well, started fresh) my Plex server off a power-hungry Windows box onto Rasberry Pi 4 running Raspbian, and have run into some difficulties updating. I checked existing threads but didn’t see the exact issue I’m experiencing.

I’ve used the Customizing your Plex configuration guide to move my Plex metadata libraries onto an EXT4-formatted external 4TB HDD, and I’ve enabled repository updating for DEB-based distros.

Unfortunately updating fails at the Pre-installation Validation, saying PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR in my /etc/systemd/system/plexmediaserver.service.d/override.conf does not exist. Isn’t that impossible since my server is running fine? Here’s the terminal output from the upgrade attempt:

pi@raspberrypi:~ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  binutils binutils-arm-linux-gnueabihf binutils-common libbinutils raspi-config
The following packages will be upgraded:
  plexmediaserver
1 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
16 not fully installed or removed.
Need to get 0 B/70.9 MB of archives.
After this operation, 318 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Reading changelogs... Done
(Reading database ... 45912 files and directories currently installed.)
Preparing to unpack .../plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb ...
PlexMediaServer install: Pre-installation Validation.
' used in /etc/systemd/system/plexmediaserver.service.d/override.conf.
' used in /etc/systemd/system/plexmediaserver.service.d/override.conf.
' used in /etc/systemd/system/plexmediaserver.service.d/override.conf  does not exist.
dpkg: error processing archive /var/cache/apt/archives/plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb (--unpack):
 new plexmediaserver package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Here’s my override.conf file:

# Customize Plex's config

# Identify this as a service override
[Service]

# Move the data directory
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/mnt/media/Plex/Library/Application Support"

# These values are only needed if you wish to change user
User=pi
Group=pi

# This is needed to change the default umask
UMask=0002    # this must be octal    - See warning below

I checked ownership of the PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR, and it’s correct. Any suggestions would be greatly appreciated!

Thanks,
AC

If you look, the script itself is having problems running and printing error messages.
These are echo statements from the shell.

Something else is seriously wrong at the system level.

Further,
You have other, more important, upgrades to install first.

The following packages have been kept back:
  binutils binutils-arm-linux-gnueabihf binutils-common libbinutils raspi-config

Hmm, I did notice that some other packages are held back, but don’t understand what that has to do with the Plex Pre-Install Validation failing. Aren’t the echo statements are intended to print the path set in PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR?

I was thinking initially that the spaces in the path were causing the problem, so I tried a variation that works in BASH shell, but no dice: /mnt/media/Plex/Library/Application\ Support/

Any other ideas or stuff I can try? I’m happy to do some more diagostics.

The script is written to run in basic /bin/sh (not bash).

It uses several commands from the bin-utils package.

Per the errors shown in your output.

' used in /etc/systemd/system/plexmediaserver.service.d/override.conf.

It comes from three possible places: TEMP_DIR and APP_SUPP_DIR
A simple regex is used to parse the string out of override.conf
Your file is fine. There are no syntax errors in the specification.

The code which generates the message you see is:

    # Validate Application Support Dir (antimatter storage)
    if [ "$OverrideAppSupp" != "" ]; then
      if [ ! -d "$OverrideAppSupp" ]; then
        Output "Error: Directory \"$OverrideAppSupp\" used in \"$OverrideFile\" does not exist."
        Errors=$((Errors + 1))
        Fail=1
      else
        AppSuppDir="$OverrideAppSupp"
      fi
    fi

    # Validate Tmpdir
    if [ "$OverrideTmpdir" != "" ]; then
      if [ ! -d "$OverrideTmpdir" ]; then
        Output "Error: Directory \"$OverrideTmpdir\" used in \"$OverrideFile\" does not exist."
        Errors=$((Errors + 1))
        Fail=1
      else
        PlexTempDir="$OverrideTmpdir"
      fi
    fi
Output() {

  # Prepare base message
  Message="PlexMediaServer install: $1"

  # Add supplemental information for special case of preferences.xml
  if [ "$2" = "1" ]; then
    Message="$Message (set in Preferences.xml)"
  fi

  # Output the message even if a blank message (make output nice)
  echo "$Message"

  # Return if blank.
  if [ "$1" = "" ]; then
    return
  fi

  # Output to log
  if [ $Systemd -eq 1 ]; then
    echo MESSAGE="$Message" | logger --journald
  else
    echo "$Message" | logger
  fi
}

Output() is a function of mine to control writing output to the terminal window, log file, or both. It’s very simple and uses echo to deliver the message to you.
If echo is failing, you have a problem with /bin/sh and its libraries.

Those updates which have been held back are important and needed.

I’m having some problems too and I don’t really know how to upgrade.

[pi] in 📁~
└ > sudo dpkg -i plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb 
(Reading database ... 50116 files and directories currently installed.)
Preparing to unpack plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb ...
Warning: The unit file, source configuration file or drop-ins of plexmediaserver.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Removed /etc/systemd/system/multi-user.target.wants/plexmediaserver.service.
PlexMediaServer install: Pre-installation Validation.  
dpkg: error processing archive plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb (--install):
 new plexmediaserver package pre-installation script subprocess returned error exit status 2
Created symlink /etc/systemd/system/multi-user.target.wants/plexmediaserver.service → /lib/systemd/system/plexmediaserver.service.
Errors were encountered while processing:
 plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb

it’s warning you.

You changed the service override but didn’t update systemd.

I’m so sorry. That was not my massage. Well, that was the message after I play around with some things, but the original message is this:

[pi] in 📁~
└ > sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  plexmediaserver
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/70.9 MB of archives.
After this operation, 720 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Reading changelogs... Done
(Reading database ... 50116 files and directories currently installed.)
Preparing to unpack .../plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb ...
Removed /etc/systemd/system/multi-user.target.wants/plexmediaserver.service.
PlexMediaServer install: Pre-installation Validation.  
dpkg: error processing archive /var/cache/apt/archives/plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb (--unpack):
 new plexmediaserver package pre-installation script subprocess returned error exit status 2
Created symlink /etc/systemd/system/multi-user.target.wants/plexmediaserver.service → /lib/systemd/system/plexmediaserver.service.
Errors were encountered while processing:
 /var/cache/apt/archives/plexmediaserver_1.18.7.2457-77cb9455c_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Please read my reply here in the Issues thread.

See if any of it applies to you.

I have just upgraded to version 1.19.1.2630 successfully. Thanks for everything!

@ChuckPa

I’m still having no success updating to 1.19.1.2701 on my Raspberry Pi. The pre-installation validation gives me the same error, despite having successfully updated all other packages on my system.

I read through the thread here but am still at a loss, since the directory specified in PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR is valid as you pointed out earlier.

That seems to be the only thing tripping up the pre-install script. Got any more ideas?

Thanks!

pi@raspberrypi:~ $ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  plexmediaserver
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
13 not fully installed or removed.
Need to get 0 B/71.4 MB of archives.
After this operation, 950 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Reading changelogs... Done
(Reading database ... 46091 files and directories currently installed.)
Preparing to unpack .../plexmediaserver_1.19.1.2701-6327e27bf_armhf.deb ...
PlexMediaServer install: Pre-installation Validation.
" used in "/etc/systemd/system/plexmediaserver.service.d/override.conf".
" used in "/etc/systemd/system/plexmediaserver.service.d/override.conf".
" used in "/etc/systemd/system/plexmediaserver.service.d/override.conf" does not exist.
PlexMediaServer install:
PlexMediaServer install: Pre-installation Validation failed.
PlexMediaServer install: Configuration information discovered:
PlexMediaServer install:   Installation Type:  New
PlexMediaServer install:   Process Control:    systemd
PlexMediaServer install:   Plex User:          plex
PlexMediaServer install:   Plex Group:         plex
PlexMediaServer install:   Video Group:        video
PlexMediaServer install:   Metadata Dir:       /var/lib/plexmediaserver/Library/Application Support
PlexMediaServer install:   Temp Directory:     /tmp
PlexMediaServer install:   Lang Encoding:      en_US.UTF-8
PlexMediaServer install:   Config file used:   /etc/systemd/system/plexmediaserver.service.d/override.conf
PlexMediaServer install:   Transcoding HW:     Not found
PlexMediaServer install:
PlexMediaServer install: Pre-installation Validation complete.  Errors: 3, Warnings: 0
dpkg: error processing archive /var/cache/apt/archives/plexmediaserver_1.19.1.2701-6327e27bf_armhf.deb (--unpack):
 new plexmediaserver package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/plexmediaserver_1.19.1.2701-6327e27bf_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

You see where it shows there are errors in the override.conf file.

Please share the override.conf file contents?
We’ll see what it doesn’t like and correct it. I suspect a missing quote.

Sure, here’s the override:

pi@raspberrypi:~ $ cat /etc/systemd/system/plexmediaserver.service.d/override.conf
# Customize Plex's config

# Identify this as a service override
[Service]

# Move the data directory
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/mnt/media/Plex/Library/Application Support"

# These values are only needed if you wish to change user
User=pi
Group=pi

# This is needed to change the default umask
UMask=0002    # this must be octal    - See warning below

I think I found it. What a nice edge case.

[chuck@lizum /tmp.514]$ ./filter
/mnt/media/Plex/Library/Application Support
pi
pi
0002 # this must be octal - See warning below
[chuck@lizum /tmp.515]$

Notice the value of UMask ?

As verification, Remove the # comment from the UMask line.

Here’s the function which reads the Override.conf

[chuck@lizum debian.512]$ cat /tmp/filter
#!/bin/sh

GetValue()
{

  Retval=""

  Retval="$(grep -v '^#' "$2" | sed -e 's/^export //' | sed -e 's/^Environment=//' | \
            sed -e 's/^"//' | grep ^"$1" | head -1 | awk -F= '{print $2}' | tr -d '"' )"

  echo "$Retval"
}

echo $(GetValue "PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" /tmp/sample)
echo $(GetValue "User" /tmp/sample)
echo $(GetValue "Group" /tmp/sample)
echo $(GetValue "UMask" /tmp/sample)

[chuck@lizum debian.513]$
[chuck@lizum debian.513]$ cat /tmp/sample
# Customize Plex's config

# Identify this as a service override
[Service]

# Move the data directory
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/mnt/media/Plex/Library/Application Support"

# These values are only needed if you wish to change user
User=pi
Group=pi

# This is needed to change the default umask
UMask=0002    # this must be octal    - See warning below
[chuck@lizum debian.514]$

Interesting idea, and oh lord, haven’t seen sed in a while! Unfortunately didn’t make a difference. Here’s the modified override when I tried again to upgrade:

pi@raspberrypi:~ $ cat /etc/systemd/system/plexmediaserver.service.d/override.conf
# Customize Plex's config

# Identify this as a service override
[Service]

# Move the data directory
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/mnt/media/Plex/Library/Application Support"

# These values are only needed if you wish to change user
User=pi
Group=pi

# This is needed to change the default umask
UMask=0002

One last thing before I get really frustrated.

Change
Plex's Config

to
Plex Config

It’s commented out and therefore should be ignored by the grep

If you can take the script, as I’ve written it, and obtain the same results, then there’s something very funky going on which makes no sense.

Supplemental:

It’s likely failing here but the first part of the “Error: Directory” is missing.

    fi

    # Validate Application Support Dir (antimatter storage)
    if [ "$OverrideAppSupp" != "" ]; then
      if [ ! -d "$OverrideAppSupp" ]; then
        Output "Error: Directory \"$OverrideAppSupp\" used in \"$OverrideFile\" does not exist."
        Errors=$((Errors + 1))
        Fail=1
      else
        AppSuppDir="$OverrideAppSupp"
      fi
    fi


What’s the most disturbing is this is solid code. Why it is failing for you makes no sense.

I’ve gone the full setup to resolve this.

  1. Copy & paste the actual code
  2. Added just enough so it could run.

Output:

[chuck@lizum /tmp.537]$ vi filter 
[chuck@lizum /tmp.538]$ ./filter
PlexMediaServer install: Error: Directory "/mnt/media/Plex/Library/Application Support" used in "/tmp/sample" does not exist.
pi
pi
0002 # this must be octal - See warning below
[chuck@lizum /tmp.539]$ 

This is your input used with the code.

[chuck@lizum /tmp.541]$ cat filter
#!/bin/sh


Systemd=1
Init=0
# Function to output to log and console.
#
# Usage:
#   $1 =  Message (should be "Text Message" quoted).
#   $2 =  Optional "0" or "1" flag.   "1" adds "(extracted from Preferences.xml)" message
#
#   Note: Blank lines (Null text strings "") are not written to the system log.  There is no need to waste that space.
Output() {

  # Prepare base message
  Message="PlexMediaServer install: $1"

  # Add supplemental information for special case of preferences.xml
  if [ "$2" = "1" ]; then
    Message="$Message (set in Preferences.xml)"
  fi

  # Output the message even if a blank message (make output nice)
  echo "$Message"

  # Return if blank.
  if [ "$1" = "" ]; then
    return
  fi

  # Output to log
  if [ $Systemd -eq 1 ]; then
    echo MESSAGE="$Message" | logger --journald
  else
    echo "$Message" | logger
  fi
}

GetValue()
{

  Retval=""

  Retval="$(grep -v '^#' "$2" | sed -e 's/^export //' | sed -e 's/^Environment=//' | \
            sed -e 's/^"//' | grep ^"$1" | head -1 | awk -F= '{print $2}' | tr -d '"' )"

  echo "$Retval"
}


Errors=0
OverrideFile=/tmp/sample

OverrideAppSupp="$(GetValue "PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" /tmp/sample)"

# Copied from *preinst*
    # Validate Application Support Dir (antimatter storage)
    if [ "$OverrideAppSupp" != "" ]; then
      if [ ! -d "$OverrideAppSupp" ]; then
        Output "Error: Directory \"$OverrideAppSupp\" used in \"$OverrideFile\" does not exist."
        Errors=$((Errors + 1))
        Fail=1
      else
        AppSuppDir="$OverrideAppSupp"
      fi
    fi



echo $(GetValue "User" /tmp/sample)
echo $(GetValue "Group" /tmp/sample)
echo $(GetValue "UMask" /tmp/sample)

[chuck@lizum /tmp.542]$ 

If the above works in isolation but doesn’t in the install,

  1. Uninstall the previous package (no harm comes to your data)
  2. Restart
  3. Install again.

Thanks for digging in. I modified the override again removing the ' from Plex's Config in the comment line, but the update still trips at the same place.

So just to confirm, you’re saying I should use apt to uninstall Plex and then run a fresh install after rebooting? Won’t the installer fail again as long as the override exists?

either sudo apt remove or sudo dpkg -e
apt ends up calling dpkg

Uninstalled and could not reinstall because of the pre-install validation. The only way I could get it to reinstall was:

  1. Stop the server: sudo systemctl stop plexmediaserver
  2. Uninstall Plex: sudo apt remove plexmediaserver
  3. Rename the systemd service override config temporarily: /etc/systemd/system/plexmediaserver.service.d/override.conf
  4. Install Plex: sudo apt install plexmediaserver
  5. Stop Plex: sudo systemctl stop plexmediaserver
  6. Restore the override.
  7. Reload systemctl: sudo systemctl daemon-reload
  8. Start Plex: sudo systemctl start plexmediaserver

Now I have the latest version and my data is still intact.