Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

OSError: Invalid cross-device link #176

Open
frague59 opened this issue Nov 12, 2018 · 0 comments
Open

OSError: Invalid cross-device link #176

frague59 opened this issue Nov 12, 2018 · 0 comments

Comments

@frague59
Copy link

Hi,

I'm using coreapi / coreapi-cli on a debian machine, and I'm having the following error on getting a schema:

$ coreapi get http://localhost:8001/
Traceback (most recent call last):
  File "/home/<user>/<project_root>/virtualenv/bin/coreapi", line 11, in <module>
    sys.exit(client())
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi_cli/main.py", line 147, in get
    doc = client.get(url, force_codec=force_codec)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/client.py", line 136, in get
    return transport.transition(link, decoders, force_codec=force_codec)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/transports/http.py", line 380, in transition
    result = _decode_result(response, decoders, force_codec)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/transports/http.py", line 294, in _decode_result
    result = codec.load(response.content, **options)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/codecs/base.py", line 24, in load
    return self.decode(*args, **kwargs)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/codecs/download.py", line 143, in decode
    os.rename(temp_path, output_path)
OSError: [Errno 18] Invalid cross-device link: '/tmp/tmpjthickut.download' -> '/home/<user>/.coreapi/downloads/api-schema'

The problem is that you use os.rename(<src>, <dest>) , which performs a "link" copy.
The resolution is easy: you just have to replace the:

    os.rename(temp_path, output_path)

by:

    shutil.move(temp_path, output_path)

shutil is in the python standart library, so you have just to adds the import.

Thanks for this great tool !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant