Cerebro: Cerebro installation fails with unexpected token operator

Created on 2 Jul 2017  ยท  18Comments  ยท  Source: cerebroapp/cerebro

  • [x] I am on the latest Cerebro.app version
  • [x] I have searched the issues of this repo and believe that this is not a duplicate
  • OS version and name: Arch
  • Cerebro version: 0.3.0-1 (cerebro) & 0.2.7.r4.ga69a0a8-1 (cerebro-git)

Issue

Installing via AUR results in following error message with both cerebro and cerebro-git package:

Parse error at ./app/dist/main.bundle.js:940,5060                                         
,h,k){'use strict';var m=k(9);const n=u=>u.replace(/[^ะฐ-ัa-z0-9\s]/i,'').replace          
                                        ^    
SyntaxError: Unexpected token: operator (>)  
    at JS_Parse_Error.get (eval at <anonymous> (/home/jonathan/.cache/pacaur/cerebro/src/cerebro-0.3.0/node_modules/uglify-js/tools/node.js:27:1), <anonymous>:86:23)               
    at /home/jonathan/.cache/pacaur/cerebro/src/cerebro-0.3.0/node_modules/uglify-js/bin/uglifyjs:384:39        
    at time_it (/home/jonathan/.cache/pacaur/cerebro/src/cerebro-0.3.0/node_modules/uglify-js/bin/uglifyjs:620:15)                     
    at /home/jonathan/.cache/pacaur/cerebro/src/cerebro-0.3.0/node_modules/uglify-js/bin/uglifyjs:345:9         
    at tryToString (fs.js:512:3)             
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:500:12)

Most helpful comment

As a temporary solution I fixed path to uglify binary (./node_modules/uglify-es/bin/uglifyjs, instead of ./node_modules/.bin/uglifyjs). I'll try to investigate more why it happens, but #362 should fix installation issue

All 18 comments

To clarify whether the issue with AUR package or application itself, could you please confirm if the issue happens during installation, or after installation when starting the app?

@maximbaz during installation

I just tried AppImage which seems to be working except some searches result in a transparent box with nothing in it. Is this a known bug?

Bugy

I confirm, the error happens to me too during installation. Interestingly though I installed cerebro just two days ago from the same AUR package and it was successful. It is also curious that both cerebro and cerebro-git are affected - cerebro follows official releases and it was not updated for quite some time already.

@KELiON Looks like some dependency got updated (uglifyjs?) which breaks the build now.

As for the transparent window bug, it is tracked in https://github.com/KELiON/cerebro/issues/285

@maximbaz ๐Ÿค” even if something was updated it should work, because all dependencies are locked in yarn.lock. I've just tried to do rm -rf ./node_modules && yarn && yarn build and it works for me. Can you try to run it on your machine?

That is almost exactly what AUR package is doing, but for the sake of experiment I've just cloned the repo from scratch and ran the following:

$ git clone https://github.com/KELiON/cerebro.git
$ cd cerebro
$ yarn
$ cd app
$ yarn
$ cd ..
$ yarn run build

And it reproduces, exactly the same error.

If you have docker, I've recently made a docker image that builds AUR packages, you can try it ๐Ÿ™‚
It reproduces the issue as well.

$ docker pull maximbaz/arch-build-aur
$ docker run --rm -v $(pwd):/pkg maximbaz/arch-build-aur /bin/bash -c '/build.sh cerebro'

Put cerebro for the latest release or cerebro-git to fetch latest master.

@KELiON I've tried @maximbaz's docker and your command to build locally. Same error :slightly_frowning_face:

@KELiON Your builds are failing as well https://travis-ci.org/KELiON/cerebro/builds/250264889

@IgnusG yep, started to fail on travis after merging last PR, I didn't find time to fix, I'll try to do it asap

It seems that uglify-js does not accept _arrow function_ syntax. I did not push the analyze further. I am an Arch user who just discovered cerebro and would like to pacaur -S cerebro to try it out.

@enguerran uglify-js doesn't work with new ES syntax, i.e. with arrow functions. But in cerebro we're using uglify-es, that do support it

Tried to clone repo and reinstall everything from scratch, but still works. Can someone run ./node_modules/.bin/uglifyjs --version? It should be uglify-es 3.0.15. And run uglify from specified directory node_modules/.bin, like this:

yarn run build-main 
yarn run build-renderer
./node_modules/.bin/uglifyjs ./app/dist/main.bundle.js -o ./app/dist/main.bundle.js --mangle
./node_modules/.bin/uglifyjs ./app/dist/background.bundle.js -o ./app/dist/background.bundle.js --mangle

/cc @maximbaz

This seems to be the problem. Clean run, once again.

โฏ  git clone https://github.com/KELiON/cerebro.git
Cloning into 'cerebro'...
remote: Counting objects: 5827, done.
remote: Total 5827 (delta 0), reused 0 (delta 0), pack-reused 5827
Receiving objects: 100% (5827/5827), 3.31 MiB | 1.69 MiB/s, done.
Resolving deltas: 100% (3604/3604), done.

โฏ  cd cerebro && yarn && cd ./app && yarn && cd ../
yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "[email protected]" has incorrect peer dependency "eslint@^2.9.0".
warning "[email protected]" has incorrect peer dependency "eslint-plugin-import@^1.7.0".
warning "[email protected]" has incorrect peer dependency "eslint@^2.9.0".
warning "[email protected]" has incorrect peer dependency "eslint-plugin-import@^1.7.0".
[4/4] Building fresh packages...
$ concurrently "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json"
[0] node node_modules/fbjs-scripts/node/check-dev-engines.js package.json exited with code 0
Done in 6.76s.
yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 6.40s.

โฏ  ./node_modules/.bin/uglifyjs --version
uglify-js 2.8.27

@KELiON I can confirm the latest release of cerebro uses uglify-js 2.6.4 and HEAD uglify-js 2.8.27. But uglify-es has the correct 3.0.15 version.

$ npm list | grep uglify
[email protected]
โ”‚ โ”œโ”€โ”ฌ [email protected]
โ”‚ โ”‚ โ”œโ”€โ”€ [email protected].
$ yarn list | grep uglify
[email protected]
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ uglify-to-browserify@~1.0.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ uglify-js@^2.8.

It's fascinating, I mean we packed the release sources in an archive, locked dependencies versions, I'm 100% positive it _used to work_ just two weeks ago on my own laptop with the same OS, and now the same archive cannot correctly be installed, and the issue reproduces every single time... I'm very keen to see the solution for this bug, what else has to be locked to ensure that a given sources archive will always be able to build successfully in the future.

As a temporary solution I fixed path to uglify binary (./node_modules/uglify-es/bin/uglifyjs, instead of ./node_modules/.bin/uglifyjs). I'll try to investigate more why it happens, but #362 should fix installation issue

That works :+1:

To state the obvious, once its merged, cerebro-git AUR package will work, but cerebro will still not work until a new version is released that includes this patch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexSHoffman picture AlexSHoffman  ยท  4Comments

lavir picture lavir  ยท  7Comments

vandamm picture vandamm  ยท  5Comments

mycraftmw picture mycraftmw  ยท  5Comments

mijoharas picture mijoharas  ยท  3Comments