Repository: conda/conda

Issue:
Conda exits with: Invalid cross-device link 
While building a docker image with docker-1.2.6 on ubuntu-16.0.4 I error:
OSError(18, 'Invalid cross-device link')

Here is the debug output:

`An unexpected error has occurred.                   | Time: 0:00:00 803.99 kB/s
Please consider posting the following information to the
conda GitHub issue tracker at:

    https://github.com/conda/conda/issues



Current conda install:

               platform : linux-64
          conda version : 4.3.4
       conda is private : False
      conda-env version : 4.3.4
    conda-build version : not installed
         python version : 3.5.2.final.0
       requests version : 2.12.4
       root environment : /root/miniconda3  (writable)
    default environment : /root/miniconda3
       envs directories : /root/miniconda3/envs
          package cache : /root/miniconda3/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : None
           offline mode : False
             user-agent : conda/4.3.4 requests/2.12.4 CPython/3.5.2 Linux/4.4.0-59-generic debian/stretch/sid glibc/2.23
                UID:GID : 0:0



$ /root/miniconda3/bin/conda-env create -f=environment.yml --name carnd-term1 --debug -v -v




    Traceback (most recent call last):
      File "/root/miniconda3/lib/python3.5/site-packages/conda/exceptions.py", line 617, in conda_exception_handler
        return_value = func(*args, **kwargs)
      File "/root/miniconda3/lib/python3.5/site-packages/conda_env/cli/main_create.py", line 112, in execute
        installer.install(prefix, pkg_specs, args, env)
      File "/root/miniconda3/lib/python3.5/site-packages/conda_env/installers/conda.py", line 37, in install
        plan.execute_actions(actions, index, verbose=not args.quiet)
      File "/root/miniconda3/lib/python3.5/site-packages/conda/plan.py", line 837, in execute_actions
        execute_instructions(plan, index, verbose)
      File "/root/miniconda3/lib/python3.5/site-packages/conda/instructions.py", line 258, in execute_instructions
        cmd(state, arg)
      File "/root/miniconda3/lib/python3.5/site-packages/conda/instructions.py", line 111, in PROGRESSIVEFETCHEXTRACT_CMD
        progressive_fetch_extract.execute()
      File "/root/miniconda3/lib/python3.5/site-packages/conda/core/package_cache.py", line 467, in execute
        self._execute_action(action)
      File "/root/miniconda3/lib/python3.5/site-packages/conda/core/package_cache.py", line 489, in _execute_action
        raise CondaMultiError(exceptions)
    conda.CondaMultiError: OSError(18, 'Invalid cross-device link')
    OSError(18, 'Invalid cross-device link')
    OSError(18, 'Invalid cross-device link')
`
Conda exits with: Invalid cross-device link 
While building a docker image with docker-1.2.6 on ubuntu-16.0.4 I error:
OSError(18, 'Invalid cross-device link')

Here is the debug output:

`An unexpected error has occurred.                   | Time: 0:00:00 803.99 kB/s
Please consider posting the following information to the
conda GitHub issue tracker at:

    https://github.com/conda/conda/issues



Current conda install:

               platform : linux-64
          conda version : 4.3.4
       conda is private : False
      conda-env version : 4.3.4
    conda-build version : not installed
         python version : 3.5.2.final.0
       requests version : 2.12.4
       root environment : /root/miniconda3  (writable)
    default environment : /root/miniconda3
       envs directories : /root/miniconda3/envs
          package cache : /root/miniconda3/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : None
           offline mode : False
             user-agent : conda/4.3.4 requests/2.12.4 CPython/3.5.2 Linux/4.4.0-59-generic debian/stretch/sid glibc/2.23
                UID:GID : 0:0



$ /root/miniconda3/bin/conda-env create -f=environment.yml --name carnd-term1 --debug -v -v




    Traceback (most recent call last):
      File "/root/miniconda3/lib/python3.5/site-packages/conda/exceptions.py", line 617, in conda_exception_handler
        return_value = func(*args, **kwargs)
      File "/root/miniconda3/lib/python3.5/site-packages/conda_env/cli/main_create.py", line 112, in execute
        installer.install(prefix, pkg_specs, args, env)
      File "/root/miniconda3/lib/python3.5/site-packages/conda_env/installers/conda.py", line 37, in install
        plan.execute_actions(actions, index, verbose=not args.quiet)
      File "/root/miniconda3/lib/python3.5/site-packages/conda/plan.py", line 837, in execute_actions
        execute_instructions(plan, index, verbose)
      File "/root/miniconda3/lib/python3.5/site-packages/conda/instructions.py", line 258, in execute_instructions
        cmd(state, arg)
      File "/root/miniconda3/lib/python3.5/site-packages/conda/instructions.py", line 111, in PROGRESSIVEFETCHEXTRACT_CMD
        progressive_fetch_extract.execute()
      File "/root/miniconda3/lib/python3.5/site-packages/conda/core/package_cache.py", line 467, in execute
        self._execute_action(action)
      File "/root/miniconda3/lib/python3.5/site-packages/conda/core/package_cache.py", line 489, in _execute_action
        raise CondaMultiError(exceptions)
    conda.CondaMultiError: OSError(18, 'Invalid cross-device link')
    OSError(18, 'Invalid cross-device link')
    OSError(18, 'Invalid cross-device link')
`


