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

Invalid string length #4929

Closed
jycouet opened this issue Nov 14, 2017 · 7 comments
Closed

Invalid string length #4929

jycouet opened this issue Nov 14, 2017 · 7 comments

Comments

@jycouet
Copy link

jycouet commented Nov 14, 2017

Hello,

I'm using yarn v1.3.2 and I have a bug.

What is the current behavior?
I'm running yarn from js like this:

    ({ stdout, stderr } = await exec('yarn install --ignore-scripts  --ignore-engines', {
      cwd: tmpDir,
      shell: true,
      env: { NODE_ENV: 'dev', PATH: process.env.PATH },
    }));
    logger.debug(`yarn stdout:\n${stdout}`);
    logger.debug(`yarn stderr:\n${stderr}`);

And I often get: "stderr": "error An unexpected error occurred: \"Invalid string length\".\n"

Here is my trace:

Trace: 
  RangeError: Invalid string length
      at tokenise (D:\Dev\jycouet_renovate\node_modules\yarn\lib\cli.js:59559:16)
      at tokenise.next (<anonymous>)
      at Parser.next (D:\Dev\jycouet_renovate\node_modules\yarn\lib\cli.js:59657:30)
      at Parser.parse (D:\Dev\jycouet_renovate\node_modules\yarn\lib\cli.js:59737:14)
      at Parser.parse (D:\Dev\jycouet_renovate\node_modules\yarn\lib\cli.js:59761:28)
      at parse (D:\Dev\jycouet_renovate\node_modules\yarn\lib\cli.js:59850:17)
      at module.exports.exports.default (D:\Dev\jycouet_renovate\node_modules\yarn\lib\cli.js:59443:96)
      at D:\Dev\jycouet_renovate\node_modules\yarn\lib\cli.js:1976:63
      at Generator.next (<anonymous>)
      at step (D:\Dev\jycouet_renovate\node_modules\yarn\lib\cli.js:92:30)

You you can see the package.json that I have (nothing really special?):

{
  "name": "vsts_tmpReno",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@angular/animations": "4.4.6",
    "@angular/cdk": "2.0.0-beta.12",
    "@angular/common": "4.4.6",
    "@angular/compiler": "4.4.6",
    "@angular/core": "4.4.6",
    "@angular/flex-layout": "2.0.0-rc.1",
    "@angular/forms": "4.4.6",
    "@angular/http": "4.4.6",
    "@angular/material": "2.0.0-beta.12",
    "@angular/platform-browser": "4.4.6",
    "@angular/platform-browser-dynamic": "4.4.6",
    "@angular/router": "4.4.6",
    "@markpieszak/ng-application-insights": "2.4.1",
    "@ng-bootstrap/ng-bootstrap": "1.0.0-beta.5",
    "@swimlane/ngx-datatable": "9.3.1",
    "angular-tree-component": "4.1.0",
    "angular2-moment": "1.7.0",
    "apollo-angular": "0.13.3",
    "apollo-client": "1.9.3",
    "apollo-client-rxjs": "0.6.0-rc.2",
    "bootstrap": "4.0.0-beta.2",
    "bowser": "1.8.1",
    "chart.js": "2.7.1",
    "classlist.js": "1.1.20150312",
    "core-js": "2.5.1",
    "d3": "4.11.0",
    "echarts": "3.8.5",
    "file-saver": "1.3.3",
    "font-awesome": "4.7.0",
    "graphql-tag": "2.5.0",
    "hammerjs": "2.0.8",
    "immutability-helper": "2.5.0",
    "leaflet": "1.2.0",
    "leaflet-geosearch": "2.6.0",
    "moment": "2.19.2",
    "mydaterangepicker": "4.1.11",
    "ng2-charts": "1.6.0",
    "ng2-date-picker": "2.6.2",
    "ngx-color-picker": "4.5.0",
    "ngx-echarts": "1.2.4",
    "ngx-infinite-scroll": "0.5.2",
    "ngx-swiper-wrapper": "4.6.6",
    "qrcodejs": "1.0.0",
    "rxjs": "5.5.2",
    "subscriptions-transport-ws": "0.8.3",
    "web-animations-js": "2.3.1",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@angular/cli": "1.5.0",
    "@angular/compiler-cli": "4.4.6",
    "@angular/language-service": "4.4.6",
    "@types/chartjs": "0.0.30",
    "@types/geojson": "1.0.6",
    "@types/jest": "20.0.8",
    "@types/leaflet": "1.2.2",
    "@types/moment": "2.13.0",
    "@types/node": "6.0.91",
    "codelyzer": "3.0.1",
    "graphql": "0.10.5",
    "graphql-code-generator": "0.8.14",
    "jest": "21.2.1",
    "jest-junit-reporter": "1.1.0",
    "jest-preset-angular": "3.0.2",
    "mutationobserver-shim": "0.3.2",
    "prettier": "1.8.2",
    "ts-node": "3.0.6",
    "tslint": "5.3.2",
    "tslint-config-prettier": "1.6.0",
    "tslint-microsoft-contrib": "5.0.1",
    "typescript": "2.6.1",
    "webpack-bundle-analyzer": "2.9.1"
  }
}

I don't get what could be the issue; Could you help me please?

Please mention your node.js, yarn and operating system version.
node: 8.7.0
yarn 1.3.2
On windows and Linux

