Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn install Invalid protocol error #1625

Closed
lambertkuang opened this issue Nov 2, 2016 · 23 comments
Closed

Yarn install Invalid protocol error #1625

lambertkuang opened this issue Nov 2, 2016 · 23 comments

Comments

@lambertkuang
Copy link

Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Running yarn on a new system gives me this error:

Error: Invalid protocol: git+https:
      at Request.init (/usr/local/lib/node_modules/yarn/node_modules/request/request.js:459:31)
      at new Request (/usr/local/lib/node_modules/yarn/node_modules/request/request.js:128:8)
      at request (/usr/local/lib/node_modules/yarn/node_modules/request/index.js:54:10)
      at RequestManager.execute (/usr/local/lib/node_modules/yarn/lib/util/request-manager.js:327:17)
      at RequestManager.shiftQueue (/usr/local/lib/node_modules/yarn/lib/util/request-manager.js:353:10)
      at Promise (/usr/local/lib/node_modules/yarn/lib/util/request-manager.js:150:12)
      at RequestManager.request (/usr/local/lib/node_modules/yarn/lib/util/request-manager.js:148:21)
      at NpmRegistry.request (/usr/local/lib/node_modules/yarn/lib/registries/npm-registry.js:97:32)
      at TarballFetcher.fetchFromExternal (/usr/local/lib/node_modules/yarn/lib/fetchers/tarball-fetcher.js:176:21)
      at TarballFetcher._fetch (/usr/local/lib/node_modules/yarn/lib/fetchers/tarball-fetcher.js:218:19)

If the current behavior is a bug, please provide the steps to reproduce.
Running yarn on a new system
What is the expected behavior?
Install successfully
Please mention your node.js, yarn and operating system version.
Node: 6.9.1
Yarn: 0.16.0
OS: CentOS 6.8

@sebmck
Copy link
Contributor

sebmck commented Nov 3, 2016

Need more information to reproduce this like the package.json you're using.

@lambertkuang
Copy link
Author

{
  "name": "web",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node-dev app.js"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "",
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "private": true,
  "dependencies": {
    "co": "^4.6.0",
    "cookie-parser": "^1.4.3",
    "lodash": "^4.15.0",
    "lokka": "^1.7.0",
    "lokka-transport-http": "^1.6.1",
    "moment": "^2.15.1",
    "parse-cache-control": "^1.0.1",
    "request": "^2.74.0",
    "sand": "^1.7.2",
    "sand-clients": "^1.0.0",
    "sand-eventsd": "1.2.0",
    "sand-grain": "^1.2.1",
    "sand-graphql": "1.1.0",
    "sand-http": "^2.8.4",
    "sand-mysql": "^2.2.2"
  }
}

What's weird is that it worked when I ran yarn in another project on the same machine, then came back and ran yarn again on this project and it worked. It's happened twice, both on fresh GCE instances.

@KidkArolis
Copy link
Contributor

I couldn't reproduce, works fine with yarn@0.17.6. @lambertkuang can you try again with the latest yarn? I appreciate you're saying it only doesn't work the first time you run it. If you can still reproduce that, I will get a CentOS VM and try as well.

@nadia318
Copy link

nadia318 commented Nov 25, 2016

It still reproduce for me.

Error: Invalid protocol: git: at Request.init (/usr/local/lib/node_modules/yarn/node_modules/request/request.js:459:31) at new Request (/usr/local/lib/node_modules/yarn/node_modules/request/request.js:128:8) at request (/usr/local/lib/node_modules/yarn/node_modules/request/index.js:54:10) at RequestManager.execute (/usr/local/lib/node_modules/yarn/lib/util/request-manager.js:348:17) at RequestManager.shiftQueue (/usr/local/lib/node_modules/yarn/lib/util/request-manager.js:374:10) at data (/usr/local/lib/node_modules/yarn/lib/util/request-manager.js:264:12) at Extract.extractorStream.pipe.on.on (/usr/local/lib/node_modules/yarn/lib/fetchers/tarball-fetcher.js:128:9) at emitNone (events.js:91:20) at Extract.emit (events.js:185:7) at DirWriter.<anonymous> (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/extract.js:82:8)