Discussion:
Thanks for the report.  I'm not sure this is a new problem in 4.3, but it might be.  Without more debug output (and I'm not sure conda-env can even give more), my guess is that conda is trying to hard-link across two different devices.

Changing your command to 

    CONDA_ALWAYS_COPY=true /root/miniconda3/bin/conda-env create -f=environment.yml --name carnd-term1 --debug -v -v

should fix your immediate problem.  It's possible that conda 4.2 did this better.  Can you confirm that this is something new in conda 4.3?
Hi,

I just got the same error on OSX El Capitan. Reverting to 4.2.12 fixes it.

/Rasmus
Oops, sorry I forgot that I was working in a Docker container. Debian 8, not OSX :)
@rasmusagren Does setting the `CONDA_ALWAYS_COPY=true` environment variable help at all?
I will test the workaround tonight. Here is the fragment of my dicker script. It was working last week:
ADD https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh tmp/Miniconda3-latest-Linux-x86_64.sh
RUN bash tmp/Miniconda3-latest-Linux-x86_64.sh -b
ENV PATH $PATH:/root/miniconda3/bin/

COPY environment.yml  .
RUN conda install --yes pyyaml
RUN conda env create -f=environment.yml --name carnd-term1

I am not sure which of the dependencies changed lately.
If either of you can reproduce your error without using a `conda env` command (probably just `conda create` or `conda install`), it would be a huge help to add `-vvv` and share the output.  It'll be extremely verbose, but it will help me pinpoint what's going on.
CONDA_ALWAYS_COPY=true didn't help in my case, but going back to 4.2.12 (debian jessie in Docker 1.12), too (like for rasmusagren)
Actually, if you're using a conda-env command that's fine. Just set an environment variable `CONDA_VERBOSE=3`, and then remove the other `--debug` and `-v` flags. 
@troussan Could you change the line 

    RUN conda env create -f=environment.yml --name carnd-term1

in your docker file to

    RUN CONDA_VERBOSE=3 conda env create -f=environment.yml --name carnd-term1

and then give me the full output?
@kalefranz This produced exactly the same output as the one posted above.

Downgrading to 4.2.13 resolves the issue.
I'm seeing the same error all of a sudden. Docker version 1.12.3, have tried with Miniconda2-4.2.12-Linux-x86_64.sh and Miniconda2-latest-Linux-x86_64.sh , so at least what I'm seeing isn't a 4.3 issue. Error occurs if I run my docker build from the Dockerfile, but if I use an interactive session & run the install commands one by one it works fine.
This is on my list of bugs to quash today.  I need to set up a docker environment on my machine first though.  There's not yet enough information in this ticket for me to understand that root cause.
I had the problem inside a Dockerfile build yesterday and had this error. However, I came past it when downgrading to 4.2.12, also during the Dockerfile built. I think you have to be very careful that conda doesn't manage to upgrade to 4.3 again.
Oh nice catch! I had a `conda update conda` in there I'd forgotten about :) 
I just came across this github issue while trying to debug a problem that started recently with a complicated docker build process. I've got as far boiling my problem down to the following (not yet minimal) example:

