# Inconsistency in relative path handling in the config

**URL:** https://discourse.beets.io/t/inconsistency-in-relative-path-handling-in-the-config/791
**Category:** Help
**Created:** [June 5, 2019, 3:27pm UTC](https://discourse.beets.io/t/inconsistency-in-relative-path-handling-in-the-config/791 "2019-06-05T15:27:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![kergoth](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/kergoth/32/240_2.png) [@kergoth](https://discourse.beets.io/u/kergoth)
#### Post date: [June 5, 2019, 3:27pm UTC](https://discourse.beets.io/t/inconsistency-in-relative-path-handling-in-the-config/791/1 "2019-06-05T15:27:50Z")

</div>

I’ve noticed that handling of relative paths in config.yaml is inconsistent, which makes it difficult to have a self contained library and beets configuration. It’d be nice if either this was consistent, or if we could use some form of templating scheme, i.e. string.format or string.Template, to access the most common paths. It could be worthwhile to provide a new type when plugins interact with the config to handle this transparently for their options as well, giving them an absolute path.

From what I’ve seen (where BEETSDIR is the path where config.yaml lives):

- directory: relative to `BEETSDIR`
- library: relative to `BEETSDIR`
- pluginpath: relative to `PWD`
- importfeeds: m3u: relative to `directory`
- importfeeds: m3u\_multi: relative to `BEETSDIR`
- alternatives: relative to `directory`

Any thoughts on the cleanest way to address this? I was going to start working on a pull request, but would like to determine the correct approach.

-kergoth

---

<div class="post-metadata">

### Author: ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)
#### Post date: [June 5, 2019, 6:38pm UTC](https://discourse.beets.io/t/inconsistency-in-relative-path-handling-in-the-config/791/2 "2019-06-05T18:38:07Z")

</div>

Good catches! For what it’s worth, Confuse (our configuration library) provides built-in functionality that defaults to "relative to `BEETSDIR`". That’s the `as_filename` method—like [this](https://github.com/beetbox/beets/blob/3161e2722670884884adcdaddd25591e3bef3dc4/beets/ui/ __init__.py#L1197), for example.

Other config options that use `as_str` or just plain `get` should probably be changed to use `as_filename`.

---

<div class="post-metadata">

### Author: ![kergoth](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/kergoth/32/240_2.png) [@kergoth](https://discourse.beets.io/u/kergoth)
#### Post date: [June 5, 2019, 6:40pm UTC](https://discourse.beets.io/t/inconsistency-in-relative-path-handling-in-the-config/791/4 "2019-06-05T18:40:33Z")

</div>

Ah, great, thanks. That’s simple enough. pluginpath currently uses as\_str\_seq(), guessing we can just do [p.as\_filename() for p in config[‘pluginpath’]] or so, instead?

---

<div class="post-metadata">

### Author: ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)
#### Post date: [June 6, 2019, 2:43am UTC](https://discourse.beets.io/t/inconsistency-in-relative-path-handling-in-the-config/791/5 "2019-06-06T02:43:59Z")

</div>

Well, that one might be a bit more complicated. The `as_str_seq` thing is a bit more powerful—it can take a single string and split it on whitespace. Maybe we should leave that one alone for a little bit while we take a look at the others, which are hopefully easier?

---

<div class="post-metadata">

### Author: ![tianon](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/tianon/32/579_2.png) [@tianon](https://discourse.beets.io/u/tianon)
#### Post date: [October 24, 2021, 2:57am UTC](https://discourse.beets.io/t/inconsistency-in-relative-path-handling-in-the-config/791/6 "2021-10-24T02:57:47Z")

</div>

I found this topic specifically because of `pluginpath` 😅

I created the following (really hacky) patch which makes it “work” although it’s real bad and as far as I can tell should really be implemented as a new `Template` type in Confuse (something that combines `StrSeq` with `Filename`)?

(I was going to try my hand at creating such a thing, but very, very quickly got way out of my depth. 😇)

```diff
diff --git a/beets/ui/ __init__.py b/beets/ui/ __init__.py
index 8d980d54..0ebe9f68 100644
--- a/beets/ui/ __init__.py
+++ b/beets/ui/ __init__.py
@@ -1114,6 +1116,7 @@ def _load_plugins(options, config):
     """Load the plugins specified on the command line or in the configuration.
     """
     paths = config['pluginpath'].as_str_seq(split=False)
+ paths = [confuse.Filename(default=p).value(config['lolnopeleethax']) for p in paths]
     paths = [util.normpath(p) for p in paths]
     log.debug(u'plugin paths: {0}', util.displayable_path(paths))
 

```

**Edit:** scratch that, this patch doesn’t even work 😂 😇
