Yarn: the problem of installing yarn

Created on 16 Oct 2016  路  22Comments  路  Source: yarnpkg/yarn

system: Ubuntu 16.04 lts

when I type in sudo apt-get update,the problem occurred:

Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://archive.ubuntukylin.com:10006 xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E40EBBA24FF2FC69

W: Failed to fetch http://archive.ubuntukylin.com:10006/ubuntukylin/dists/xenial/InRelease  

W: Failed to fetch http://dl.yarnpkg.com/debian/dists/stable/Release.gpg  Cannot initiate the connection to dl.yarnpkg.com:80 (2400:cb00:2048:1::6810:3bad). - connect (101: Network is unreachable) [IP: 2400:cb00:2048:1::6810:3bad 80]

W: Failed to fetch http://dl.yarnpkg.com/debian/dists/stable/main/binary-amd64/Packages  Cannot initiate the connection to dl.yarnpkg.com:80 (2400:cb00:2048:1::6810:3bad). - connect (101: Network is unreachable) [IP: 2400:cb00:2048:1::6810:3bad 80]

W: Failed to fetch http://dl.yarnpkg.com/debian/dists/stable/main/binary-i386/Packages  Cannot initiate the connection to dl.yarnpkg.com:80 (2400:cb00:2048:1::6810:3bad). - connect (101: Network is unreachable) [IP: 2400:cb00:2048:1::6810:3bad 80]

W: Failed to fetch http://dl.yarnpkg.com/debian/dists/stable/main/i18n/Translation-en_US  Cannot initiate the connection to dl.yarnpkg.com:80 (2400:cb00:2048:1::6810:3bad). - connect (101: Network is unreachable) [IP: 2400:cb00:2048:1::6810:3bad 80]

W: Failed to fetch http://dl.yarnpkg.com/debian/dists/stable/main/i18n/Translation-en  Cannot initiate the connection to dl.yarnpkg.com:80 (2400:cb00:2048:1::6810:3bad). - connect (101: Network is unreachable) [IP: 2400:cb00:2048:1::6810:3bad 80]

W: Failed to fetch http://dl.yarnpkg.com/debian/dists/stable/main/i18n/Translation-zh_CN  Cannot initiate the connection to dl.yarnpkg.com:80 (2400:cb00:2048:1::6810:3bad). - connect (101: Network is unreachable) [IP: 2400:cb00:2048:1::6810:3bad 80]

W: Some index files failed to download. They have been ignored, or old ones used instead.

then I type in sudo apt-get install yarn,the problem still existed:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package yarn

what is the reason of it?

Most helpful comment

I was also getting the error The method driver /usr/lib/apt/methods/https could not be found.

This is how i fixed it

RUN apt-get update
RUN apt-get install apt-transport-https

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update
RUN apt-get install yarn

thanks to http://askubuntu.com/questions/165676/how-do-i-fix-a-e-the-method-driver-usr-lib-apt-methods-http-could-not-be-foun

All 22 comments

Hello @QuoniamYIF! "Network is unreachable" generally means that you have network errors on your end. It looks like it's trying to connect to the Yarn download server via IPv6, perhaps your IPv6 connectivity is broken. Can you please try ping6 dl.yarnpkg.com and ping6 google.com? If both fail, there's an issue with IPv6 connectivity on your system. As a quick hack, you could try disabling IPv6.

@Daniel15 thank you,the problem has been solved!

I'm also running into this problem while trying to install yarn using the Docker Node JS image:
https://hub.docker.com/_/node/

I get the following error:

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package yarn

I tried checking if IPv6 connectivity is broken and it's not.

@keatz55 Did you add the repository, and run apt-get update?

@Daniel15 Thanks for the response, I followed these steps:
https://yarnpkg.com/en/docs/install#linux-tab

Here is my Dockerfile

FROM node:latest

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update && apt-get install yarn

# Install Node.js dependencies
RUN yarn install

CMD [ "node", "server.js" ]

I get the before mentioned error on the RUN apt-get install yarn command

Also I have a docker-compose.yml file that has the following:

version: '2'
services:
  header:
    build: ./myApp
    volumes:
      - ./header:/src/app
    restart: always
    ports:
     - "3000:3000"
     - "3001:3001"
     - "5000:5000"

