I’ve been running mopidy as a service on my Raspberry Pi, and decided I’d try to set up the
local extension. Unfortunately, it doesn’t seem to be reading anything I put into the
media_dir parameter. This is from my
enabled = true
library = json
media_dir = "/home/pi/Music"
scan_timeout = 1000
scan_flush_threshold = 100
scan_follow_symlinks = false
When I restart the service, it gives me a warning that
media_dir must be set, and disables the
local extension. Am I doing something wrong, or is there a bug with the config? I added in the quotes after it didn’t work with the raw path, but they didn’t seem to make a difference. /home/pi/Music is a real folder, readable by all users, with a few mp3 files in it.
Can you use
sudo mopidyctl config to make sure the config is what you expect. Quotes are not necessary. What are the full permissions on /home/pi/Music i.e. the output of
ls -la /home/pi/Music ?
The issue actually seemed to be caused by the quotes, and possibly also by a comment (I had commented out the default
media_dir). Removing quotes and comment and just presenting the path fixed it. I think my main complaint now would be that the error messages ought to have been more helpful, telling me that I had an invalid format/that there was a parsing error instead of complaining that I hadn’t provided one.
sudo mopidyctl config indicated that nothing had been provided for
media_dir. In parsing my config, it seems to have discarded what it considered invalid (anything having quotes/comments)
The music directory in question was readable to all users.
For the record, I was also interested in ensuring /home/pi had +x permission. Which I guess it does.
If you could give an example of a comment that caused an issue that would be helpful. We do not support inline comments.
Yep, it has +x. Here is what I believe the comment was:
media_dir = /home/pi/Music #$XDG_MUSIC_DIR
I don’t recall exactly, but I’m pretty sure I tried removing quotes first (made no difference) then nuked the comment and it worked. So I suspect it was the comment causing this issue.
Yes, you can’t (generally) comment INI files like you tried to do. If you want an inline comment like that you need to use the ‘;’ separator. For example:
Some=value ; my comment on the same line
; or my comment on a new file
# comments like this must be on a new line
Strictly speaking # doesn’t actually define a comment, it’s more of a hack. But since it’s a comment character in other languages and basically resolves to being a comment anyway, it gets used as such. Which is a little confusing if you ask me.
Gotcha, yeah, definitely user error there on my part. Would it be possible to say something indicating an invalid line/value in the INI file (as opposed to just silently discarding it)?
In cases where it matters (config setting is required) then you will usually get a warning/error as it is. We also try to stress that people should use the
mopidy config and
sudo mopidyctl config commands rather than dumping the .conf files (which they often then edit and remove significant info).
But if someone wanted to work on improving the parsing we’d certainly be interested in a PR.
Cool. Okay, if I have some time I’ll see about getting together a PR to improve parsing. Thanks for clarifying this issue for me.