karlicoss / promnesia

Another piece of your extended mind
https://beepb00p.xyz/promnesia.html
MIT License
1.74k stars 74 forks source link

unable to build extension in Windows #398

Closed AnweshGangula closed 1 year ago

AnweshGangula commented 1 year ago

I'm running the build command (py build --chrome) in my Windows PC and I'm getting the following error

Could not find platform independent libraries <prefix>
Traceback (most recent call last):
  File "C:\Users\AnweshGangula\Downloads\promnesia\extension\build", line 119, in <module>
    main()
  File "C:\Users\AnweshGangula\Downloads\promnesia\extension\build", line 64, in main
    check_call([
  File "C:\Users\AnweshGangula\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 408, in check_call
    retcode = call(*popenargs, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AnweshGangula\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 389, in call
    with Popen(*popenargs, **kwargs) as p:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AnweshGangula\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\AnweshGangula\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
AnweshGangula commented 1 year ago

Turns out the python ./build is not able to identify the executable. I tried to debug this, but could not spend too much time on this.

Instead I ran the npm run build script directly, but it didn't work since the parameter target in the webpack.config.js file was being passed by the python ./build file.

Debugging this was fairly simple

But this isn't a solution, rather a workaround.

AnweshGangula commented 1 year ago

found the solution for the issue with ./build --chrome. the check_call command should specify shell = True for the command to work properly.

check_call([
    'npm', 'run', 'build',
], env=env, shell=True, cwd=str(Path(__file__).absolute().parent))

But it also points to another resource which says that for Windows, adding shell=True is not the right approach, instead the check_call command should be:

check_call([
    'npm.cmd', 'run', 'build',
], env=env, cwd=str(Path(__file__).absolute().parent))
AnweshGangula commented 9 months ago

Along with the above changes, I also had to disable the App Installer of python.exe and python3.exe in the "App Execution aliases" in windows for the command py build --chrome to work in terminal. Without the above change I got the following error:

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

Reference: https://stackoverflow.com/a/68215805/6908282