Mopidy does not update the database

Hello, I have a problem with mopidy running on an OrangePi PC.
I’ve added a few files to my music folder, so I gave the command to update the database:

mopidyctl local scan

It found the files to be updated but then, after scanning, this is the output:

INFO     Scanned 327 of 327 files in 33s.
ERROR    [Errno 13] Permission denied: '/mnt/dietpi_userdata/mopidy/dat
/local/library.json.gz.I2W9JU'
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mopidy/__main__.py", line 134,
in main
    return args.command.run(args, proxied_config)
  File "/usr/lib/python2.7/dist-packages/mopidy/local/commands.py", lin
 167, in run
    library.close()
  File "/usr/lib/python2.7/dist-packages/mopidy/local/json.py", line 17
, in close
    'tracks': self._tracks.values()
  File "/usr/lib/python2.7/dist-packages/mopidy/internal/storage.py", l
ne 51, in dump
    prefix=basename + '.', dir=directory, delete=False)
  File "/usr/lib/python2.7/tempfile.py", line 462, in NamedTemporaryFil
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
  File "/usr/lib/python2.7/tempfile.py", line 239, in _mkstemp_inner
    fd = _os.open(file, flags, 0600)
OSError: [Errno 13] Permission denied: '/mnt/dietpi_userdata/mopidy/dat
/local/library.json.gz.I2W9JU'
Traceback (most recent call last):
  File "/usr/bin/mopidy", line 9, in <module>
    load_entry_point('Mopidy==2.1.0', 'console_scripts', 'mopidy')()
  File "/usr/lib/python2.7/dist-packages/mopidy/__main__.py", line 134,
in main
    return args.command.run(args, proxied_config)
  File "/usr/lib/python2.7/dist-packages/mopidy/local/commands.py", lin
 167, in run
    library.close()
  File "/usr/lib/python2.7/dist-packages/mopidy/local/json.py", line 17
, in close
    'tracks': self._tracks.values()
  File "/usr/lib/python2.7/dist-packages/mopidy/internal/storage.py", l
ne 51, in dump
    prefix=basename + '.', dir=directory, delete=False)
  File "/usr/lib/python2.7/tempfile.py", line 462, in NamedTemporaryFil
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
  File "/usr/lib/python2.7/tempfile.py", line 239, in _mkstemp_inner
    fd = _os.open(file, flags, 0600)
OSError: [Errno 13] Permission denied: '/mnt/dietpi_userdata/mopidy/dat
/local/library.json.gz.I2W9JU'
root@OPiHome: #

I then tried with

mopidyctl local scan --force

but after scanning the files it gave this error:

INFO     Scanned 9295 of 9295 files in 1152s.
ERROR    [Errno 13] Permission denied: '/mnt/dietpi_userdata/mopidy/dat
/local/library.json.gz.OH0ri5'
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mopidy/__main__.py", line 134,
in main
    return args.command.run(args, proxied_config)
  File "/usr/lib/python2.7/dist-packages/mopidy/local/commands.py", lin
 167, in run
    library.close()
  File "/usr/lib/python2.7/dist-packages/mopidy/local/json.py", line 17
, in close
    'tracks': self._tracks.values()
  File "/usr/lib/python2.7/dist-packages/mopidy/internal/storage.py", l
ne 51, in dump
    prefix=basename + '.', dir=directory, delete=False)
  File "/usr/lib/python2.7/tempfile.py", line 462, in NamedTemporaryFil
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
  File "/usr/lib/python2.7/tempfile.py", line 239, in _mkstemp_inner
    fd = _os.open(file, flags, 0600)
OSError: [Errno 13] Permission denied: '/mnt/dietpi_userdata/mopidy/dat
/local/library.json.gz.OH0ri5'
Traceback (most recent call last):
  File "/usr/bin/mopidy", line 9, in <module>
    load_entry_point('Mopidy==2.1.0', 'console_scripts', 'mopidy')()
  File "/usr/lib/python2.7/dist-packages/mopidy/__main__.py", line 134,
