Media scanner cli is crashing [fixed] - needed env variable set

So now I’m curious, if it works for you … maybe you’re the one with extra special helpful environment variables!

You guys just hang out in the Plex Ivory Tower, where there are always charcuterie plates and Herman Miller chairs and every environment variable is sacred, right? Keeping the “good” builds for yourselves?

Literally nothing is wrong for me, I’m just dumb-curious about why I need an environment variable if it should work by default. I’m happy it’s documented (in a forum post …) and will sleep soundly.

So if you have something better to do … ignore me …

Actually I think the issue here is why it segfaults for you in the first place… It doesn’t for me even without setting any env and just calling the bin directly, I get the help/usage text if I just call it directly:

 su -m plex -c "./Plex\ Media\ Scanner"
Plex Media Scanner (c) 2010-2019 Plex Development Team.

  -h, --help           Display this message.
  -v, --verbose        Show more output.
  -p, --progress       Show special progress output.
  --log-file-suffix    Specify suffix for log file.

 Actions:

ofc trying to actually use any option would get me at least failing python modules or such, but the point is its odd that it segfaults to you!

FWIW I am on FreeBSD12.1 and running plex in a iocage jail. So this is not FreeNAS; rc.con is just "plexmediaserver_enable="YES so its all defaults.

Note that you should still do what you’re doing to get it to work properly and setting PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR is not wrong in any means don’t get me wrong, initially I said look into start.sh or the rc.d script (the rc.d script for PMS does set that one if you look) and its set to whatever plexmediaserver_support_path is set to

export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=${plexmediaserver_support_path}

And as a minimized version this seems to work fine for the scanner (I tested my self and works fine too) so why not :slight_smile:

I’m used to being “special”! :innocent:

I get the same results you do if I don’t pass any arguments/options.

root@plex:/usr/local/share/plexmediaserver # su -m plex -c "./Plex\ Media\ Scanner"
Plex Media Scanner (c) 2010-2019 Plex Development Team.

  -h, --help           Display this message.
  -v, --verbose        Show more output.
  -p, --progress       Show special progress output.
  --log-file-suffix    Specify suffix for log file.

 Actions: <trimmed>

It’s when adding arguments that it starts to break.

root@plex:/usr/local/share/plexmediaserver # su -m plex -c "./Plex\ Media\ Scanner -l"
Abort

Plex Media Scanner (c) 2010-2019 Plex Development Team.

Hey update your copyright dates! I took my Christmas tree down so it’s time. :stuck_out_tongue:

1 Like

Hey folks, just wanted to clarify that I was indeed running this as another user, sorry for my missing that. I am running plex on FreeBSD, not in a jail.

$ freebsd-version
12.1-RELEASE-p5

If I simulate a full login to the plex user (not preserving my typical user’s environment su -l plex), here is the results depending on env:

$ env
SHELL=/usr/local/bin/bash
PWD=/home/plex
HOME=/home/plex
LANG=en_US.UTF-8
TERM=screen-256color
USER=plex
SHLVL=1
MM_CHARSET=en_US.UTF-8
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/plex/bin
BLOCKSIZE=K
MAIL=/var/mail/plex
_=/usr/bin/env
$ /usr/local/share/plexmediaserver/Plex\ Media\ Scanner
Plex Media Scanner (c) 2010-2019 Plex Development Team.

  -h, --help           Display this message.
<snip>
$ /usr/local/share/plexmediaserver/Plex\ Media\ Scanner --list
Abort trap (core dumped)

In my set up it appears all I need is to set PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR, then things work.

$ export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/usr/local/plexdata
$ /usr/local/share/plexmediaserver/Plex\ Media\ Scanner --list
<works>

Whether or not it “should” crash if that env variable is not a topic I have a comment for.
Thanks again for your help.

1 Like

yeah ideally it shouldn’t just segfault but produce some meaningful error, we actually made some fixes with the new scanner work (in forum preview). But not sure if it catches all cases.

Speaking of, and totally out of curiosity, since we have an API that allows similar functionality why do you guys prefer the cli tool? (just curious really)

I just started playing with the API.

I should have started with that, but old habits die hard, and I know how quickly I could normally shell up some functions to rescan libraries when I want it to. Actually the thing that finally made me move to the API was the CLI’s insistence on showing output on fd3, which for some reason I can’t even process with pexpect. Now I’ve moved on, so I don’t care anymore, but I read the thread that mentioned it’s using fd3 because that’s what cout does… Not in my tests, not sure what kinda cout you guys are using. --Anyway, when I’ve got time to actually have fun again I’ll be back writing calls to the API. Cheers.

My answer is 90% the same as @habys’s. Old habits. Comfort in the CLI and with shell scripts. Not an informed preference.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.