```
$ cat Dockerfile
FROM continuumio/anaconda3:4.2.0
RUN conda install -y pandas
RUN conda install -y -c conda-forge jupyter_contrib_nbextensions

$ docker build . --no-cache
Sending build context to Docker daemon 568.3 kB
Step 1 : FROM continuumio/anaconda3:4.2.0
 ---> f44b5cac90c5
Step 2 : RUN conda install -y pandas
 ---> Running in a129a8f484c5
Fetching package metadata .......
Solving package specifications: ..........

Package plan for installation in environment /opt/conda:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-env-2.6.0            |                0          502 B
    requests-2.12.4            |           py35_0         800 KB
    pandas-0.19.2              |      np111py35_1        16.7 MB
    pyopenssl-16.2.0           |           py35_0          70 KB
    conda-4.3.4                |           py35_0         487 KB
    ------------------------------------------------------------
                                           Total:        18.1 MB

The following NEW packages will be INSTALLED:

    conda-env: 2.6.0-0

The following packages will be UPDATED:

    conda:     4.2.9-py35_0       --> 4.3.4-py35_0
    pandas:    0.18.1-np111py35_0 --> 0.19.2-np111py35_1
    pyopenssl: 16.0.0-py35_0      --> 16.2.0-py35_0
    requests:  2.11.1-py35_0      --> 2.12.4-py35_0

Fetching packages ...
conda-env-2.6. 100% |###############################| Time: 0:00:00 377.34 kB/s
requests-2.12. 100% |###############################| Time: 0:00:00   1.79 MB/s
pandas-0.19.2- 100% |###############################| Time: 0:00:04   4.18 MB/s
pyopenssl-16.2 100% |###############################| Time: 0:00:00 951.86 kB/s
conda-4.3.4-py 100% |###############################| Time: 0:00:00   2.17 MB/s
Extracting packages ...
[      COMPLETE      ]|##################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################| 100%
 ---> c82a1ab1c82e
Removing intermediate container a129a8f484c5
Step 3 : RUN conda install -y -c conda-forge jupyter_contrib_nbextensions
 ---> Running in f2d59f035524
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /opt/conda:

The following NEW packages will be INSTALLED:

    jupyter_contrib_core:              0.3.0-py35_1 conda-forge
    jupyter_contrib_nbextensions:      0.2.3-py35_0 conda-forge
    jupyter_highlight_selected_word:   0.0.7-py35_0 conda-forge
    jupyter_latex_envs:                1.3.6-py35_0 conda-forge
    jupyter_nbextensions_configurator: 0.2.3-py35_0 conda-forge

The following packages will be SUPERCEDED by a higher-priority channel:

    conda:                             4.3.4-py35_0             --> 4.2.13-py35_0 conda-forge
    conda-env:                         2.6.0-0                  --> 2.6.0-0       conda-forge

conda-env-2.6. 100% |###############################| Time: 0:00:00 840.02 kB/s
conda-4.2.13-p 100% |###############################| Time: 0:00:00 612.71 kB/s
jupyter_contri 100% |###############################| Time: 0:00:00   1.10 MB/s
jupyter_highli 100% |###############################| Time: 0:00:00   1.05 MB/s
jupyter_latex_ 100% |###############################| Time: 0:00:00   1.43 MB/s
jupyter_nbexte 100% |###############################| Time: 0:00:00   2.10 MB/s
jupyter_contri  88% |###########################    | Time: 0:00:02   5.38 MB/s

CondaError: OSError(18, 'Invalid cross-device link')

CondaError: OSError(18, 'Invalid cross-device link')

CondaError: OSError(18, 'Invalid cross-device link')



jupyter_contri 100% |###############################| Time: 0:00:02   5.82 MB/s
The command '/bin/sh -c conda install -y -c conda-forge jupyter_contrib_nbextensions' returned a non-zero code: 1
```

I've attached a longer version with verbose output from conda: [verbose.txt](https://github.com/conda/conda/files/712290/verbose.txt)

I'm still investigating but wanted to post now because it sounds like @kalefranz might be trying to reproduce the problem at the moment, and maybe this example helps.

