editor icon indicating copy to clipboard operation
editor copied to clipboard

Not able to run editor locally following instructions in Readme

Open ArulselvanMadhavan opened this issue 3 years ago • 1 comments

Hello, Thanks for maintaining this library!

I have not been able to run the editor in my machine following the instructions in the Readme. At first, the yarn start throws an error saying "tsconfig.json" is missing. I noticed that it was added to gitignore. I found an older version in the commit history and bypassed that error. Then, yarn start failed stating that public/spec/vega/index.json and vega-lite/index.json are missing. I found older versions from the commit history to start the server.

Could you please update the Readme with instructions on how to run the editor locally?

ArulselvanMadhavan avatar Feb 10 '23 19:02 ArulselvanMadhavan

if you run yarn, it should set up your environment including the tsconfig. You can see the build steps in https://github.com/vega/editor/blob/master/.github/workflows/test.yml.

Can you post your environment details?

domoritz avatar Feb 10 '23 22:02 domoritz

This issue is older than a year, not sure if my problem was the same one:

I cloned the repo (currently on commit 691d6195b75ad34f7afa8dc526f3a5561391fd37) and ran yarn. This resulted in ...

EDIT: This first block of the terminal session was only copied by accident. I leave it here for historical reasons. Please focus on the second block of output only, which shows the relevant part.

yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Saved lockfile.
Done in 0.07s.
root@1deaaa1511e4:/usr/app# cd editor/
root@1deaaa1511e4:/usr/app/editor# yarn
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[####------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 16/812^C
root@1deaaa1511e4:/usr/app/editor# time yarn
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > [email protected]" has incorrect peer dependency "react@^16.0.0-0".
warning " > [email protected]" has incorrect peer dependency "react-dom@^16.0.0-0".
warning " > [email protected]" has unmet peer dependency "vega@^5.24.0".
warning " > [email protected]" has unmet peer dependency "vega@^5.21.0".
warning " > [email protected]" has unmet peer dependency "vega@*".
warning " > [email protected]" has unmet peer dependency "postcss@^8.1.0".
[4/4] Building fresh packages...
$ husky && npx patch-package
patch-package 8.0.0
Applying patches...
[email protected] ✔
$ yarn vendor
yarn run v1.22.19
$ scripts/vendor.sh
Copying data to 'public/data'.
scripts/vendor.sh: line 17: rsync: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

When ignoring those errors and running yarn start nevertheless, you get

yarn run v1.22.19
$ PARCEL_BUILD_COMMIT_HASH=$(git rev-parse HEAD) parcel --watch-dir .. index.html
Server running at http://localhost:1234
🚨 Build failed.

@parcel/core: Failed to resolve '../../public/spec/vega/index.json' from './src/constants/specs.ts'

  /usr/app/editor/src/constants/specs.ts:1:24
  > 1 | import VEGA_SPECS from '../../public/spec/vega/index.json';
  >   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 | import VEGA_LITE_SPECS from '../../public/spec/vega-lite/index.json';
    3 |

@parcel/resolver-default: Cannot load file '../../public/spec/vega/index.json' in './src/constants'.
💡 Did you mean '_../../node_modules/vega/index.js_'?
💡 Did you mean '_../../node_modules/vega/index.d.ts_'?

This sounds like the problem OP described.

Quick-Fix for Users

Install rsync (e.g. apt-get update; apt-get install rsync on Debian) so that the script scripts/vendor.sh works.

Suggested Solution For Maintainers

Add a note to the README.md, that yarn and rsync (and all the other tools you may use in custom scripts) are needed.
btw: The eval rsync -r is not really needed in the script. A simple rm and cp should work too.

The custom script only seems to to handle the examples. If vega-editor would make them optional (just like the https://github.com/vega/editor-backend is optional too) then that would be even better.

schaetzc avatar Sep 13 '24 15:09 schaetzc

Something is off because there is a lock file.

domoritz avatar Sep 13 '24 16:09 domoritz

@domoritz Thank you for your swift reply. Can you explain your decision to close this issue? I cannot follow, maybe because I'm not familiar with tools like yarn.

there is a lock file.

Do you mean yarn.lock? Isn't it expected, that this file is there? It is part of the repo. According to the git history, it has been there for years and has been updated regularly.

Could it be that you meant to say »because there is no lock file«? The second line of my log said so. I accidentally copied too much of my terminal. Please have a look at the line after cd editor/.

I wanted to give you a way to reproduce this easily, using below docker command. However, that fails with yet another error:

sudo docker run -it --rm node bash -xc 'ls -a && git clone --depth=1 https://github.com/vega/editor.git && cd editor && ls -a && ( yarn; ls -a; yarn start; )'

prints ( parts shortend by me):

…
+ yarn
yarn install v1.22.22
…
[4/4] Building fresh packages...
error /editor/node_modules/canvas: Command failed.
…
Package pangocairo was not found in the pkg-config search path.
…
node-pre-gyp ERR! node-pre-gyp -v v1.0.11
…

See the attached full log log.txt using less -r log.txt

schaetzc avatar Sep 13 '24 22:09 schaetzc

Yeah, I got confused by your logs. Thanks for clarifying the message now. I accidentally closed this.

Thanks also for finding the cause here.

domoritz avatar Sep 14 '24 03:09 domoritz

I think either updating the docs or using rm and cp (probably preferred) makes sense. I originally used rsync because it was faster but that's probably not as relevant anymore with modern ssds. Would you send a pull request to switch to the simpler setup?

domoritz avatar Sep 14 '24 03:09 domoritz

Would you send a pull request to switch to the simpler setup?

Sure, see https://github.com/vega/editor/pull/1444
Took me a while because of the other issues, which I also documented in the new version of the README.

used rsync because it was faster

I was curious how much of an impact that had, and tested it after my changes. I wasn't able to reproduce any benefits on my systems and the currently used vega versions. I think switching to rm and cp was a good idea.

schaetzc avatar Sep 15 '24 16:09 schaetzc