Repository: Cog-Creators/Red-DiscordBot

Issue:
[V3 Beta 2] Adding repo with non-default cog install location
```
[11/11/2017 19:58] ERROR events on_command_error 159: Exception in command 'repo add'
Traceback (most recent call last):
  File "c:\program files\python36\lib\site-packages\discord\ext\commands\core.py", line 62, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Program Files\Python36\Lib\site-packages\redbot\cogs\downloader\downloader.py", line 212, in _repo_add
    branch=branch
  File "C:\Program Files\Python36\Lib\site-packages\redbot\cogs\downloader\repo_manager.py", line 541, in add_repo
    await self._save_repos()
  File "C:\Program Files\Python36\Lib\site-packages\redbot\cogs\downloader\repo_manager.py", line 628, in _save_repos
    repo_json_info = {name: r.to_json() for name, r in self._repos.items()}
  File "C:\Program Files\Python36\Lib\site-packages\redbot\cogs\downloader\repo_manager.py", line 628, in <dictcomp>
    repo_json_info = {name: r.to_json() for name, r in self._repos.items()}
  File "C:\Program Files\Python36\Lib\site-packages\redbot\cogs\downloader\repo_manager.py", line 475, in to_json
    "folder_path": self.folder_path.relative_to(Path.cwd()).parts,
  File "c:\program files\python36\lib\pathlib.py", line 870, in relative_to
    .format(str(self), str(formatted)))
ValueError: 'E:\\github\\Testbot\\cogs\\RepoManager\\repos\\trusty' does not start with 'C:\\Users\\Trusty'
```

### Steps to reproduce
- Fresh install of Red V3
- Set cog path to something other than default on bot setup
- add repo with `[p]repo add name repo-link branch`

Error happens on Windows 10 with Python 3.6.2 Redbot Beta 2. 



Discussion:
This issue actually stems from having the data location on an entirely different root path than the cwd. I'm planning on fixing this asap.

Resolving patch:
diff --git a/redbot/cogs/downloader/installable.py b/redbot/cogs/downloader/installable.py
--- a/redbot/cogs/downloader/installable.py
+++ b/redbot/cogs/downloader/installable.py
@@ -5,6 +5,7 @@
 from pathlib import Path
 from typing import Union, MutableMapping, Any
 
+from redbot.core import data_manager
 from .log import log
 from .json_mixins import RepoJSONMixin
 
@@ -191,11 +192,13 @@ def _process_info_file(self, info_file_path: Path=None) -> MutableMapping[str, A
         return info
 
     def to_json(self):
+        data_path = data_manager.cog_data_path()
         return {
-            "location": self._location.relative_to(Path.cwd()).parts
+            "location": self._location.relative_to(data_path).parts
         }
 
     @classmethod
     def from_json(cls, data: dict):
-        location = Path.cwd() / Path(*data["location"])
+        data_path = data_manager.cog_data_path()
+        location = data_path / Path(*data["location"])
         return cls(location=location)
diff --git a/redbot/cogs/downloader/repo_manager.py b/redbot/cogs/downloader/repo_manager.py
--- a/redbot/cogs/downloader/repo_manager.py
+++ b/redbot/cogs/downloader/repo_manager.py
@@ -468,19 +468,21 @@ def available_libraries(self) -> Tuple[Installable]:
         )
 
     def to_json(self):
+        data_path = data_manager.cog_data_path()
         return {
             "url": self.url,
             "name": self.name,
             "branch": self.branch,
-            "folder_path": self.folder_path.relative_to(Path.cwd()).parts,
+            "folder_path": self.folder_path.relative_to(data_path).parts,
             "available_modules": [m.to_json() for m in self.available_modules]
         }
 
     @classmethod
     def from_json(cls, data):
+        data_path = data_manager.cog_data_path()
         # noinspection PyTypeChecker
         return Repo(data['name'], data['url'], data['branch'],
-                    Path.cwd() / Path(*data['folder_path']),
+                    data_path / Path(*data['folder_path']),
                     tuple([Installable.from_json(m) for m in data['available_modules']]))
 
 


Test patch: