ampproject / ampproject/amp.dev

Issues with building the website locally

Open
#3,330 1 comment 2 reactions 2 assignees Claimed by @matthiasrohmer View on GitHub
Category: UX P1: High Type: Bug
Dominant language
HTML
Stars
600
Forks
675
PR merge metrics
No merged PRs in 30d

Description

I wanted to get some high level discussion started around this, as I've heard feedback about it on both Slack and during the Contributor Summit. And I also struggled with this personally on many occasions.

I spent the last few hours trying the developer experience fresh (inside an empty Docker container, to make sure I get a clear slate). Currently, it's very difficult to get the project running locally.

This doesn't work:

```bash
npm install
npm run develop
# error: dist/static/files/component-versions.json not found
```

It seems bootstrapping is required (which isn't clear in the README or in the error message), but this, too, fails:

```bash
npm install
npm run bootstrap
npm run develop
# error: dist/static/samples/samples.json not found
```

The correct commands to run are this:
```bash
npm install
npm run bootstrap
npx gulp buildSamples
npm run develop
```

What also works is running `npm run develop` twice.

The main issues here are:
- Seems there's a race condition in `gulp develop` that prevents `samples.json` from being generated in time?
- Requiring a bootstrap means we require `AMP_DOC_TOKEN` which is not hard, but raises the bar to entry. Users unfamiliar with access tokens or bash will struggle with this (e.g. how to make that variable persist and the implications of storing it locally).
- Most of the error messages are unforgiving and confusing. Examples:
- The issues with `samples.json` or `component-versions.json` missing provide no additional information about how these files should be created / obtained.
- Not having an `AMP_DOC_TOKEN` set gives a clear error and points the user to the README. However, if the token is invalid, the error is `TypeError: Cannot read property 'tag_name' of undefined`.
- Anything going south with `gulp` will display `Did you forget to signal async completion?` with the actual error somewhere above.
- Grow errors are especially vague, e.g. `Error loading /content/amp-dev/documentation/examples/documentation/Stories_in_AMP.html` followed by a very long python stack trace.

Other issues:

- README.md is currently *very* verbose. There's instructions for all sorts of scenarios and things to do and this is overwhelming, especially for new contributors.
- For example, there's a very long section explaining how to install node and python on different platforms. Do we really need this? Can we link to an external guide about this? If not, can we at least move it to a separate file?
- `git config user.name` is called from [here](https://github.com/ampproject/amp.dev/blob/3be347aab4294d5790e83f31202b5aa99db0244b/platform/lib/utils/git.js#L21). This command fails if the username is not set, resulting in a confusing error when `npm install` is ran.
- If `grow` is not installed, the error `npm run develop` throws is confusing (`Grow had an error starting up. There probably is a brokendocument in the project. See the log above for details.`).
- When `grow` starts, it shows `Address: http://localhost:8081/` which is a lie. This is explained in the README, but... can we just hide this message?
- Bootstrapping generates unignored artifacts, which can be confusing (tracked in #3203).
- Missing `dist/static/samples/samples.json` doesn't actually stop `npm run develop`. The server still runs, but nothing can be opened.
- Killing `npm run develop` before it finishes building is likely to make subsequent attempts to run `npm run develop` fail with an error from grow about malformed files. I found no way to fix this state (e.g. `npx gulp clean` doesn't fix it) other than to fully nuke the repo and start over.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.