in main
    return args.command.run(args, proxied_config)
  File "/usr/lib/python2.7/dist-packages/mopidy/local/commands.py", lin
 167, in run
    library.close()
  File "/usr/lib/python2.7/dist-packages/mopidy/local/json.py", line 17
, in close
    'tracks': self._tracks.values()
  File "/usr/lib/python2.7/dist-packages/mopidy/internal/storage.py", l
ne 51, in dump
    prefix=basename + '.', dir=directory, delete=False)
  File "/usr/lib/python2.7/tempfile.py", line 462, in NamedTemporaryFil
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
  File "/usr/lib/python2.7/tempfile.py", line 239, in _mkstemp_inner
    fd = _os.open(file, flags, 0600)
OSError: [Errno 13] Permission denied: '/mnt/dietpi_userdata/mopidy/dat
/local/library.json.gz.OH0ri5'

No need to say that the database has not been updated.
Any suggestions? Thanks!

Ok, it looks like the problem is the file /usr/sbin/mopidyctl and specifically this line:

DAEMON_USER=“mopidy”

It looks like user mopidy does not have the permissions to write in the /mnt/dietpi_userdata/mopidy/dat
/local directory.

Editing the file into:

DAEMON_USER=“root”

solved the problem, although I’m not sure this is the correct solution to be implemented.

The programmer of mopidy (who helped me with this issue) asked me to pass the following information:

"ask the people at DietPi what they are trying to do with this config:
github.com
Fourdee/DietPi/blob/master/dietpi/dietpi-software#L8480-L8483*

library = images
media_dir = $FP_DIETPI_USERDATA_DIRECTORY/Music
enabled = true
library = json

if they want to use local-images then they don’t want line 8483 (library = json) .
And they arguably want to be installing and using local-sqlite since it’s far superior to the json library"

Please, don’t shoot the messenger. :smiley:

Apologies for the delay and many thanks investigating this.

Following their install guide on their github page :wink: I either missed it, or their documentation lacked to mention this.

if they want to use local-images then they don’t want line 8483 (library = json) .

I’ve removed this entry for DietPi v155.

Tested fine:

root@DietPi:~# mopidy local scan
INFO     Starting Mopidy 2.1.0
INFO     Loading config from builtin defaults
INFO     Loading config from /root/.config/mopidy/mopidy.conf
INFO     Loading config from command line options
INFO     Enabled extensions: mpd, http, stream, m3u, local-images, softwaremixer, file, musicbox_webclient, local
INFO     Disabled extensions: none
INFO     Found 22 files in media_dir.
INFO     No local library metadata cache found at /mnt/dietpi_userdata/mopidy/data/local/library.json.gz. Please run `mopidy local scan` to index your local music library. If you do not have a local music collection, you can disable the local backend to hide this message.
INFO     Checking 0 tracks from library.
INFO     Removing 0 missing tracks.
INFO     Found 22 tracks which need to be updated.
INFO     Scanning...
WARNING  Failed local:track:Absolute-Radio-00s.pls: gst-stream-error-quark: Could not determine type of stream. (4)
WARNING  Failed local:track:Absolute-Radio-80s.pls: gst-stream-error-quark: Could not determine type of stream. (4)
WARNING  Failed local:track:Absolute-Radio-90s.pls: gst-stream-error-quark: Could not determine type of stream. (4)
WARNING  Failed local:track:Absolute-Radio.pls: gst-stream-error-quark: This appears to be a text file (5)
INFO     Scanned 22 of 22 files in 0s.
INFO     Cleaning up image directory
INFO     Done scanning.



Please, don’t shoot the messenger.

I’d give you a thumbs up, but our PHPBB forum is a little “vintage” with emote offerings, lol.

And they arguably want to be installing and using local-sqlite since it’s far superior to the json library"

And C++ is far more superior than Python (Mopidy) :wink: :wink:

No problem! Always glad to help!

No problem, again! :slight_smile:

Well, I know nothing at all of any of the two! :mrgreen:

Anyway, do I have to do anything on my mopidy installation now?
I mean, you said the issue has been solved now, but do I have to edit the file /usr/sbin/mopidyctl back to its original state or not?
Sorry this is not too clear. :slight_smile: