lens icon indicating copy to clipboard operation
lens copied to clipboard

Unable to build binary for Windows locally

Open craph opened this issue 1 year ago • 11 comments

Hello @Nokel81 , @jim-docker,

To investigate on this issue https://github.com/lensapp/lens/issues/5887#issue-1316756632 I want to build Lens locally on my laptop but I'm unable to do it because of many issues. I haven't find any documentation that explains how to proceed as a contributor to run / debug and build Windows binaries correctly.

I have open an issue to the repo of electron-builder regarding my issue and I want to try their advice : https://github.com/electron-userland/electron-builder/issues/7025

Environment (please complete the following information):

  • Lens Version: tag 5.5.4 or should I take the master branch ?
  • OS: Windows 10 pro
  • Installation method (e.g. snap or AppImage in Linux): git clone

I have node in version 14.20.0 because in package.json you require node engine >=14 <15 and yarn in version 1.22.19 After cloning the repository, I open the lens folder with VSCode and open a terminal with Git Bash:

  • npm install
  • npm run build:win

And I got the following errors :

$ npm run build:win

> [email protected] build:win
> yarn run compile && electron-builder --win --dir

yarn run v1.22.19
$ env NODE_ENV=production concurrently yarn:compile:*
$ yarn run webpack --config webpack/main.ts
$ yarn run webpack --config webpack/extensions.ts
$ yarn run webpack --config webpack/renderer.ts
$ C:\Users\myuser\Downloads\lens-5.5.4\node_modules\.bin\webpack --config webpack/main.ts
$ C:\Users\myuser\Downloads\lens-5.5.4\node_modules\.bin\webpack --config webpack/extensions.ts
$ C:\Users\myuser\Downloads\lens-5.5.4\node_modules\.bin\webpack --config webpack/renderer.ts
[compile:*main] WEBPACK:main {
[compile:*main]   isDevelopment: false,
[compile:*main]   mainDir: 'C:\\Users\\myuser\\Downloads\\lens-5.5.4\\src\\main',
[compile:*main]   buildDir: 'C:\\Users\\myuser\\Downloads\\lens-5.5.4\\static\\build'
[compile:*main] }
[compile:*renderer] WEBPACK:renderer {
[compile:*renderer]   assetsFolderName: 'assets',
[compile:*renderer]   isDevelopment: false,
[compile:*renderer]   rendererDir: 'C:\\Users\\myuser\\Downloads\\lens-5.5.4\\src\\renderer',
[compile:*renderer]   buildDir: 'C:\\Users\\myuser\\Downloads\\lens-5.5.4\\static\\build',
[compile:*renderer]   appName: 'OpenLens',
[compile:*renderer]   htmlTemplate: 'C:\\Users\\myuser\\Downloads\\lens-5.5.4\\src\\renderer\\template.html',
[compile:*renderer]   publicPath: '/build/'
[compile:*renderer] }
[compile:*main] assets by status 409 KiB [cached] 1 asset
[compile:*main] orphan modules 421 KiB [orphan] 224 modules
[compile:*main] runtime modules 937 bytes 4 modules
[compile:*main] modules by path ../src/ 982 KiB
[compile:*main]   modules by path ../src/common/ 468 KiB 224 modules
[compile:*main]   modules by path ../src/main/ 412 KiB 90 modules
[compile:*main]   modules by path ../src/extensions/ 82.6 KiB 23 modules
[compile:*main]   modules by path ../src/renderer/ 17.7 KiB 4 modules
[compile:*main]   modules by path ../src/migrations/ 1.12 KiB
[compile:*main]     ../src/migrations/helpers.ts 807 bytes [built] [code generated]
[compile:*main]     ../src/migrations/utils.ts 341 bytes [built] [code generated]
[compile:*main] modules by path external "lodash/ 126 bytes
[compile:*main]   external "lodash/orderBy" 42 bytes [built] [code generated]
[compile:*main]   external "lodash/fp" 42 bytes [built] [code generated]
[compile:*main]   external "lodash/get" 42 bytes [built] [code generated]
[compile:*main] + 35 modules
[compile:*main]
[compile:*main] ERROR in src/renderer/routes/query-parameters.injectable.ts:7:43
[compile:*main] TS2307: Cannot find module 'query-string' or its corresponding type declarations.
[compile:*main]      5 | import { getInjectable } from "@ogre-tools/injectable";
[compile:*main]      6 | import { computed } from "mobx";
[compile:*main]   >  7 | import { parse as parseQueryString } from "query-string";
[compile:*main]        |                                           ^^^^^^^^^^^^^^
[compile:*main]      8 | import observableHistoryInjectable from "../navigation/observable-history.injectable";
[compile:*main]      9 |
[compile:*main]     10 | const queryParametersInjectable = getInjectable({
[compile:*main]
[compile:*main] lens-app-main (webpack 5.72.0) compiled with 1 error in 56005 ms
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
[compile:*main] yarn run compile:main exited with code 1
[compile:*renderer] assets by status 33.3 MiB [cached] 121 assets
[compile:*renderer] Entrypoint OpenLens = OpenLens.css OpenLens.js 1 auxiliary asset
[compile:*renderer] orphan modules 9.57 MiB (javascript) 1.74 MiB (asset) 257 KiB (runtime) [orphan] 3566 modules
[compile:*renderer] runtime modules 9.95 KiB 15 modules
[compile:*renderer] modules by path ./ 28.5 MiB (javascript) 229 KiB (css/mini-extract)
[compile:*renderer]   modules by path ./node_modules/ 25.1 MiB (javascript) 78.3 KiB (css/mini-extract)
[compile:*renderer]     javascript modules 24.6 MiB 2542 modules
[compile:*renderer]     css modules 78.3 KiB 69 modules
[compile:*renderer]     json modules 463 KiB 30 modules
[compile:*renderer]   modules by path ./src/ 3.44 MiB (javascript) 151 KiB (css/mini-extract)
[compile:*renderer]     modules by path ./src/renderer/ 2.8 MiB (javascript) 151 KiB (css/mini-extract) 707 modules
[compile:*renderer]     modules by path ./src/common/ 541 KiB 226 modules
[compile:*renderer]     modules by path ./src/extensions/ 103 KiB 31 modules
[compile:*renderer]     modules by path ./src/main/ 6.51 KiB 2 modules
[compile:*renderer]     modules by path ./src/migrations/ 1.12 KiB 2 modules
[compile:*renderer]   ./package.json 10.7 KiB [built] [code generated]
[compile:*renderer] + 26 modules
[compile:*renderer]
[compile:*renderer] WARNING in ./node_modules/chokidar/lib/fsevents-handler.js 9:13-32
[compile:*renderer] Module not found: Error: Can't resolve 'fsevents' in 'C:\Users\myuser\Downloads\lens-5.5.4\node_modules\chokidar\lib'
[compile:*renderer]  @ ./node_modules/chokidar/index.js 15:24-57
[compile:*renderer]  @ ./src/extensions/extension-discovery/extension-discovery.ts 14:0-33 209:8-13
[compile:*renderer]  @ ./src/extensions/extension-discovery/extension-discovery.injectable.ts 6:0-59 17:29-47
[compile:*renderer]  @ ./src/renderer/bootstrap.tsx 27:0-108 92:41-69
[compile:*renderer]
[compile:*renderer] 1 warning has detailed information that is not shown.
[compile:*renderer] Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
[compile:*renderer]
[compile:*renderer] ERROR in ./src/renderer/routes/query-parameters.injectable.ts 7:0-57
[compile:*renderer] Module not found: Error: Can't resolve 'query-string' in 'C:\Users\myuser\Downloads\lens-5.5.4\src\renderer\routes'
[compile:*renderer] resolve 'query-string' in 'C:\Users\myuser\Downloads\lens-5.5.4\src\renderer\routes'
[compile:*renderer]   Parsed request is a module
[compile:*renderer]   using description file: C:\Users\myuser\Downloads\lens-5.5.4\package.json (relative path: ./src/renderer/routes)
[compile:*renderer]     Field 'browser' doesn't contain a valid alias configuration
[compile:*renderer]     resolve as module
[compile:*renderer]       C:\Users\myuser\Downloads\lens-5.5.4\src\renderer\routes\node_modules doesn't exist or is not a directory
[compile:*renderer]       C:\Users\myuser\Downloads\lens-5.5.4\src\renderer\node_modules doesn't exist or is not a directory
[compile:*renderer]       C:\Users\myuser\Downloads\lens-5.5.4\src\node_modules doesn't exist or is not a directory
[compile:*renderer]       looking for modules in C:\Users\myuser\Downloads\lens-5.5.4\node_modules
[compile:*renderer]         single file module
[compile:*renderer]           using description file: C:\Users\myuser\Downloads\lens-5.5.4\package.json (relative path: ./node_modules/query-string)
[compile:*renderer]             no extension
[compile:*renderer]               Field 'browser' doesn't contain a valid alias configuration
[compile:*renderer]               C:\Users\myuser\Downloads\lens-5.5.4\node_modules\query-string doesn't exist
[compile:*renderer]             .js
[compile:*renderer]               Field 'browser' doesn't contain a valid alias configuration
[compile:*renderer]               C:\Users\myuser\Downloads\lens-5.5.4\node_modules\query-string.js doesn't exist
[compile:*renderer]             .jsx
[compile:*renderer]               Field 'browser' doesn't contain a valid alias configuration
[compile:*renderer]               C:\Users\myuser\Downloads\lens-5.5.4\node_modules\query-string.jsx doesn't exist
[compile:*renderer]             .json
[compile:*renderer]               Field 'browser' doesn't contain a valid alias configuration
[compile:*renderer]               C:\Users\myuser\Downloads\lens-5.5.4\node_modules\query-string.json doesn't exist
[compile:*renderer]             .ts
[compile:*renderer]               Field 'browser' doesn't contain a valid alias configuration
[compile:*renderer]               C:\Users\myuser\Downloads\lens-5.5.4\node_modules\query-string.ts doesn't exist
[compile:*renderer]             .tsx
[compile:*renderer]               Field 'browser' doesn't contain a valid alias configuration
[compile:*renderer]               C:\Users\myuser\Downloads\lens-5.5.4\node_modules\query-string.tsx doesn't exist
[compile:*renderer]         C:\Users\myuser\Downloads\lens-5.5.4\node_modules\query-string doesn't exist
[compile:*renderer]       C:\Users\myuser\Downloads\node_modules doesn't exist or is not a directory
[compile:*renderer]       C:\Users\myuser\node_modules doesn't exist or is not a directory
[compile:*renderer]       C:\Users\node_modules doesn't exist or is not a directory
[compile:*renderer]       C:\node_modules doesn't exist or is not a directory
[compile:*renderer]  @ ./src/renderer/ sync \.injectable\.(ts%7Ctsx)$ ./routes/query-parameters.injectable.ts
[compile:*renderer]  @ ./src/renderer/getDi.tsx 12:47-101
[compile:*renderer]  @ ./src/renderer/bootstrap.tsx 24:0-32 131:11-16
[compile:*renderer]
[compile:*renderer] ERROR in src/renderer/routes/query-parameters.injectable.ts:7:43
[compile:*renderer] TS2307: Cannot find module 'query-string' or its corresponding type declarations.
[compile:*renderer]      5 | import { getInjectable } from "@ogre-tools/injectable";
[compile:*renderer]      6 | import { computed } from "mobx";
[compile:*renderer]   >  7 | import { parse as parseQueryString } from "query-string";
[compile:*renderer]        |                                           ^^^^^^^^^^^^^^
[compile:*renderer]      8 | import observableHistoryInjectable from "../navigation/observable-history.injectable";
[compile:*renderer]      9 |
[compile:*renderer]     10 | const queryParametersInjectable = getInjectable({
[compile:*renderer]
[compile:*renderer] lens-app-renderer (webpack 5.72.0) compiled with 2 errors and 1 warning in 71625 ms
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
[compile:*renderer] yarn run compile:renderer exited with code 1
[compile:*extension-types] WARNING in ./node_modules/chokidar/lib/fsevents-handler.js 9:13-32
[compile:*extension-types] Module not found: Error: Can't resolve 'fsevents' in 'C:\Users\myuser\Downloads\lens-5.5.4\node_modules\chokidar\lib'
[compile:*extension-types]
[compile:*extension-types] ERROR in C:\Users\myuser\Downloads\lens-5.5.4\src\renderer\routes\query-parameters.injectable.ts
[compile:*extension-types] 7:42-56
[compile:*extension-types] [tsl] ERROR in C:\Users\myuser\Downloads\lens-5.5.4\src\renderer\routes\query-parameters.injectable.ts(7,43)
[compile:*extension-types]       TS2307: Cannot find module 'query-string' or its corresponding type declarations.
[compile:*extension-types]
[compile:*extension-types] webpack compiled with 1 error and 1 warning
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[compile:*extension-types] error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[compile:*extension-types] error Command failed with exit code 1.
[compile:*extension-types] yarn run compile:extension-types exited with code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

and if I try with powershell I have :

PS C:\Users\myuser\Downloads\lens-5.5.4> npm run build:win        

> [email protected] build:win
> yarn run compile && electron-builder --win --dir

yarn run v1.22.19
$ env NODE_ENV=production concurrently yarn:compile:*
ERROR env: CreateProcessA
Done in 0.12s.
  • electron-builder  version=23.0.3 os=10.0.19042
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist\builder-effective-config.yaml
  • rebuilding native dependencies  [email protected] platform=win32 arch=x64
  • packaging       platform=win32 arch=x64 electron=14.2.9 appOutDir=dist\win-unpacked
  • file source doesn't exist  from=C:\Users\myuser\Downloads\lens-5.5.4\locales
  • file source doesn't exist  from=C:\Users\myuser\Downloads\lens-5.5.4\binaries\client\windows\x64\kubectl.exe
  • file source doesn't exist  from=C:\Users\myuser\Downloads\lens-5.5.4\binaries\client\windows\x64\lens-k8s-proxy.exe
  • file source doesn't exist  from=C:\Users\myuser\Downloads\lens-5.5.4\binaries\client\windows\x64\helm.exe
  ⨯ Application entry file "static\build\main.js" in the "C:\Users\myuser\Downloads\lens-5.5.4\dist\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.  failedTask=build stackTrace=Error: Application entry file "static\build\main.js" in the "C:\Users\myuser\Downloads\lens-5.5.4\dist\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.
    at error (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\asar\asarFileChecker.ts:7:12)
    at Object.checkFileInArchive (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\asar\asarFileChecker.ts:31:11)
    at WinPackager.checkFileInPackage (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\platformPackager.ts:503:7)
    at WinPackager.sanityCheckPackage (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\platformPackager.ts:551:5)
    at WinPackager.doPack (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\platformPackager.ts:312:5)
    at WinPackager.pack (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\platformPackager.ts:136:5)
    at Packager.doBuild (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\packager.ts:441:9)
    at Object.executeFinally (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\builder-util\src\promise.ts:12:14)
    at Packager._build (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\packager.ts:376:31)
    at Packager.build (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\app-builder-lib\src\packager.ts:337:12)
    at Object.executeFinally (C:\Users\myuser\Downloads\lens-5.5.4\node_modules\builder-util\src\promise.ts:12:14)

And with make I have :

$ make build
make i info Invoking build target
make i info Invoking node_modules target
(node:516) UnhandledPromiseRejectionWarning: undefined
(Use `node --trace-warnings ...` to show where the warning was created)
(node:516) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:516) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
make × ERR  not found: make-yarn.lock

Can you enhance the documentation to explain how to proceed to build binaries for windows? and help me to proceed ?

Thank you very much for your help. Best regards,

craph avatar Jul 27 '22 17:07 craph

You need to run make build using git bash

Nokel81 avatar Jul 27 '22 17:07 Nokel81

You need to run make build using git bash

@Nokel81 with git bash and make build I have :

$ make build
make i info Invoking build target
make i info Invoking node_modules target
(node:516) UnhandledPromiseRejectionWarning: undefined
(Use `node --trace-warnings ...` to show where the warning was created)
(node:516) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:516) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
make × ERR  not found: make-yarn.lock

craph avatar Jul 27 '22 17:07 craph

@Nokel81 an idea ? I have make in version 0.8.1

craph avatar Jul 27 '22 17:07 craph

$ make --version
GNU Make 4.3
Built for Windows32
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Is what I have

Nokel81 avatar Jul 27 '22 18:07 Nokel81

$ make --version
GNU Make 4.3
Built for Windows32
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Is what I have

I have installed make like this : npm install -g make is that correct ?

craph avatar Jul 27 '22 18:07 craph

No not at all, make is a piece of software from GNU https://www.gnu.org/software/make/manual/html_node/Overview.html#Overview

It should be bundled with git bash already, if not there are tutorials online of how to upgrade it.

Nokel81 avatar Jul 27 '22 18:07 Nokel81

I changed the version of electron-builder to 23.3.3 in package.json but now I have the following error :

$ make build
yarn install --frozen-lockfile --network-timeout=100000
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
make: *** [Makefile:20: node_modules] Error 1

What is the correct command to solve this ? yarn install ? make "something" ?

craph avatar Jul 28 '22 06:07 craph

I ran yarn install and it update the file yarn.lock but I'm not sure it was the right command to run. After that, I ran : make build => success I tried to install OpenLens.exe generated with electron-builder in version 23.3.3 and it solved my issue the installer / uninstaller on Lens in version 5.5.4.

So I suggest you must update the electron-builder version to the latest one 23.3.3 to fix potential issues with NSIS setup. If you want I can create a MR but I need to know if I did the things correctly to update the electron-builder to the latest version ?

I changed the version of electron-builder to 23.3.3 in package.json but now I have the following error :

$ make build
yarn install --frozen-lockfile --network-timeout=100000
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
make: *** [Makefile:20: node_modules] Error 1

What is the correct command to solve this ? yarn install ? make "something" ?

craph avatar Jul 28 '22 06:07 craph

Yes, after adding/updating packages in package.json running yarn install is correct, then make build Thanks for digging into this, I don't see a reason not to upgrade electron-builder

jim-docker avatar Jul 28 '22 15:07 jim-docker

We rely on dependabot to bump such packages to new versions. It probably hasn't been bumped yet since electron-builder 23.3.3 is tagged as next. Once there is a new latest we should get it automatically. Or we'll bump it manually if this impacts a lot of users.

jim-docker avatar Jul 28 '22 16:07 jim-docker

Why I have this when I build OpenLens locally for Windows :

• file source doesn't exist  from=C:\Users\myuser\ws\lens-6.0.0\locales

craph avatar Jul 29 '22 06:07 craph

I can't build tag 6.0 either.

yarn check --verify-tree --integrity
[2K[1G[1myarn check v1.22.19[22m
[2K[1G[31merror[39m "@sentry/integrations#@sentry/types" is wrong version: expected "6.19.7", got "6.19.3"
[2K[1G[31merror[39m "jest#@jest/core#@jest/transform#@babel/core#@babel/helper-module-transforms#@babel/helper-module-imports" is wrong version: expected "^7.16.7", got "7.10.1"
[2K[1G[31merror[39m Found 2 errors.
[2K[1G[34minfo[39m Visit [1mhttps://yarnpkg.com/en/docs/cli/check[22m for documentation about this command.
make: *** [Makefile:21: node_modules] Error 1

I tried yarn install before running make build. but it did not help.

Jeansen avatar Aug 02 '22 17:08 Jeansen

file source doesn't exist from=C:\Users\myuser\ws\lens-6.0.0\locales

That is just a warning and shouldn't matter.

Nokel81 avatar Aug 05 '22 12:08 Nokel81

@Jeansen If yarn check fails I would blow away node_modules and reinstall.

Nokel81 avatar Aug 05 '22 12:08 Nokel81

Closing this as we have now upgraded to the version of electron builder.

Nokel81 avatar Aug 05 '22 12:08 Nokel81

@Jeansen If yarn check fails I would blow away node_modules and reinstall.

Master builds fine. Tag 6.0.0, too. I wasn't aware that I had to clean the modules folder. Thank you @Nokel81 smile I even do not need to run yarn install beforehand. simple make build will do.

Jeansen avatar Aug 07 '22 21:08 Jeansen