[EDIT: I cut down the example slightly]
To work around this problem for now, I have ``RUN conda config --set auto_update_conda False`` in my Dockerfile before installing any other packages.
This did not work for me.
Not sure what changed, but all builds with anaconda fail from today with this error. Tried the auto_update_conda work around, the always copy work around, and forced conda to the latest known good version (4.3.4). But everything still fails. After reverting to conda 4.2.x it works again. (Not sure where the passed builds with conda 4.3.4 came from).
I'm also hitting this in both Ubuntu and Alpine based Docker containers, and have got a combination of the above to work.

@pvanderlinden `conda config --set auto_update_conda False` might not exist in your version of miniconda or whatever you are using to install conda- I got this workaround to work by using Miniconda 3.9.1 to install conda version 4.2.13 and then set no update (otherwise any further installs in the root conda env will try and update conda too).

```RUN cd /tmp && \
    mkdir -p $CONDA_DIR && \
    wget --quiet https://repo.continuum.io/miniconda/Miniconda3-3.9.1-Linux-x86_64.sh && \
    echo "6c6b44acdd0bc4229377ee10d52c8ac6160c336d9cdd669db7371aa9344e1ac3 *Miniconda3-3.9.1-Linux-x86_64.sh" | sha256sum -c - && \
    /bin/bash Miniconda3-3.9.1-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
    rm Miniconda3-3.9.1-Linux-x86_64.sh && \
    $CONDA_DIR/bin/conda install --yes conda=4.2.13 && \
    conda config --set auto_update_conda False```

Just adding that I'm encountering the same issue on building a simple debian docker container.
Dockerfile and terminal output attached.
[dockerfile.txt](https://github.com/conda/conda/files/718699/dockerfile.txt)


>  >>>

>docker build -t webportal .
Sending build context to Docker daemon 688.6 kB
Step 1 : FROM debian@sha256:32a225e412babcd54c0ea777846183c61003d125278882873fb2bc97f9057c51
 ---> bb5d89f9b6cb
Step 2 : MAINTAINER Joshua Barber "j.barber501@gmail.com"
 ---> Using cache
 ---> d7e4ed8df082
Step 3 : USER root
 ---> Using cache
 ---> 44c581a995a0
Step 4 : RUN apt-get update  &&         apt-get install -y python3-pip python-dev build-essential wget &
&       rm /bin/sh && ln -s /bin/bash /bin/sh
 ---> Using cache
 ---> d543e8b94bad
Step 5 : ENV APP_ACTIVATE "python ./dashboard.py"
 ---> Using cache
 ---> 6a2d47160dd3
Step 6 : ENV ENV_NAME "app-env"
 ---> Using cache
 ---> ae7475dfad71
Step 7 : ENV CONDA_DIR /opt/conda
 ---> Using cache
 ---> 595847dba965
Step 8 : ENV STARTSCRIPT /code/start.sh
 ---> Using cache
 ---> 90e5e94733fb
Step 9 : ENV PATH /$CONDA_DIR/bin:${PATH}
 ---> Using cache
 ---> b54f6a1666be
Step 10 : RUN cd /tmp &&        mkdir -p $CONDA_DIR &&  wget --quiet http://repo.continuum.io/miniconda/
Miniconda3-latest-Linux-x86_64.sh &&    /bin/bash Miniconda3-latest-Linux-x86_64.sh -f -b -p $CONDA_DIR
&&      rm Miniconda3-latest-Linux-x86_64.sh &&         conda update -y conda &&        conda clean -tip
sy
 ---> Using cache
 ---> 4f7b9d129bee
Step 11 : COPY . /code
 ---> b3a42b33dbb6
Removing intermediate container 2719dc0dd065
Step 12 : WORKDIR /code
 ---> Running in 25fec38bd680
 ---> 76c82c34fadf
Removing intermediate container 25fec38bd680
Step 13 : RUN conda env create -f environment.yml -n $ENV_NAME
 ---> Running in d94ecbe505f0
Fetching package metadata .........
Solving package specifications: .
libpq-9.5.4-0. 100% |###############################| Time: 0:00:01  65.94 kB/s
openssl-1.0.2j 100% |###############################| Time: 0:00:30 108.16 kB/s
readline-6.2-2 100% |###############################| Time: 0:00:02 209.19 kB/s
sqlite-3.13.0- 100% |###############################| Time: 0:00:18 225.25 kB/s
tk-8.5.18-0.ta 100% |###############################| Time: 0:00:12 152.99 kB/s
xz-5.2.2-1.tar 100% |###############################| Time: 0:00:07  94.97 kB/s
zlib-1.2.8-3.t 100% |###############################| Time: 0:00:01  52.40 kB/s
python-3.5.2-0 100% |###############################| Time: 0:01:03 284.78 kB/s
click-6.7-py35 100% |###############################| Time: 0:00:01  74.13 kB/s
itsdangerous-0 100% |###############################| Time: 0:00:00 250.31 kB/s
markupsafe-0.2 100% |###############################| Time: 0:00:00  53.70 kB/s
psycopg2-2.6.2 100% |###############################| Time: 0:00:01 223.49 kB/s
setuptools-27. 100% |###############################| Time: 0:01:16   7.05 kB/s
sqlalchemy-1.0 100% |###############################| Time: 0:00:02 544.09 kB/s
werkzeug-0.11. 100% |###############################| Time: 0:00:00 528.79 kB/s
wheel-0.29.0-p 100% |###############################| Time: 0:00:00 789.20 kB/s
jinja2-2.9.4-p 100% |###############################| Time: 0:00:00 681.72 kB/s
pip-9.0.1-py35  33% |##########                     | Time: 0:00:01 338.21 kB/s

> CondaError: OSError(18, 'Invalid cross-device link')
> 
> CondaError: OSError(18, 'Invalid cross-device link')
> 
> CondaError: OSError(18, 'Invalid cross-device link')
> 
> 
> 
> pip-9.0.1-py35 100% |###############################| Time: 0:00:04 389.24 kB/s
> flask-0.11.1-p 100% |###############################| Time: 0:00:00 526.69 kB/s
> The command '/bin/sh -c conda env create -f environment.yml -n $ENV_NAME' returned a non-zero code: 1

@elsmorian Thanks. I'm not disabling the upgrading at the moment, as it is not needed. All my scripts install all python requirements in 2: make sure conda is up to date (or in this occasion force it to the latest 4.2.x), install all conda & pip requirements in one command. This means after this conda installs might fail due to this bug, but should be good enough as a work around.
Thanks for the report.  I'm not sure this is a new problem in 4.3, but it might be.  Without more debug output (and I'm not sure conda-env can even give more), my guess is that conda is trying to hard-link across two different devices.

