Repository: xonsh/xonsh

Issue:
Creation of anomalous folders when setting `$XDG_DATA_DIR` and `$XONSH_DATA_DIR` in config.json
In the `config.json` file, I had the following items:

``` json
"XDG_DATA_HOME": "~/.local/share",
"XONSH_DATA_DIR": "~/.local/share/xonsh",
```

I found that whenever a new terminal was created, it would create a folder `~` in whatever the initial open folder is. So, there will end up being `~` folders everywhere if I open up `tmux` or start new terminals. This doesn't really affect me because I do not need to set these items, which are just defaults, but it may be good to have proper way to reference `$HOME` from the config files.



Discussion:
Hey @derekbrokeit, thanks for reporting!  I can't reproduce this.  Could you post the output of `xonfig`?  Thanks!

I think the problem is more peculiar that I originally thought. The folder tree is actually fairly complicated, but it may help point to the source of the problem. 

```
~
└── .local
    └── share
        └── xonsh
            └── xonsh_script_cache
                └── _users
                    └── derek
                        └── _.xonshrc.cpython-35
```

My xonfig is as follows:

```
+------------------+-----------------+
| xonsh            | 0.4.6.dev282    |
| Git SHA          | ad557bb         |
| Python           | 3.5.1           |
| PLY              | 3.7             |
| have readline    | True            |
| prompt toolkit   | 1.0.7           |
| shell type       | prompt_toolkit  |
| pygments         | 2.1.1           |
| on posix         | True            |
| on linux         | False           |
| on darwin        | True            |
| on windows       | False           |
| on cygwin        | False           |
| is superuser     | False           |
| default encoding | utf-8           |y 
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
+------------------+-----------------+
```

A more peculiar outcome is also that replacing the '~' in those fields with the absolute path actually seems to force `xonsh` to startup without a `.xonshrc` file at all.

``` json
# the following causes xonsh to not use my .xonshrc file
"XDG_DATA_HOME": "/Users/myusername/.local/share",
"XONSH_DATA_DIR": "/Users/myusername/.local/share/xonsh",
```

If I find more information for you, I will document it here. 

@derekbrokeit -- that is really weird.  I still can't reproduce this so it might be an OSX thing?  But that's very odd.  

If you use the absolute paths, what's the value of `$XONSHRC` after startup?

I tried both options and the value of `$XONSHRC` Was the default built in value from xonsh for both cases. 


Resolving patch:
diff --git a/xonsh/environ.py b/xonsh/environ.py
--- a/xonsh/environ.py
+++ b/xonsh/environ.py
@@ -184,7 +184,7 @@ def is_callable_default(x):
 @default_value
 def xonsh_data_dir(env):
     """Ensures and returns the $XONSH_DATA_DIR"""
-    xdd = os.path.join(env.get('XDG_DATA_HOME'), 'xonsh')
+    xdd = os.path.expanduser(os.path.join(env.get('XDG_DATA_HOME'), 'xonsh'))
     os.makedirs(xdd, exist_ok=True)
     return xdd
 
@@ -192,7 +192,7 @@ def xonsh_data_dir(env):
 @default_value
 def xonsh_config_dir(env):
     """Ensures and returns the $XONSH_CONFIG_DIR"""
-    xcd = os.path.join(env.get('XDG_CONFIG_HOME'), 'xonsh')
+    xcd = os.path.expanduser(os.path.join(env.get('XDG_CONFIG_HOME'), 'xonsh'))
     os.makedirs(xcd, exist_ok=True)
     return xcd
 


Test patch: