digidem / mapeo-desktop

Local-first mapping and monitoring in remote environments
https://mapeo.app
GNU General Public License v3.0
261 stars 33 forks source link

Mapeo Desktop Installer doesn't run on 32bit machines #305

Closed arky closed 4 years ago

arky commented 4 years ago

Trying to run the Mapeo Desktop (5.x) installer on 32 bit Windows 10 Pro machines results in '64-bit Windows is required' message. I have tested multiple versions of latest installers.

DSC_0149 DSC_0150

Most NGO/CSO organization have legacy machines hence the need for 32bit installers. I had managed to download and install Atom editor installer on this machine to check if electronJS applications are supported.

arky commented 4 years ago

@okdistribute Testing windows artifact from build 5843279 and build 58488207 results in following error on Windows 32 machine. DSC_0001

okdistribute commented 4 years ago

I was able to get more information by using asar: false in the windows build:

Looks like the issue is with leveldown. We are one of the 1.9% here that need to create our own build.. https://github.com/Level/leveldown/issues/554 Screenshot from 2020-03-19 20-54-40

arky commented 4 years ago

@okdistribute Yup, That reminds me that I had to rebuild leveldown package before building mapeo-desktop on 32bit machines.

okdistribute commented 4 years ago

@arky what did you type to rebuild?

arky commented 4 years ago

To build mapeo-desktop on 32bit machine you had rebuild leveldown without 64-bit flag.

"cd node_modules/leveldown && cross-env HOME=~/.electron-gyp node-gyp rebuild --target=2.0.7 --runtime=electron --dist-url=https://atom.io/download/atom-shell

Please refer to this bug https://github.com/digidem/mapeo-desktop/issues/237

vweevers commented 4 years ago

Which version of leveldown are y'all on? The above command suggests on older version.

On latest leveldown (5.x) there should be no need to rebuild. If node is 32-bit, then on npm install leveldown will see that it has no bundled prebuild for windows 32-bit and fallback to compilation. The resulting build is compatible with both node and electron.

okdistribute commented 4 years ago

@vweevers Thanks for responding. I realize now that you're right, we updated to leveldown 5.x since #237 was filed.

That's what I thought but still running into issues... I've been doing this on GitHub Actions and experimenting on this PR

okdistribute commented 4 years ago

@vweevers okay, doing this it seems to not have rebuilt leveldown, and says it can't find a native build for win32 Screenshot from 2020-03-20 11-29-23

I noticed here in the log for this build that electron-builder is rebuilding native modules for leveldown, but I wonder if that's failing silently?

vweevers commented 4 years ago

Could be, because those electron tools are geared towards the older node-pre-gyp and prebuild-install. I don't know if they support leveldown's setup.

I've got a Windows machine and can maybe help, given some instructions on how to get started on mapeo-desktop.

okdistribute commented 4 years ago

@vweevers thanks, that would be great. We're a small team and non-profit so any help is greatly appreciated. Mapeo Desktop should work out of the box with npm install, npm run watch in a new terminal window or npm run build for one-time front-end build, and npm run dev https://github.com/digidem/mapeo-desktop/#getting-started

vweevers commented 4 years ago

With:

$ node -v
v12.11.1
$ node -p process.arch
ia32
$ git branch
* master

I see that npm install correctly compiles leveldown.

There's also a postinstall script that (deep breath) runs electron-builder install-app-deps which in turn spawns node_modules/app-builder-bin/win/ia32/app-builder.exe rebuild-node-modules which is written in Go and effectively spawns npm rebuild leveldown@5.5.1 ... which calls the install script of leveldown. Which doesn't do anything, because it previously compiled and doesn't check whether that build is compatible with the target runtime. I'll get back to that.

TLDR, electron-builder install-app-deps doesn't do anything (at least for leveldown) but at this point in time we still have a leveldown build that happens to be compatible with Electron.

The npm run build and npm run dev commands also work, and I see a LevelDB db getting created on disk, so leveldown is correctly loaded.

Next up is packaging; I'll try that in your 32bit-builds branch.

vweevers commented 4 years ago

@okdistribute After running npm run dist (in the 32bit-builds branch) how can I launch Mapeo? Can I simply open dist/win-ia32-unpacked/Mapeo.exe or is that not a realistic test and should I instead run the installer exe?

Side note: the 32bit-builds branch has this (overly helpful) error:

$ npx electron-builder --ia32
  • electron-builder  version=21.2.0 os=10.0.18362
  • loaded configuration  file=package.json ("build" field)
  ⨯ Package "electron-rebuild" is only allowed in "devDependencies". Please remove it 
      from the "dependencies" section in your package.json.
vweevers commented 4 years ago

The 32-bit leveldown build correctly gets included in win-ia32-unpacked/resources/app/node_modules/.. and Mapeo.exe works - but it created registry keys so I ran the installer anyway to have the uninstaller cleanup those keys afterwards.

And... the installed Mapeo also works!

It stops working when I re-enable asar though. Another problem is that npm run dist builds both --x64 and --ia32, and because it doesn't rebuild leveldown, you'd have to separate that into two CI jobs or npm scripts.

vweevers commented 4 years ago

Given the amount of tools involved, it might take some time and thought to properly fix rebuilding. So I'm leaning towards just adding a 32-bit prebuild to leveldown (and making note of the issues elsewhere).

okdistribute commented 4 years ago

Thanks so much for investigating.

Adding 32-bit builds to leveldown will really help the electron ecosystem!

okdistribute commented 4 years ago

This will be fixed in the next release, but you can try it now in this build https://github.com/digidem/mapeo-desktop/actions/runs/67706742

arky commented 4 years ago

@okdistribute Tested on windows 32 bit machine. Works like a charm.

vweevers commented 4 years ago

Given the amount of tools involved, it might take some time and thought to properly fix rebuilding.

Update (FYI): node-gyp-build now respects the electron-builder buildDependenciesFromSource option (https://github.com/prebuild/node-gyp-build/pull/30).

okdistribute commented 4 years ago

nice thanks @vweevers !