Changing your command to 

    CONDA_ALWAYS_COPY=true /root/miniconda3/bin/conda-env create -f=environment.yml --name carnd-term1 --debug -v -v

should fix your immediate problem.  It's possible that conda 4.2 did this better.  Can you confirm that this is something new in conda 4.3?
Hi,

I just got the same error on OSX El Capitan. Reverting to 4.2.12 fixes it.

/Rasmus
Oops, sorry I forgot that I was working in a Docker container. Debian 8, not OSX :)
@rasmusagren Does setting the `CONDA_ALWAYS_COPY=true` environment variable help at all?
I will test the workaround tonight. Here is the fragment of my dicker script. It was working last week:
ADD https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh tmp/Miniconda3-latest-Linux-x86_64.sh
RUN bash tmp/Miniconda3-latest-Linux-x86_64.sh -b
ENV PATH $PATH:/root/miniconda3/bin/

COPY environment.yml  .
RUN conda install --yes pyyaml
RUN conda env create -f=environment.yml --name carnd-term1

I am not sure which of the dependencies changed lately.
If either of you can reproduce your error without using a `conda env` command (probably just `conda create` or `conda install`), it would be a huge help to add `-vvv` and share the output.  It'll be extremely verbose, but it will help me pinpoint what's going on.
CONDA_ALWAYS_COPY=true didn't help in my case, but going back to 4.2.12 (debian jessie in Docker 1.12), too (like for rasmusagren)
Actually, if you're using a conda-env command that's fine. Just set an environment variable `CONDA_VERBOSE=3`, and then remove the other `--debug` and `-v` flags. 
@troussan Could you change the line 

    RUN conda env create -f=environment.yml --name carnd-term1

in your docker file to

    RUN CONDA_VERBOSE=3 conda env create -f=environment.yml --name carnd-term1

and then give me the full output?
@kalefranz This produced exactly the same output as the one posted above.

