NativePHP / laravel

Laravel wrapper for the NativePHP framework
https://nativephp.com
MIT License
3.24k stars 167 forks source link

[Bug]: `native:build` command failed #91

Closed hasanuzzamanbe closed 7 months ago

hasanuzzamanbe commented 1 year ago

What happened?

php artisan native:build command executed laravel/sanctum ....................................................... DONE laravel/tinker ........................................................ DONE nativephp/electron .................................................... DONE nativephp/laravel ..................................................... DONE nesbot/carbon ......................................................... DONE nunomaduro/termwind ................................................... DONE

then exit with this error "electron-vite: command not found"

How to reproduce the bug

  1. Install php artisan native:install
  2. build php artisan native:build then exit with this error "electron-vite: command not found"

Package Version

0.2.0

PHP Version

8.1

Laravel Version

10.10

Node Version

14.20.1

Which operating systems does with happen with?

macOS

Notes

No response

Kuharenko commented 1 year ago

With latest version nativephp/electron (0.3.2) I call: php artisan native:build mac

It generates me .dmg file. Also I copied vendor/nativephp/php-bin/bin/mac/arm64 to vendor/nativephp/php-bin/bin/mac/x64

maiconrcf commented 1 year ago

When i run on my macOS the command : php artisan native:build mac all my packages are removed and without .dmg file.

hasanuzzamanbe commented 1 year ago

With latest version nativephp/electron (0.3.2) I call: php artisan native:build mac

It generates me .dmg file. Also I copied vendor/nativephp/php-bin/bin/mac/arm64 to vendor/nativephp/php-bin/bin/mac/x64

I tried then it throw errors like this Error copying PHP binary Error: ENOENT: no such file or directory, stat '/Volumes/Projects/debugger/vendor/nativephp/php-bin/bin/mac/x64'

Could not resolve "../../resources/php/php?asset&asarUnpack" from "src/main/index.js"

image
hasanuzzamanbe commented 1 year ago

After a quick debugging, I am able to build the package for macOS. PHP binary for x64 was not present on the path it was looking for. Don't know why it was not created automatically. I copied it from the Linux directory and paste it into the mac directory. And it works.

image
lotestudio commented 1 year ago

Same here...

simonhamp commented 1 year ago

I copied it from the Linux directory and paste it into the mac directory.

I'm not quite sure how this works, but I'd be very cautious about this as the binaries are built for each platform and won't be 100% interchangeable - something you'd absolutely want to avoid when it comes to distributing your app.

@hasanuzzamanbe Based on what you've reported, I'm assuming that you're developing on an Intel Mac... is that correct?

eqxDev commented 1 year ago

Same issue here, tried your fix it did actually open this time but with an error Test.app/Contents/Resources/app.asar.unpacked/resources/php/php EACCES at ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Almost worked then!

SRWieZ commented 1 year ago

With latest version nativephp/electron (0.3.2) I call: php artisan native:build mac

I tried then it throw errors like this

Error copying PHP binary Error: ENOENT: no such file or directory, stat '/Volumes/Projects/debugger/vendor/nativephp/php-bin/bin/mac/x64'

Could not resolve "../../resources/php/php?asset&asarUnpack" from "src/main/index.js"

Just to give my feedback too. I got the same error on Intel Mac. Tried on the last 2 releases, same behavior.

code05-hello commented 1 year ago

same here

error during build: RollupError: Could not resolve "../../resources/php/php?asset&asarUnpack" from "src/main/index.js" at error (file:///Users/ktech/code/phpnative/phpnative/vendor/nativephp/electron/resources/js/node_modules/rollup/dist/es/shared/node-entry.js:2245:30) at ModuleLoader.handleInvalidResolvedId (file:///Users/ktech/code/phpnative/phpnative/vendor/nativephp/electron/resources/js/node_modules/rollup/dist/es/shared/node-entry.js:24736:24) at file:///Users/ktech/code/phpnative/phpnative/vendor/nativephp/electron/resources/js/node_modules/rollup/dist/es/shared/node-entry.js:24698:26

hasanuzzamanbe commented 1 year ago

I copied it from the Linux directory and paste it into the mac directory.

I'm not quite sure how this works, but I'd be very cautious about this as the binaries are built for each platform and won't be 100% interchangeable - something you'd absolutely want to avoid when it comes to distributing your app.

@hasanuzzamanbe Based on what you've reported, I'm assuming that you're developing on an Intel Mac... is that correct?

Sorry it was "Apple M1 Pro" chip

code05-hello commented 1 year ago

Yes, Mac based on intel i3 processor

avazquez-bit commented 7 months ago

I have same issue working on linux an traying to build to linux, win and mac, even wothout parameter the output is the same 2024-04-30_12-22

In another device with windows before update, I was able to build, the app does not show any window but at least it could be build, after update I got the same issue on windows too.

SRWieZ commented 7 months ago

Had the same error with a composer update

Just updated nativephp/electron from 4.0 to 6.0 and this whole issue is fixed! 🎉

Did you tried to update nativephp ? composer require nativephp/electron

avazquez-bit commented 7 months ago

It work, but now i got image

simonhamp commented 7 months ago

Looks like some step is missing or skipped where it should try to install the latest set of NPM dependencies

simonhamp commented 7 months ago

Please note that you can't build for Mac when you're not on a Mac

avazquez-bit commented 7 months ago

I've droped node_modules and vendor folders and reinstall them and it work. then i tried to build for linux and even when the app is created and actually it work, I got next console messages

image

Now i'll try to build for windows on windows whit this updates

Thanks!!!

simonhamp commented 7 months ago

That seems to be an error within electron-builder. Not sure what it means exactly, but it seems it might be bypass-able (if I'm interpreting the message correctly)

I'll try to replicate it at some point and find a way to bounce past it, but it would be helpful to raise that as a separate issue as it's off-track from this thread.

avazquez-bit commented 7 months ago

Ok, I'll put on new one!!! Thanks

simonhamp commented 7 months ago

For everyone else: there have been a load of improvements to NativePHP recently.

Please update to nativephp/electron v0.6 and try again.