Node: 6.9.1
Yarn: 0.17.8
linux x64

@ianmurrays
Copy link

ianmurrays commented Dec 6, 2016

I also get this same error, on a debian jessie docker container. Doesn't happen on macOS El Capitan for some reason.

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: Invalid protocol: git+https:
    at Request.init (/root/.yarn/node_modules/request/request.js:459:31)
    at new Request (/root/.yarn/node_modules/request/request.js:128:8)
    at request (/root/.yarn/node_modules/request/index.js:54:10)
    at RequestManager.execute (/root/.yarn/lib-legacy/util/request-manager.js:362:17)
    at RequestManager.shiftQueue (/root/.yarn/lib-legacy/util/request-manager.js:389:10)
    at /root/.yarn/lib-legacy/util/request-manager.js:276:12
    at Extract.<anonymous> (/root/.yarn/lib-legacy/fetchers/tarball-fetcher.js:146:9)
    at emitNone (events.js:72:20)
    at Extract.emit (events.js:166:7)
    at DirWriter.<anonymous> (/root/.yarn/node_modules/tar/lib/extract.js:82:8)

yarn 0.18.0

@ryanwe
Copy link

ryanwe commented Dec 15, 2016

In case this helps anyone, I ran into this when testing a migration from npm to yarn and running CI on travis. I was able to work around the problem by changing our dependency references in package.json from the form
"dependency-name": "Company/dependency-name",
to
"dependency-name": "git://github.com/Company/dependency-name",

node 6.3.0
yarn 0.17.10

@ianmurrays
Copy link

I guess the problem is more troublesome when one does not have control over that, say, when a package has a dependency written as "dependency-name": "Company/dependency-name"

@shkfnly
Copy link

shkfnly commented Dec 15, 2016

I found a temporary fix. Delete the yarn.lock file when trying to run on a new machine. Yarn will generate another one.

@ianmurrays
Copy link

@shkfnly kinda defeats the purpose though. The idea of using a lock file is to make sure you always have the same dependencies ☹️

@cyprusglobe
Copy link

I'm noticing this as well

@drewpc
Copy link

drewpc commented Jan 21, 2017

Same issue. Running yarn 0.19.1 and node 7.4.0 on macOS and Ubuntu Linux. Deleting yarn.lock is not an acceptable solution. Error message:

yarn install v0.19.1
[1/5] Resolving packages...
[2/5] Fetching packages...
error An unexpected error occurred: "Invalid protocol: git:".
info If you think this is a bug, please open a bug report with the information provided in "/opt/atlassian/pipelines/agent/build/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

yarn.lock.txt

@pnispel
Copy link

pnispel commented Feb 8, 2017

finally got repro steps for this:

  1. empty dependencies in package.json
yarn cache clean
yarn add grunt-jsdoc@0.5.7
yarn add jsdoc@3.4.3
rm -rf node_modules/
yarn cache clean
yarn

that produces a yarn.lock entry like

taffydb@2.6.2, "taffydb@git+https://github.com/hegemonic/taffydb.git":
  version "2.6.2"
  resolved "git+https://github.com/hegemonic/taffydb.git#e41b5e179e197bb85c5fb887b707672b1e5ca079"

which for whatever reason produces the error.
adding "taffydb": "2.6.2" to our package.json gives the working entry of

taffydb@2.6.2:
  version "2.6.2"
  resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268"

"taffydb@git+https://github.com/hegemonic/taffydb.git":
  version "2.6.2"
  resolved "git+https://github.com/hegemonic/taffydb.git#e41b5e179e197bb85c5fb887b707672b1e5ca079"

/shrug

@DCKT
Copy link

DCKT commented Jun 15, 2017

Hi,

I got this error too on yarn v0.24.6. Any idea about this ?

@larserikfinholt
Copy link

