{"action":"created","issue":{"url":"https://api.github.com/repos/yarnpkg/yarn/issues/1085","repository_url":"https://api.github.com/repos/yarnpkg/yarn","labels_url":"https://api.github.com/repos/yarnpkg/yarn/issues/1085/labels{/name}","comments_url":"https://api.github.com/repos/yarnpkg/yarn/issues/1085/comments","events_url":"https://api.github.com/repos/yarnpkg/yarn/issues/1085/events","html_url":"https://github.com/yarnpkg/yarn/issues/1085","id":183177548,"number":1085,"title":"Yarn Install Error: TypeError: Cannot read property 'split' of undefined","user":{"login":"kabirsikand","id":1432209,"avatar_url":"https://avatars.githubusercontent.com/u/1432209?v=3","gravatar_id":"","url":"https://api.github.com/users/kabirsikand","html_url":"https://github.com/kabirsikand","followers_url":"https://api.github.com/users/kabirsikand/followers","following_url":"https://api.github.com/users/kabirsikand/following{/other_user}","gists_url":"https://api.github.com/users/kabirsikand/gists{/gist_id}","starred_url":"https://api.github.com/users/kabirsikand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kabirsikand/subscriptions","organizations_url":"https://api.github.com/users/kabirsikand/orgs","repos_url":"https://api.github.com/users/kabirsikand/repos","events_url":"https://api.github.com/users/kabirsikand/events{/privacy}","received_events_url":"https://api.github.com/users/kabirsikand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-15T00:31:03Z","updated_at":"2016-10-22T17:19:05Z","closed_at":null,"body":"<!-- *Before creating an issue please make sure you are using the latest version of yarn.* -->\r\n\r\n**Do you want to request a *feature* or report a *bug*?**\r\n*Bug*\r\n\r\n**What is the current behavior?**\r\nWhen running `yarn` a second (or third or fourth, etc...) time in a repo:\r\n```\r\n$ yarn\r\nyarn install v0.15.1\r\n[1/4] 🔍  Resolving packages...\r\nerror TypeError: Cannot read property 'split' of undefined\r\n    at Object.explodeHashedUrl (/Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/lib/util/version.js:8:20)\r\n    at PackageRequest.getLocked (/Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/lib/package-request.js:133:59)\r\n    at /Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/lib/resolvers/exotics/git-resolver.js:170:36\r\n    at next (native)\r\n    at step (/Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)\r\n    at /Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14\r\n    at new Promise (/Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/node_modules/core-js/library/modules/es6.promise.js:191:7)\r\n    at /Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12\r\n    at GitResolver.resolve (/Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/lib/resolvers/exotics/git-resolver.js:195:7)\r\n    at GitHubResolver.fork (/Users/blah/.nvm/v5.2.0/lib/node_modules/yarn/lib/resolvers/base-resolver.js:24:21)\r\ninfo Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command.\r\n```\r\n**If the current behavior is a bug, please provide the steps to reproduce.**\r\nrun `yarn upgrade` with a package.json like:\r\n```\r\n{\r\n  \"name\": \"foo\",\r\n  \"version\": \"0.0.1\",\r\n  \"description\": \"Settings for foo customers\",\r\n  \"private\": true,\r\n  \"directories\": {\r\n    \"doc\": \"doc\",\r\n    \"test\": \"tests\"\r\n  },\r\n  \"scripts\": {\r\n    \"build\": \"ember build\",\r\n    \"postinstall\": \"bower install\",\r\n    \"start\": \"ember server\",\r\n    \"test\": \"ember test\"\r\n  },\r\n  \"repository\": \"\",\r\n  \"engines\": {\r\n    \"node\": \">= 5.0.0\"\r\n  },\r\n  \"author\": \"foo\",\r\n  \"license\": \"UNLICENSED\",\r\n  \"dependencies\": {\r\n    \"foo-gooey\": \"file:../foo-gooey\",\r\n    \"foo-tables\": \"file:../foo-tables\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"broccoli-asset-rev\": \"~2.4.2\",\r\n    \"ember-ajax\": \"~2.0.1\",\r\n    \"ember-cli\": \"~2.8.0\",\r\n    \"ember-cli-app-version\": \"~1.0.0\",\r\n    \"ember-cli-babel\": \"~5.1.6\",\r\n    \"ember-cli-dependency-checker\": \"~1.2.0\",\r\n    \"ember-cli-htmlbars\": \"~1.0.3\",\r\n    \"ember-cli-htmlbars-inline-precompile\": \"~0.3.1\",\r\n    \"ember-cli-inject-live-reload\": \"~1.4.0\",\r\n    \"ember-cli-jshint\": \"~1.0.0\",\r\n    \"ember-cli-mocha\": \"~0.10.4\",\r\n    \"ember-cli-release\": \"~0.2.9\",\r\n    \"ember-cli-sass\": \"~5.5.2\",\r\n    \"ember-cli-sri\": \"~2.1.0\",\r\n    \"ember-cli-test-loader\": \"~1.1.0\",\r\n    \"ember-cli-uglify\": \"~1.2.0\",\r\n    \"ember-data\": \"~2.8.0\",\r\n    \"ember-data-hal-9000\": \"201-created/ember-data-hal-9000\",\r\n    \"ember-export-application-global\": \"~1.0.5\",\r\n    \"ember-load-initializers\": \"~0.5.1\",\r\n    \"ember-resolver\": \"~2.0.3\",\r\n    \"ember-simple-auth\": \"~1.1.0\",\r\n    \"ember-sinon\": \"~0.5.1\",\r\n    \"loader.js\": \"~4.0.1\",\r\n    \"torii\": \"~0.8.0\"\r\n  }\r\n}\r\n```\r\nRun `yarn` again.\r\n\r\n\r\n**What is the expected behavior?**\r\nIt should install all packages.\r\n\r\n\r\n**Please mention your node.js, yarn and operating system version.**\r\n```\r\n$ node --version\r\nv5.2.0\r\n\r\n$ npm --version\r\n3.3.12\r\n\r\n$ yarn --version\r\n0.15.1\r\n```"},"comment":{"url":"https://api.github.com/repos/yarnpkg/yarn/issues/comments/255541370","html_url":"https://github.com/yarnpkg/yarn/issues/1085#issuecomment-255541370","issue_url":"https://api.github.com/repos/yarnpkg/yarn/issues/1085","id":255541370,"user":{"login":"serhalp","id":1377702,"avatar_url":"https://avatars.githubusercontent.com/u/1377702?v=3","gravatar_id":"","url":"https://api.github.com/users/serhalp","html_url":"https://github.com/serhalp","followers_url":"https://api.github.com/users/serhalp/followers","following_url":"https://api.github.com/users/serhalp/following{/other_user}","gists_url":"https://api.github.com/users/serhalp/gists{/gist_id}","starred_url":"https://api.github.com/users/serhalp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serhalp/subscriptions","organizations_url":"https://api.github.com/users/serhalp/orgs","repos_url":"https://api.github.com/users/serhalp/repos","events_url":"https://api.github.com/users/serhalp/events{/privacy}","received_events_url":"https://api.github.com/users/serhalp/received_events","type":"User","site_admin":false},"created_at":"2016-10-22T17:19:05Z","updated_at":"2016-10-22T17:19:05Z","body":"So there are a few different things going on here, some of which are obscuring others.\r\n\r\nFirst, yarn makes [this request](https://github.com/yarnpkg/yarn/blob/0c5bd61b5b50c376ffe37a3bb951d2b3bbe19ed1/src/resolvers/exotics/hosted-git-resolver.js#L84-L87) to hosted git repos to resolve the ref specified in the URL:\r\n```\r\n${url}/info/refs?service=git-upload-pack\r\n```\r\n\r\nand yarn's request manager handles 400s, 403s, and 404s by returning `false` but does not handle 401s. GitHub appears to respond with a 401 and a response body of \"Repository not found\" when attempting to hit the above path for a repo that does not exist:\r\n\r\n```\r\ncurl -v https://github.com/Nikku/foofoodoesnotexist123.git/info/refs?service=git-upload-pack\r\n*   Trying 192.30.253.112...\r\n* Connected to github.com (192.30.253.112) port 443 (#0)\r\n* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\r\n* Server certificate: github.com\r\n* Server certificate: DigiCert SHA2 Extended Validation Server CA\r\n* Server certificate: DigiCert High Assurance EV Root CA\r\n> GET /Nikku/foofoodoesnotexist123.git/info/refs?service=git-upload-pack HTTP/1.1\r\n> Host: github.com\r\n> User-Agent: curl/7.43.0\r\n> Accept: */*\r\n> \r\n< HTTP/1.1 401 Authorization Required\r\n< Server: GitHub Babel 2.0\r\n< Content-Type: text/plain\r\n< Content-Length: 21\r\n< WWW-Authenticate: Basic realm=\"GitHub\"\r\n< X-GitHub-Request-Id: 49E7878C:24241:3A5E384:580B9B32\r\n< X-Frame-Options: DENY\r\n< \r\n* Connection #0 to host github.com left intact\r\nRepository not found.\r\n```\r\n\r\nwhich then [is of course truthy](https://github.com/yarnpkg/yarn/blob/0c5bd61b5b50c376ffe37a3bb951d2b3bbe19ed1/src/resolvers/exotics/hosted-git-resolver.js#L89) and gets parsed in all sorts of incorrect ways then [passed through to `Git.parseRefs`](https://github.com/yarnpkg/yarn/blob/0c5bd61b5b50c376ffe37a3bb951d2b3bbe19ed1/src/resolvers/exotics/hosted-git-resolver.js#L107) which parses this in still more incorrect ways, until finally we get a `line` [here](https://github.com/yarnpkg/yarn/blob/0c5bd61b5b50c376ffe37a3bb951d2b3bbe19ed1/src/util/git.js#L346) which is an empty string, and thus `sha` is `''` and `id` is `undefined`.\r\n\r\nFinally, in the test case I provided, this all occurs (unrelatedly) because the `user/repo.git#optional-commitish` format is not handled correctly, leading to a request to `https://github.com/Nikku/node-browserify.git.git/info/refs?service=git-upload-pack` (notice **.git.git**).\r\n\r\nI'll get started on two PRs. Should I split this out into separate issues?"}}
{"actor":{"display_login":"serhalp"}}