Repository: ipython/ipython

Issue:
OSError when moving configuration file
1. Why are you moving something that adheres to http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html elsewhere???? I want fewer things cluttering up my home directory, not more! Really. I am disappoint.
2. use shutil.move
3. my ~/.config/ is a symlink to a different filesystem than my ~/

```
    __05:54:43 fdata $ ipython
    /media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/utils/path.py:302: UserWarning: Moving ~/.config/ipython to ~/.ipython
      warnings.warn('Moving {0} to {1}'.format(cu(xdg_ipdir), cu(ipdir)))
    Traceback (most recent call last):
      File "/home/hashem/pyve/bin/ipython", line 11, in <module>
        sys.exit(start_ipython())
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython
        return launch_new_instance(argv=argv, **kwargs)
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/config/application.py", line 563, in launch_instance
        app.initialize(argv)
      File "<string>", line 2, in initialize
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
        return method(app, *args, **kwargs)
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 321, in initialize
        super(TerminalIPythonApp, self).initialize(argv)
      File "<string>", line 2, in initialize
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
        return method(app, *args, **kwargs)
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/core/application.py", line 387, in initialize
        self.init_profile_dir()
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/core/application.py", line 295, in init_profile_dir
        p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/utils/traitlets.py", line 342, in __get__
        value = method()
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/core/application.py", line 140, in _ipython_dir_default
        d = get_ipython_dir()
      File "/media/hashem/fdata/fdata/pyve/local/lib/python2.7/site-packages/IPython/utils/path.py", line 303, in get_ipython_dir
        os.rename(xdg_ipdir, ipdir)
    OSError: [Errno 18] Invalid cross-device link

    If you suspect this is an IPython bug, please report it at:
        https://github.com/ipython/ipython/issues
    or send an email to the mailing list at ipython-dev@scipy.org

    You can print a more detailed traceback right now with "%tb", or use "%debug"
    to interactively debug it.

    Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
        c.Application.verbose_crash=True
```



Discussion:
1. No it does not adhere to it, as it stores cached files and other stuff that do not comply to the standard. 

The rational was that the logic to store the IPython config was alway wrong somewhere, and too complicated, so we removed the platform specific logic. Then packager are responsible to make it coherent with their platform to be XDG compliant or not.

2 . I suspect shutils.move was not use because of windows problem, but we can check.

Pull request welcome, though I'm not sure how to test it.

Cf #4457 for background.

On 24 May 2014 06:34, "Matthias Bussonnier" notifications@github.com wrote

> The rational was that the logic to store the IPython config was alway
> wrong somewhere, and too complicated, so we removed the platform specific
> logic. Then packager are responsible to make it coherent with their
> platform to be XDG compliant or not.

We don't encourage packagers to change it, though, because then users
wouldn't find their files where the docs say to look.

We switched back to ~/.ipython to make it simple to explain where those
files are for all platforms. Also, as Matthias said, we were never really
following the xdg spec properly anyway, because we mix config files and
application data.


Resolving patch:
diff --git a/IPython/utils/path.py b/IPython/utils/path.py
--- a/IPython/utils/path.py
+++ b/IPython/utils/path.py
@@ -292,7 +292,7 @@ def get_ipython_dir():
                     'to get rid of this message').format(cu(xdg_ipdir), cu(ipdir)))
                 else:
                     warnings.warn('Moving {0} to {1}'.format(cu(xdg_ipdir), cu(ipdir)))
-                    os.rename(xdg_ipdir, ipdir)
+                    shutil.move(xdg_ipdir, ipdir)
 
     ipdir = os.path.normpath(os.path.expanduser(ipdir))
 


Test patch: