# \`local/media\_dir\` not loading from config

**URL:** <https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004>\
**Category:** Misc\
**Created:** [January 8, 2019, 8:52pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004 "2019-01-08T20:52:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![boz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/boz/32/1057_2.png) [@boz](https://discourse.mopidy.com/u/boz)\
**Post date:** [January 8, 2019, 8:52pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/1 "2019-01-08T20:52:06Z")

</div>

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 `/etc/mopidy/mopidy.conf` :

```auto
[local]
enabled = true
library = json
media_dir = "/home/pi/Music"
scan_timeout = 1000
scan_flush_threshold = 100
scan_follow_symlinks = false
excluded_file_extensions = 
  .directory
  .html
  .jpeg
  .jpg
  .log
  .nfo
  .png
  .txt

```

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.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [January 8, 2019, 10:58pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/2 "2019-01-08T22:58:41Z")

</div>

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` ?

---

<div class="post-metadata">

**Author:** ![boz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/boz/32/1057_2.png) [@boz](https://discourse.mopidy.com/u/boz)\
**Post date:** [January 9, 2019, 5:55pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/3 "2019-01-09T17:55:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![boz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/boz/32/1057_2.png) [@boz](https://discourse.mopidy.com/u/boz)\
**Post date:** [January 9, 2019, 5:56pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/4 "2019-01-09T17:56:32Z")

</div>

`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)

---

<div class="post-metadata">

**Author:** ![boz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/boz/32/1057_2.png) [@boz](https://discourse.mopidy.com/u/boz)\
**Post date:** [January 9, 2019, 5:57pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/5 "2019-01-09T17:57:03Z")

</div>

The music directory in question was readable to all users.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [January 9, 2019, 6:24pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/6 "2019-01-09T18:24:23Z")

</div>

For the record, I was also interested in ensuring /home/pi had +x permission. Which I guess it does.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [January 9, 2019, 6:25pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/7 "2019-01-09T18:25:45Z")

</div>

If you could give an example of a comment that caused an issue that would be helpful. We do not support inline comments.

---

<div class="post-metadata">

**Author:** ![boz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/boz/32/1057_2.png) [@boz](https://discourse.mopidy.com/u/boz)\
**Post date:** [January 9, 2019, 6:54pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/8 "2019-01-09T18:54:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [January 9, 2019, 7:26pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/9 "2019-01-09T19:26:03Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![boz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/boz/32/1057_2.png) [@boz](https://discourse.mopidy.com/u/boz)\
**Post date:** [January 9, 2019, 7:51pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/10 "2019-01-09T19:51:05Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [January 9, 2019, 11:11pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/11 "2019-01-09T23:11:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![boz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/boz/32/1057_2.png) [@boz](https://discourse.mopidy.com/u/boz)\
**Post date:** [January 10, 2019, 2:29pm UTC](https://discourse.mopidy.com/t/local-media-dir-not-loading-from-config/3004/12 "2019-01-10T14:29:06Z")

</div>

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.
