Yarn: `Tarball is not in network and can not be located in cache`, with a certain combination of yarn.lock and yarn calls

Created on 7 Mar 2017  路  9Comments  路  Source: yarnpkg/yarn

https://github.com/yarnpkg/yarn/issues/560 is closed, so following up here:

Ok, got reproducible steps here, in a clean dir put:

Dockerfile:

FROM node:6.9
ADD . /app/
RUN wget https://github.com/yarnpkg/yarn/releases/download/v0.20.4/yarn-0.20.4.js -O /usr/local/bin/yarn && chmod +x /usr/local/bin/yarn
RUN cd /app && yarn
CMD /bin/bash

in yarn.lock:

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


[email protected]:
  version "2.9.6"
  resolved bluebird-2.9.6.tgz#1fc3a6b1685267dc121b5ec89b32ce069d81ab7d

bluebird@^2.9.33:
  version "2.11.0"
  resolved bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1

bluebird@^3.4.1:
  version "3.4.7"
  resolved bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3

package.json:

{
  "name": "hello",
  "description": "world",
  "private": true,
  "dependencies": {
    "babyparse": "0.4.2",
    "bluebird": "2.9.6"
  }
}

Run docker build -t ohmy .

and debug :)

Final output looks like:

...
Step 4 : RUN cd /app && yarn
 ---> Running in 6ae3fd9a9f2c
yarn install v0.20.4
[1/4] Resolving packages...
[2/4] Fetching packages...
error "bluebird-2.9.6.tgz": Tarball is not in network and can not be located in cache ("/app/bluebird-2.9.6.tgz")
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
The command '/bin/sh -c cd /app && yarn' returned a non-zero code: 1

Most helpful comment

So what is the agreed upon solution to this? I'm on yarn 1.22.4.

All 9 comments

Yeah - you were using an offline cache, but probably didn't passed it to your docker instance, so it wasn't able to find the tarballs. This should be fixed in the latest release (it will fallback on the network), but you should still make sure you don't have an unwanted offline mirror somewhere (check your .yarnrc files).

In my case I have a middleware (Nexus) mirror. Why this isn't a supported usage of yarn?

Not sure we're talking about the same kind of mirror. I'm talking about the offline mirror, a Yarn feature that allows you to store the tarball of your packages inside a directory (so that they can be fetched even when offline). It seems you've (maybe accidentally) enabled this feature, but didn't mount the directory into your docker instance. Yarn being unable to locate the tarball, the installation failed.

Message says "Tarball is not in network and can not be located in cache". If it's not in cache, it should be located in network. In my problem, when I delete the lock file it locates (and changes the lock file). In my understand, a offline mirror is a cache and same lock entries used for the cache should be valid and locate them in the internet when not in cache.

The offline mirror and the cache are two separate things. If the offline mirror cannot be found, the installation will not proceed in the older Yarn releases. Starting from the 0.23 release, this behavior changed, and we will fallback on the network if the offline mirror cannot be found.

So what is the agreed upon solution to this? I'm on yarn 1.22.4.

If anyone is running into this with yarn workspaces and local tarballs, try running yarn install from the root of the project, not from within a workspace directory (make sure the current directory is the root of the project).

The bug is on this line: https://github.com/yarnpkg/yarn/blob/0e7133ca28618513503b4e1d9063f1c18ea318e5/src/fetchers/tarball-fetcher.js#L214

If you're cd'd to any other folder than the root of your project, it will resolve to the wrong path.

I ran into this, but it was a silly mistake of having a docker build where I copied in package.json/yarn.lock as a stage, ran install, and then copied the rest of my project in. I needed to (obviously) copy in the tar file before running install.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FLGMwt picture FLGMwt  路  3Comments

torifat picture torifat  路  3Comments

danez picture danez  路  3Comments

davidmaxwaterman picture davidmaxwaterman  路  3Comments

esphen picture esphen  路  3Comments