Try the Yarn Docker image (https://hub.docker.com/r/yarnpkg/node-yarn/) and see if that works for you. It's based off node:7

FROM yarn:latest

# Install Node.js dependencies
RUN yarn install

CMD [ "node", "server.js" ]

I'm having the same issue ('Unable to locate package yarn') as keatz55.
Running ubuntu (16.04.2 lts) in a docker (17.03.1-ce) container on Windows 10.
Resorting to yarn installation via npm for now..

@dk0r Did you add the Yarn package repository? Docs are at https://yarnpkg.com/en/docs/install#linux-tab

I was also getting the error The method driver /usr/lib/apt/methods/https could not be found.

This is how i fixed it

RUN apt-get update
RUN apt-get install apt-transport-https

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update
RUN apt-get install yarn

thanks to http://askubuntu.com/questions/165676/how-do-i-fix-a-e-the-method-driver-usr-lib-apt-methods-http-could-not-be-foun

Good catch - apt-transport-https should be installed on most systems, but minimal installations may not have it.

@Daniel15 I am also getting error to install yarn

jsroyal@HP:~$ sudo apt-get update && sudo apt-get install yarn
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://archive.ubuntu.com/ubuntu yakkety InRelease
Hit:3 http://archive.canonical.com/ubuntu yakkety InRelease
Hit:4 http://dl.google.com/linux/chrome/deb stable Release
Hit:5 http://archive.ubuntu.com/ubuntu yakkety-updates InRelease
Hit:6 http://archive.ubuntu.com/ubuntu yakkety-security InRelease
Hit:7 http://archive.ubuntu.com/ubuntu yakkety-backports InRelease
Hit:9 http://archive.ubuntu.com/ubuntu yakkety-proposed InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package yarn

Despite having added the Yarn package repository as per https://yarnpkg.com/en/docs/install#linux-tab, I still get the message E: Unable to locate package yarn.

I'm using:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial

and the repository addresses belong have urls such as:

root@UBU16-TUNR:~# apt-get update && apt-get install yarn
Hit:1 https://download.sublimetext.com apt/stable/ InRelease        
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]                  
Hit:3 http://bo.archive.ubuntu.com/ubuntu xenial InRelease                                  
Hit:4 http://bo.archive.ubuntu.com/ubuntu xenial-updates InRelease              
Hit:5 http://bo.archive.ubuntu.com/ubuntu xenial-backports InRelease            
Err:6 https://download.docker.com/linux/ubuntu xenial InRelease                             
  Could not resolve host: download.docker.com
Err:7 http://dl.google.com/linux/chrome/deb stable InRelease
  Temporary failure resolving 'dl.google.com'
Fetched 102 kB in 35s (2.904 B/s)
Reading package lists... Done
... _"more lines which end in the "Unable to locate package yarn"_ error...

Worth mentioning I am not using docker, although I installed it.

Also, the npm install -g yarnpkg workaround does not work.

@javlc You may have already resolved your issue; but for the benefit of others: I was having a similar problem on Ubuntu Budgie 16.04...

Note the yarn install guide's instruction "to configure the NodeSource repository" by running:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

When I ran that I got an error about missing "apt-transport-https"; so installed that with

sudo apt install apt-transport-https

...then ran the NodeSource repo line above - which ran to completion - and then sudo apt install yarn in order to successfully install yarn :)

@blindfish3 : Yes I fixed it using a symlink t the yarn executable, which, although inaccessible, it was indeed installed. The downside is that I will need to redo the entire process to update yarn.
For the _nodesoruce repo_ thing, I am using nvm to manage nodejs versions, so I may have missed this step. I think installing yarn in ubuntu when using nvm is a bit trickier than expected.

@javlc - I installed node via nvm also. From an answer elsewhere I'm guessing adding nodesource is enough to convince the Yarn installer that node is available on the system; since (IIRC) it looks at the contents of apt (which nvm obviously doesn't touch) to determine this. _I didn't have to run_:
sudo apt-get install -y nodejs

@keatz55 and anyone else, try running
sudo apt install cmdtest

Thanks @eibrahim and @blindfish3
apt-transport-https seemed to be the missing factor in my case :)

$ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package yarn

How to resolve this error?????

$ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package yarn

How to resolve this error?????

sudo npm install -g yarnpkg worked for me. Note that the following was printed in response.
"npm WARN deprecated [email protected]: Please use the yarn package instead of yarnpkg"

@ShubhamChauhanJi You need to add the Yarn repo:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Then it should work (but make sure you sudo apt-get update first)

Try This...

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Then run the below commands :+1:

sudo apt-get update
sudo apt-get install yarn

Locking this as it's outdated and has multiple different issues in it. Please create a new issue if you're still having trouble.

Was this page helpful?
0 / 5 - 0 ratings