Downgrading to 4.2.13 resolves the issue.
I'm seeing the same error all of a sudden. Docker version 1.12.3, have tried with Miniconda2-4.2.12-Linux-x86_64.sh and Miniconda2-latest-Linux-x86_64.sh , so at least what I'm seeing isn't a 4.3 issue. Error occurs if I run my docker build from the Dockerfile, but if I use an interactive session & run the install commands one by one it works fine.
This is on my list of bugs to quash today.  I need to set up a docker environment on my machine first though.  There's not yet enough information in this ticket for me to understand that root cause.
I had the problem inside a Dockerfile build yesterday and had this error. However, I came past it when downgrading to 4.2.12, also during the Dockerfile built. I think you have to be very careful that conda doesn't manage to upgrade to 4.3 again.
Oh nice catch! I had a `conda update conda` in there I'd forgotten about :) 
I just came across this github issue while trying to debug a problem that started recently with a complicated docker build process. I've got as far boiling my problem down to the following (not yet minimal) example:

```
$ cat Dockerfile
FROM continuumio/anaconda3:4.2.0
RUN conda install -y pandas
RUN conda install -y -c conda-forge jupyter_contrib_nbextensions

$ docker build . --no-cache
Sending build context to Docker daemon 568.3 kB
Step 1 : FROM continuumio/anaconda3:4.2.0
 ---> f44b5cac90c5
Step 2 : RUN conda install -y pandas
 ---> Running in a129a8f484c5
Fetching package metadata .......
Solving package specifications: ..........

Package plan for installation in environment /opt/conda:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-env-2.6.0            |                0          502 B
    requests-2.12.4            |           py35_0         800 KB
    pandas-0.19.2              |      np111py35_1        16.7 MB
    pyopenssl-16.2.0           |           py35_0          70 KB
    conda-4.3.4                |           py35_0         487 KB
    ------------------------------------------------------------
                                           Total:        18.1 MB

The following NEW packages will be INSTALLED:

    conda-env: 2.6.0-0

The following packages will be UPDATED:

    conda:     4.2.9-py35_0       --> 4.3.4-py35_0
    pandas:    0.18.1-np111py35_0 --> 0.19.2-np111py35_1
    pyopenssl: 16.0.0-py35_0      --> 16.2.0-py35_0
    requests:  2.11.1-py35_0      --> 2.12.4-py35_0

Fetching packages ...
conda-env-2.6. 100% |###############################| Time: 0:00:00 377.34 kB/s
requests-2.12. 100% |###############################| Time: 0:00:00   1.79 MB/s
pandas-0.19.2- 100% |###############################| Time: 0:00:04   4.18 MB/s
pyopenssl-16.2 100% |###############################| Time: 0:00:00 951.86 kB/s
conda-4.3.4-py 100% |###############################| Time: 0:00:00   2.17 MB/s
Extracting packages ...
[      COMPLETE      ]|##################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################| 100%
 ---> c82a1ab1c82e
Removing intermediate container a129a8f484c5
Step 3 : RUN conda install -y -c conda-forge jupyter_contrib_nbextensions
 ---> Running in f2d59f035524
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /opt/conda:

The following NEW packages will be INSTALLED:

    jupyter_contrib_core:              0.3.0-py35_1 conda-forge
    jupyter_contrib_nbextensions:      0.2.3-py35_0 conda-forge
    jupyter_highlight_selected_word:   0.0.7-py35_0 conda-forge
    jupyter_latex_envs:                1.3.6-py35_0 conda-forge
    jupyter_nbextensions_configurator: 0.2.3-py35_0 conda-forge

The following packages will be SUPERCEDED by a higher-priority channel:

    conda:                             4.3.4-py35_0             --> 4.2.13-py35_0 conda-forge
    conda-env:                         2.6.0-0                  --> 2.6.0-0       conda-forge

conda-env-2.6. 100% |###############################| Time: 0:00:00 840.02 kB/s
conda-4.2.13-p 100% |###############################| Time: 0:00:00 612.71 kB/s
jupyter_contri 100% |###############################| Time: 0:00:00   1.10 MB/s
jupyter_highli 100% |###############################| Time: 0:00:00   1.05 MB/s
jupyter_latex_ 100% |###############################| Time: 0:00:00   1.43 MB/s
jupyter_nbexte 100% |###############################| Time: 0:00:00   2.10 MB/s
jupyter_contri  88% |###########################    | Time: 0:00:02   5.38 MB/s

CondaError: OSError(18, 'Invalid cross-device link')

CondaError: OSError(18, 'Invalid cross-device link')

CondaError: OSError(18, 'Invalid cross-device link')



jupyter_contri 100% |###############################| Time: 0:00:02   5.82 MB/s
The command '/bin/sh -c conda install -y -c conda-forge jupyter_contrib_nbextensions' returned a non-zero code: 1
```

