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

Failed to compile: Unexpected end of JSON input when installing Alloy #105

Closed
kerak19 opened this issue Nov 13, 2024 · 8 comments · Fixed by #106
Closed

Failed to compile: Unexpected end of JSON input when installing Alloy #105

kerak19 opened this issue Nov 13, 2024 · 8 comments · Fixed by #106

Comments

@kerak19
Copy link

kerak19 commented Nov 13, 2024

Hi. While installing Alloy on MacOS with the guide available at https://grafana.com/docs/alloy/latest/set-up/install/macos/ I've encountered an issue; the installation fails with following details:

brew install grafana/grafana/alloy
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Fetching grafana/grafana/alloy
==> Downloading https://github.com/grafana/alloy/archive/refs/tags/v1.5.0.tar.gz
Already downloaded: /Users/lukasz/Library/Caches/Homebrew/downloads/4bf992ce5c20569d3810b62b73e547fb1490d7f766881219f1cc870edb60915f--alloy-1.5.0.tar.gz
==> Installing alloy from grafana/grafana
==> yarn
==> yarn run build
Last 15 lines from /Users/lukasz/Library/Logs/Homebrew/alloy/02.yarn:
$ react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
Failed to compile.

Unexpected end of JSON input


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/grafana/homebrew-grafana/issues
Full content of yarn 2024-11-13 15:09:43 +0000

yarn
run
build

yarn run v1.22.22
$ react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
Failed to compile.

Unexpected end of JSON input

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

HOMEBREW_VERSION: 4.4.5
ORIGIN: https://github.com/Homebrew/brew
HEAD: 254bf3fe9d8fa2e1b2fb55dbcf535b2d870180c4
Last commit: 2 days ago
Core tap JSON: 13 Nov 15:09 UTC
Core cask tap JSON: 13 Nov 15:09 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 12
HOMEBREW_NO_BOOTSNAP: set
Homebrew Ruby: 3.3.6 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: dodeca-core 64-bit arm_lobos
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.0.1-arm64
CLT: 16.0.0.0.1.1724870825
Xcode: N/A
Rosetta 2: false

HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
MAKEFLAGS: -j12
CMAKE_PREFIX_PATH: /opt/homebrew/opt/[email protected]:/opt/homebrew
CMAKE_INCLUDE_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers
CMAKE_LIBRARY_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/15
HOMEBREW_MAKE_JOBS: 12
HOMEBREW_GIT: git
HOMEBREW_SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
ACLOCAL_PATH: /opt/homebrew/share/aclocal
PATH: /opt/homebrew/Library/Homebrew/shims/mac/super:/opt/homebrew/opt/[email protected]/bin:/opt/homebrew/opt/node/bin:/opt/homebrew/opt/yarn/bin:/usr/bin:/bin:/usr/sbin:/sbin

@thampiotr
Copy link
Contributor

Hey! did it work when you retried or does the issue persist?

@kerak19 kerak19 changed the title Failed to compile: Unexpected end of JSON input Failed to compile: Unexpected end of JSON input when installing Alloy Nov 13, 2024
@kerak19
Copy link
Author

kerak19 commented Nov 13, 2024

I wasn't able to fix that yet. I've tried removing the cask and installing again. ATM I've downloaded the release and ran the binary

@PeterBowater
Copy link

Same issues here, MacOS 15.0.1, 2019 Intel.

@thampiotr
Copy link
Contributor

thampiotr commented Nov 14, 2024

Investigated this a bit and found that it's something unrelated to our recent release of v1.5.0 - it seems to be broken even on v1.0.0 - likely the node / yarn / react build is not reproducible and fails with some dependency:

$ git checkout tags/v1.0.0
Note: switching to 'tags/v1.0.0'.
...
$ git log | head
commit 1eef9b3ae92cb806181dc6ad39a660864f778764
Author: Robert Fratto <[email protected]>
Date:   Fri Apr 5 15:48:59 2024 -0400

    ci: fix windows image tags (#137)

    Aligns tags with Linux.
...
$ cd internal/web/ui/
$ yarn run build
yarn run v1.22.22
$ react-scripts build
Creating an optimized production build...
Failed to compile.

Unexpected end of JSON input


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The react project failing to build is here: https://github.com/grafana/alloy/tree/main/internal/web/ui

@thampiotr
Copy link
Contributor

I've managed to get to this stacktrace with the debugger, but I wasn't able to figure out what JSON is failing to parse.

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at ConcatenationScope.matchModuleReference (/Users/thampiotr/workspace/alloy/internal/web/ui/node_modules/webpack/lib/ConcatenationScope.js:148:13)
    at ConcatenatedModule.codeGeneration (/Users/thampiotr/workspace/alloy/internal/web/ui/node_modules/webpack/lib/optimize/ConcatenatedModule.js:1202:41)
    at /Users/thampiotr/workspace/alloy/internal/web/ui/node_modules/webpack/lib/Compilation.js:3332:22
    at /Users/thampiotr/workspace/alloy/internal/web/ui/node_modules/webpack/lib/Cache.js:85:6
    at /Users/thampiotr/workspace/alloy/internal/web/ui/node_modules/webpack/lib/Cache.js:39:11
    at /Users/thampiotr/workspace/alloy/internal/web/ui/node_modules/webpack/lib/cache/IdleFileCachePlugin.js:77:9
    at /Users/thampiotr/workspace/alloy/internal/web/ui/node_modules/webpack/lib/Cache.js:88:6
    at eval (eval at create (/Users/thampiotr/workspace/alloy/internal/web/ui/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:30:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

If anyone has any further ideas, that would be great help.

yarn cache clean; rm -rf ./node_modules/; yarn install; yarn run build didn't help either

Interestingly, this is reported to build fine on Windows.

@thampiotr
Copy link
Contributor

This could be related to nodejs/node#55826
Reportedly, on node 20 it works, on node 23 it fails.

@thampiotr
Copy link
Contributor

We have merged a PR with a fix to pin to previous Node version. Can you test?

@kerak19
Copy link
Author

kerak19 commented Nov 14, 2024

Confirmed it works now 🎉 Thanks

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

Successfully merging a pull request may close this issue.

3 participants