creswick / cabal-dev

A wrapper program around cabal and cabal-install that maintains sandboxed build environments.
BSD 3-Clause "New" or "Revised" License
150 stars 24 forks source link

add-source fails due to invalid cross-device link #51

Open basvandijk opened 12 years ago

basvandijk commented 12 years ago

Hello,

I've a cabal-dev project on a filesystem on an encrypted partition. Now I want to cabal-dev add-source a project from a filesystem on my unencrypted partition. However I get the following error:

unsupported operation (Invalid cross-device link)

I guess cabal-dev tries to make a hard-link from my encrypted partition to my unencrypted partition which is invalid.

Is it possible to create symbolic links instead?

creswick commented 12 years ago

I'm fairly certain cabal-dev doesn't create links (symlinks or hardlinks); doing so on all the supported platforms would be a real bear -- so I'm not sure where the invalid cross-device link is being generated.

Some questions to help narrow it down:

basvandijk commented 12 years ago

Does the project you're add-sourc'ing properly cabal sdist?

Yes it does:

$ cd ~/downloads/Crypto-4.2.4/
$ cabal sdist
Building source dist for Crypto-4.2.4...
Preprocessing library Crypto-4.2.4...
Preprocessing executable 'WordListTest' for Crypto-4.2.4...
Preprocessing executable 'SymmetricTest' for Crypto-4.2.4...
Preprocessing executable 'SHA1Test' for Crypto-4.2.4...
Preprocessing executable 'RSATest' for Crypto-4.2.4...
Preprocessing executable 'QuickTest' for Crypto-4.2.4...
Preprocessing executable 'HMACTest' for Crypto-4.2.4...
Source tarball created: dist/Crypto-4.2.4.tar.gz

Can you run with --verbose=3 and see if there are details in there that may be helpful?

$ cabal-dev add-source ~/downloads/Crypto-4.2.4/ --verbose=3
...
Building source dist at /home/bas/downloads/Crypto-4.2.4/ for Crypto-4.2.4
Running cabal sdist in /home/bas/downloads/Crypto-4.2.4/
Building source dist for Crypto-4.2.4...
Preprocessing library Crypto-4.2.4...
Preprocessing executable 'WordListTest' for Crypto-4.2.4...
Preprocessing executable 'SymmetricTest' for Crypto-4.2.4...
Preprocessing executable 'SHA1Test' for Crypto-4.2.4...
Preprocessing executable 'RSATest' for Crypto-4.2.4...
Preprocessing executable 'QuickTest' for Crypto-4.2.4...
Preprocessing executable 'HMACTest' for Crypto-4.2.4...
Source tarball created: dist/Crypto-4.2.4.tar.gz
cabal-dev: /home/bas/downloads/Crypto-4.2.4/dist/Crypto-4.2.4.tar.gz: rename: unsupported operation (Invalid cross-device link)

Can you share the project that this is happening with?

No sorry it's proprietary.

creswick commented 12 years ago

Thanks for the details. The most likely workaround is to not use add-source, and instead, cabal-dev install to the sandbox you're working with.

eg:

$ cd /home/bas/downloads/Crypto-4.2.4/
$ cabal-dev install --sandbox=<other directory>

Unfortunately, I haven't been able to test this across devices.

On Thu, Feb 16, 2012 at 12:20 AM, Bas van Dijk reply@reply.github.com wrote:

cabal-dev: /home/bas/downloads/Crypto-4.2.4/dist/Crypto-4.2.4.tar.gz: rename: unsupported operation (Invalid cross-device link)

It /looks/ like this is due to the way System.Directory.renameFile works; from the haddocks:

" A conformant implementation need not support renaming files in all situations (e.g. renaming across different physical devices), but the constraints must be documented."

This issue doesn't seem to be clearly documented, but there is an error condition that probably corresponds to your situation:

Digging through the source, it does look like renameFile uses links in some cases (if not all, on Posix, anyway).

We'll probably have to use something other than renameFile to get around this, unfortunately. Thanks for pointing it out!