I've attached a longer version with verbose output from conda: [verbose.txt](https://github.com/conda/conda/files/712290/verbose.txt)

I'm still investigating but wanted to post now because it sounds like @kalefranz might be trying to reproduce the problem at the moment, and maybe this example helps.

[EDIT: I cut down the example slightly]
To work around this problem for now, I have ``RUN conda config --set auto_update_conda False`` in my Dockerfile before installing any other packages.
This did not work for me.
Not sure what changed, but all builds with anaconda fail from today with this error. Tried the auto_update_conda work around, the always copy work around, and forced conda to the latest known good version (4.3.4). But everything still fails. After reverting to conda 4.2.x it works again. (Not sure where the passed builds with conda 4.3.4 came from).
I'm also hitting this in both Ubuntu and Alpine based Docker containers, and have got a combination of the above to work.

@pvanderlinden `conda config --set auto_update_conda False` might not exist in your version of miniconda or whatever you are using to install conda- I got this workaround to work by using Miniconda 3.9.1 to install conda version 4.2.13 and then set no update (otherwise any further installs in the root conda env will try and update conda too).

```RUN cd /tmp && \
    mkdir -p $CONDA_DIR && \
    wget --quiet https://repo.continuum.io/miniconda/Miniconda3-3.9.1-Linux-x86_64.sh && \
    echo "6c6b44acdd0bc4229377ee10d52c8ac6160c336d9cdd669db7371aa9344e1ac3 *Miniconda3-3.9.1-Linux-x86_64.sh" | sha256sum -c - && \
    /bin/bash Miniconda3-3.9.1-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
    rm Miniconda3-3.9.1-Linux-x86_64.sh && \
    $CONDA_DIR/bin/conda install --yes conda=4.2.13 && \
    conda config --set auto_update_conda False```