Thank you

@ghost ghost assigned bestander Nov 14, 2017
@ghost ghost added the triaged label Nov 14, 2017
@sameer-coder
Copy link

Tried but couldn't reproduce it.

@anderszhang
Copy link

yes , i have same problem .
yarn v1.3.2
node 8.9.1
platform mac os 10. 13.1

@bestander
Copy link
Member

Could be Node.js specific

@rhendric
Copy link
Contributor

rhendric commented Nov 20, 2017

I think that's the part of yarn that handles yarn.lock; is it possible that's corrupted? Can you rename it (for further testing) and try running yarn again?

@jycouet
Copy link
Author

jycouet commented Nov 20, 2017

Hi,
I just found my issue thx to @rhendric
Yes my file was corrupted... I was copying only half of the file!!!

I owe you a 🍺

@Roog
Copy link

Roog commented Jan 18, 2018

Hi,
I'm running yarn on windows. Installed with the MSI installer. current version is 1.4.0-20180115.1714, this problem occurs in yarn 1.3.2 also. It's reacting really slow to any command and then thinks for a while when printing out: (Can be good to mention that i'm behind a corporate proxy. Not sure how much this matters).

I actually get the same result if I do "yarn init"

yarn run v1.4.0-20180115.1714 error An unexpected error occurred: "Invalid string length". info If you think this is a bug, please open a bug report with the information provided in "C:\\\\\\yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Currently running Node v8.9.1.

Here is my package.json:
{ "name": "Gui", "version": "1.0.0", "description": "Hacking", "main": "server.js", "license": "UNLICENSED", "repository": {}, "scripts": { "start": "SET NODE_ENV=development && webpack --color", "watch": "SET NODE_ENV=development && webpack --watch --color --progress", "webserver": "SET NODE_ENV=development&& webpack-dev-server --hot --colors", "watch:prod": "yarn build:prod --watch", "watch:dev": "yarn build:dev --watch", "build:prod": "yarn build --env.env=production", "build:dev": "yarn build --env.env=development", "build": "webpack --color --progress", "wd": "yarn watch:dev" }, "dependencies": { "FitText": "davatron5000/FitText.js", "applicationinsights-js": "1.0.14", "fittextjs": "1.2.0", "flexboxgrid": "6.3.1", "jquery": "3.2.1", "jquery-mobile": "1.5.0-alpha.1", "jquery-ui": "1.12.1", "json-stringify-safe": "moll/json-stringify-safe", "knockouch": "yaroslavya/knockouch", "knockout": "3.4.2", "knockout-postbox": "0.6.0", "moment": "2.19.1", "ms-signalr-client": "2.2.7", "slipjs": "pornel/slip", "underscore": "1.8.3", "virtual-keyboard": "1.27.0" }, "devDependencies": { "@types/applicationinsights-js": "1.0.5", "@types/jquery": "3.2.13", "@types/jqueryui": "1.11.37", "@types/knockout": "3.4.46", "@types/knockout.postbox": "0.0.28", "@types/signalr": "2.2.35", "@types/underscore": "1.8.3", "@types/virtual-keyboard": "1.26.0", "assets-webpack-plugin": "3.5.1", "copy-webpack-plugin": "4.2.3", "css-loader": "0.28.7", "extract-text-webpack-plugin": "3.0.2", "html-loader": "0.5.1", "ignore-loader": "0.1.2", "node-sass": "4.7.2", "sass-loader": "6.0.6", "ts-loader": "3.2.0", "tslint": "5.8.0", "tslint-loader": "3.5.3", "typescript": "2.6.2", "webpack": "3.9.1", "webpack-merge": "4.1.1", "yarn": "1.3.2" }, "author": "Roger" }

Trace: RangeError: Invalid string length at tokenise (C:\Users\rogsan01\Programs\Yarn\lib\cli.js:61500:21) at tokenise.next (<anonymous>) at Parser.next (C:\Users\rogsan01\Programs\Yarn\lib\cli.js:61624:28) at Parser.parse (C:\Users\rogsan01\Programs\Yarn\lib\cli.js:61672:30) at parse (C:\Users\rogsan01\Programs\Yarn\lib\cli.js:61845:17) at module.exports.exports.default (C:\Users\rogsan01\Programs\Yarn\lib\cli.js:61409:96) at YarnRegistry.<anonymous> (C:\Users\rogsan01\Programs\Yarn\lib\cli.js:91623:64) at Generator.next (<anonymous>) at step (C:\Users\rogsan01\Programs\Yarn\lib\cli.js:98:30) at C:\Users\rogsan01\Programs\Yarn\lib\cli.js:109:13

Not sure what to try?

Solved

  1. Ran yarn --verbose and checked every file that was listed to see if there was an error in them.
  2. Found oout that one .npmrc file had a wrong proxy definition. using "=" instead of " " (space).
  3. It is now working.

Should be:
proxy http://proxy.xx.se:98
https-proxy http://proxy.xx.se:98

Was:
proxy=http://proxy.xx.se:98
https-proxy=http://proxy.xx.se:98

Bye 👍

@bestander
Copy link
Member

Cool, looks like resolved, thanks for reporting

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

No branches or pull requests

7 participants
@Roog @anderszhang @rhendric @bestander @sameer-coder @jycouet and others