Hi, got the same issue on v0.23.. I upgraded to v0.24.6 but got same issue. I'm unsure of what info I should provide, but this is the last lines of yarn-error.log

  yargs@~3.10.0:
    version "3.10.0"
    resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1"
    dependencies:
      camelcase "^1.0.2"
      cliui "^2.1.0"
      decamelize "^1.0.0"
      window-size "0.1.0"
  
  yn@^1.2.0:
    version "1.2.0"
    resolved "https://registry.yarnpkg.com/yn/-/yn-1.2.0.tgz#d237a4c533f279b2b89d3acac2db4b8c795e4a63"

Trace: 
  Error: Invalid protocol: git:
      at Request.init (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:108126:31)
      at new Request (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:107796:8)
      at request (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:106394:10)
      at RequestManager.execute (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:56300:17)
      at RequestManager.shiftQueue (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:56327:10)
      at promise.default (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:56104:12)
      at Promise.F (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:29142:28)
      at RequestManager.request (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:56102:21)
      at NpmRegistry.request (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:30492:32)
      at TarballFetcher.fetchFromExternal (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:54425:21)

@larserikfinholt
Copy link

Deleted yarn.lock and everything works fine.

@nynexman4464
Copy link

Keep running into this setting up new devs. Deleting yarn.lock is not a good solution as it defeats the purpose of having the file in the same place (eg everyone installs the same versions of dependencies). It also is only temporary - once the yarn.lock is generated it can't be used by anyone else due to this issue.

Has anyone else found a different workaround?

@keegan-lillo
Copy link

One thing that worked for us was to:

  1. look through your yarn.lock for anything using:
    resolved "git+https://github.com/foo/bar.git#1234"
    
  2. Comment out the entire block
  3. Figure out which of your dependencies are using it and yarn upgrade the package to any new version. hopefully commenting out the block allows you to run the upgrade
  4. yarn upgrade back to the version you were using before. The changes to the lock file should be minimal.

@benjaminkohl
Copy link

We just inherited a project that uses Yarn so I installed it today and we are seeing this error. I agree that deleting the lock file is not an acceptable solution. I see a commit was merged on July 13th. Was that supposed to fix the issue?

@pyramation
Copy link

If it helps find this bug, I ran into this when using a git submodule and trying to run yarn install inside of the submodule.

I was able to copy the package.json into a clean folder and it ran just fine. However, any time, even after deleting yarn cache (manually and with yarn cache clean), it always failed to install properly inside of the submodule.

Currently my workaround is ok for me, but ideally would be great if there's a solution to this bug. Cheers!

BYK pushed a commit that referenced this issue Oct 26, 2017
**Summary**

Yarn can not handle the `git+https://` dependency format correctly, as described for various versions in #1625. The problem is present in Yarn 1.2.1.

A related problem for `git+ssh://` has been described in #573 and fixed in #3425.

This PR extends the solution from #3425 to use the Git fetcher for any [Git-over-protocol](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols) URLs.

**Test plan**

Extended the `package-request` unit tests to verify that the correct remote type (git) is used for `git+https://`, while the tarball remote type continues to be used for regular HTTP(S) URLs.
joaolucasl pushed a commit to joaolucasl/yarn that referenced this issue Oct 27, 2017
…g#4759)

**Summary**

Yarn can not handle the `git+https://` dependency format correctly, as described for various versions in yarnpkg#1625. The problem is present in Yarn 1.2.1.

A related problem for `git+ssh://` has been described in yarnpkg#573 and fixed in yarnpkg#3425.

This PR extends the solution from yarnpkg#3425 to use the Git fetcher for any [Git-over-protocol](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols) URLs.

**Test plan**

Extended the `package-request` unit tests to verify that the correct remote type (git) is used for `git+https://`, while the tarball remote type continues to be used for regular HTTP(S) URLs.
@charleylla
Copy link

this worked for me:

npm uninstall yarn -g
npm install yarn -g
yarn install

@perezpz
Copy link

perezpz commented Apr 28, 2018

upgrade yarn to latest version and everything works fine.

@cbrownbridge
Copy link

Tried deleting yarn.lock file, it now requires a yarn install, cannot yarn install as it hits the same error.... error An unexpected error occurred: "Invalid protocol: localhost:".

@olingern
Copy link
Contributor

Closing this. If this is is still an issue on 1.21.1, please comment and I'll reopen.

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

No branches or pull requests