Just adding that I'm encountering the same issue on building a simple debian docker container.
Dockerfile and terminal output attached.
[dockerfile.txt](https://github.com/conda/conda/files/718699/dockerfile.txt)


>  >>>

>docker build -t webportal .
Sending build context to Docker daemon 688.6 kB
Step 1 : FROM debian@sha256:32a225e412babcd54c0ea777846183c61003d125278882873fb2bc97f9057c51
 ---> bb5d89f9b6cb
Step 2 : MAINTAINER Joshua Barber "j.barber501@gmail.com"
 ---> Using cache
 ---> d7e4ed8df082
Step 3 : USER root
 ---> Using cache
 ---> 44c581a995a0
Step 4 : RUN apt-get update  &&         apt-get install -y python3-pip python-dev build-essential wget &
&       rm /bin/sh && ln -s /bin/bash /bin/sh
 ---> Using cache
 ---> d543e8b94bad
Step 5 : ENV APP_ACTIVATE "python ./dashboard.py"
 ---> Using cache
 ---> 6a2d47160dd3
Step 6 : ENV ENV_NAME "app-env"
 ---> Using cache
 ---> ae7475dfad71
Step 7 : ENV CONDA_DIR /opt/conda
 ---> Using cache
 ---> 595847dba965
Step 8 : ENV STARTSCRIPT /code/start.sh
 ---> Using cache
 ---> 90e5e94733fb
Step 9 : ENV PATH /$CONDA_DIR/bin:${PATH}
 ---> Using cache
 ---> b54f6a1666be
Step 10 : RUN cd /tmp &&        mkdir -p $CONDA_DIR &&  wget --quiet http://repo.continuum.io/miniconda/
Miniconda3-latest-Linux-x86_64.sh &&    /bin/bash Miniconda3-latest-Linux-x86_64.sh -f -b -p $CONDA_DIR
&&      rm Miniconda3-latest-Linux-x86_64.sh &&         conda update -y conda &&        conda clean -tip
sy
 ---> Using cache
 ---> 4f7b9d129bee
Step 11 : COPY . /code
 ---> b3a42b33dbb6
Removing intermediate container 2719dc0dd065
Step 12 : WORKDIR /code
 ---> Running in 25fec38bd680
 ---> 76c82c34fadf
Removing intermediate container 25fec38bd680
Step 13 : RUN conda env create -f environment.yml -n $ENV_NAME
 ---> Running in d94ecbe505f0
Fetching package metadata .........
Solving package specifications: .
libpq-9.5.4-0. 100% |###############################| Time: 0:00:01  65.94 kB/s
openssl-1.0.2j 100% |###############################| Time: 0:00:30 108.16 kB/s
readline-6.2-2 100% |###############################| Time: 0:00:02 209.19 kB/s
sqlite-3.13.0- 100% |###############################| Time: 0:00:18 225.25 kB/s
tk-8.5.18-0.ta 100% |###############################| Time: 0:00:12 152.99 kB/s
xz-5.2.2-1.tar 100% |###############################| Time: 0:00:07  94.97 kB/s
zlib-1.2.8-3.t 100% |###############################| Time: 0:00:01  52.40 kB/s
python-3.5.2-0 100% |###############################| Time: 0:01:03 284.78 kB/s
click-6.7-py35 100% |###############################| Time: 0:00:01  74.13 kB/s
itsdangerous-0 100% |###############################| Time: 0:00:00 250.31 kB/s
markupsafe-0.2 100% |###############################| Time: 0:00:00  53.70 kB/s
psycopg2-2.6.2 100% |###############################| Time: 0:00:01 223.49 kB/s
setuptools-27. 100% |###############################| Time: 0:01:16   7.05 kB/s
sqlalchemy-1.0 100% |###############################| Time: 0:00:02 544.09 kB/s
werkzeug-0.11. 100% |###############################| Time: 0:00:00 528.79 kB/s
wheel-0.29.0-p 100% |###############################| Time: 0:00:00 789.20 kB/s
jinja2-2.9.4-p 100% |###############################| Time: 0:00:00 681.72 kB/s
pip-9.0.1-py35  33% |##########                     | Time: 0:00:01 338.21 kB/s

> CondaError: OSError(18, 'Invalid cross-device link')
> 
> CondaError: OSError(18, 'Invalid cross-device link')
> 
> CondaError: OSError(18, 'Invalid cross-device link')
> 
> 
> 
> pip-9.0.1-py35 100% |###############################| Time: 0:00:04 389.24 kB/s
> flask-0.11.1-p 100% |###############################| Time: 0:00:00 526.69 kB/s
> The command '/bin/sh -c conda env create -f environment.yml -n $ENV_NAME' returned a non-zero code: 1

@elsmorian Thanks. I'm not disabling the upgrading at the moment, as it is not needed. All my scripts install all python requirements in 2: make sure conda is up to date (or in this occasion force it to the latest 4.2.x), install all conda & pip requirements in one command. This means after this conda installs might fail due to this bug, but should be good enough as a work around.

Resolving patch:
diff --git a/conda/core/path_actions.py b/conda/core/path_actions.py
--- a/conda/core/path_actions.py
+++ b/conda/core/path_actions.py
@@ -2,6 +2,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 
 from abc import ABCMeta, abstractmethod, abstractproperty
+from errno import EXDEV
 import json
 from logging import getLogger
 from os.path import dirname, join
@@ -793,7 +794,18 @@ def execute(self):
         if lexists(self.hold_path):
             rm_rf(self.hold_path)
         if lexists(self.target_full_path):
-            backoff_rename(self.target_full_path, self.hold_path)
+            try:
+                backoff_rename(self.target_full_path, self.hold_path)
+            except (IOError, OSError) as e:
+                if e.errno == EXDEV:
+                    # OSError(18, 'Invalid cross-device link')
+                    # https://github.com/docker/docker/issues/25409
+                    # ignore, but we won't be able to roll back
+                    log.debug("Invalid cross-device link on rename %s => %s",
+                              self.target_full_path, self.hold_path)
+                    rm_rf(self.target_full_path)
+                else:
+                    raise
         extract_tarball(self.source_full_path, self.target_full_path)
 
         target_package_cache = PackageCache(self.target_pkgs_dir)


Test patch: