latticexyz / mud

MUD is a framework for building autonomous worlds
https://mud.dev
MIT License
726 stars 183 forks source link

add stackblitz or similar to docs #2373

Open holic opened 7 months ago

holic commented 7 months ago

so folks can start playing with mud immediately

yonadaaa commented 7 months ago

Will add more context soon, but here's a StackBlitz of the MUD React example: https://stackblitz.com/~/github.com/yonadaaa/my-project

yonadaaa commented 6 months ago

I put the MUD<>React template project on GitHub (https://github.com/yonadaaa/my-project), then imported it into StackBlitz, but ran into issues.

1) it can't install packages from the forge-std and ds-test dependencies from GitHub:

❯ pnpm install && pnpm run dev
Scope: all 3 workspace projects
preResolution: Hydrating content-addressable store.
Content-addressable store is at: ~/.local/share/pnpm/store/v3
Progress: total 513, downloaded 513, done

Lockfile is up to date, resolution step is skipped
Packages: +499
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 WARN  GET https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0 error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://codeload.github.com/foundry-rs/forge-std/tar.gz/74cfb77e308dd188d2f58864aaf44963ae6b88b1 error (ECONNRESET). Will retry in 10 seconds. 2 retries left.
 WARN  GET https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0 error (ECONNRESET). Will retry in 1 minute. 1 retries left.
 WARN  GET https://codeload.github.com/foundry-rs/forge-std/tar.gz/74cfb77e308dd188d2f58864aaf44963ae6b88b1 error (ECONNRESET). Will retry in 1 minute. 1 retries left.
 ECONNRESET  request to https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0 failed, reason: socket hang up

c: request to https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0 failed, reason: socket hang up
    at ClientRequest.eval (/usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:268:11333)
    at EventEmitter.emit (node:events:42:9202)
    at TLSSocket.socketOnEnd (node:_http_client:252:6585)
    at EventEmitter.emit (node:events:42:9318)
    at endReadableNT (node:internal/streams/readable:105:15152)
    at _0x4a10af (https://myproject-vifi.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:352:154446)
    at <anonymous> (https://myproject-vifi.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:352:154203)
Progress: resolved 499, reused 497, downloaded 0, added 497

2) foundryup fails with the curl command:

> pnpm install && pnpm run dev
Scope: all 3 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
. prepare$ (forge --version || pnpm foundry:up)
│ jsh: command not found: forge
│ > mud-template-react@ foundry:up /home/yonadaaa/my-project
│ > curl -L https://foundry.paradigm.xyz | bash && bash $HOME/.foundry/bin/foundryup
│ curl: socket hang up
│ ~/yonadaaa/my-project
~/yonadaaa/my-project master
│ jsh: can't open input file: /home/.foundry/bin/foundryup
│ ❯  ELIFECYCLE  Command failed.
└─ Failed in 812ms at /home/yonadaaa/my-project
 ELIFECYCLE  Command failed with exit code 1.

3) If we sidestep these issues and attempt to run the project, mprocs fails with a command can only contain words and redirects:

❯ pnpm install && pnpm run dev
Scope: all 3 workspace projects
preResolution: Hydrating content-addressable store.
Content-addressable store is at: ~/.local/share/pnpm/store/v3
Progress: total 513, downloaded 513, done

Lockfile is up to date, resolution step is skipped
Packages: +497
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 497, reused 497, downloaded 0, added 497, done

devDependencies:
+ @latticexyz/cli 2.0.0-next.17
+ @types/debug 4.1.7
+ @types/prettier 2.7.2
+ @typescript-eslint/eslint-plugin 5.46.1
+ @typescript-eslint/parser 5.46.1
+ eslint 8.29.0
+ mprocs 0.6.4
+ rimraf 3.0.2
+ typescript 5.1.6

Done in 6.3s

> mud-template-react@ dev /home/yonadaaa/my-project
> mprocs

/home/yonadaaa/my-project/node_modules/.pnpm/mprocs@0.6.4/node_modules/mprocs/mprocs-0.6.4-linux64/mprocs: line 2: a command can only contain words and redirects
 ELIFECYCLE  Command failed with exit code 2.

4) If I install forge with foundry-on-npm, the forge script fails with Error: Command failed with exit code 2: forge config --json node_modules/.bin/forge: line 3: unsupported shell syntax:


❯ pnpm run dev:contracts

> mud-template-react@ dev:contracts /home/yonadaaa/my-project
> pnpm --filter 'contracts' dev

> contracts@0.0.0 dev /home/yonadaaa/my-project/packages/contracts
> pnpm mud dev-contracts

(node:80) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:80) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
null
Error: Command failed with exit code 2: forge config --json
node_modules/.bin/forge: line 3: unsupported shell syntax
    at Module.makeError (/home/yonadaaa/my-project/node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/error.js:75:11)
    at handlePromise (/home/yonadaaa/my-project/node_modules/.pnpm/execa@7.2.0/node_modules/execa/index.js:144:40)
    at async n (/home/yonadaaa/my-project/node_modules/.pnpm/@latticexyz+common@2.0.0-next.17_typescript@5.1.6_zod@3.22.4/node_modules/@latticexyz/common/dist/foundry.js:25:71)
    at async Module.u (/home/yonadaaa/my-project/node_modules/.pnpm/@latticexyz+common@2.0.0-next.17_typescript@5.1.6_zod@3.22.4/node_modules/@latticexyz/common/dist/foundry.js:25:225)
    at async Object.handler (/home/yonadaaa/my-project/node_modules/.pnpm/@latticexyz+cli@2.0.0-next.17_google-protobuf@3.21.2/node_modules/@latticexyz/cli/dist/commands-3JV3U43E.js:35:5434) {
  shortMessage: 'Command failed with exit code 2: forge config --json',
  command: 'forge config --json',
  escapedCommand: 'forge config --json',
  exitCode: 2,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: 'node_modules/.bin/forge: line 3: unsupported shell syntax',
  cwd: '/home/yonadaaa/my-project/packages/contracts',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
/home/yonadaaa/my-project/packages/contracts:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  contracts@0.0.0 dev: `pnpm mud dev-contracts`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.
 ```