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

unable to build extension in Windows #398

Closed
AnweshGangula opened this issue Jun 11, 2023 · 3 comments
Closed

unable to build extension in Windows #398

AnweshGangula opened this issue Jun 11, 2023 · 3 comments

Comments

@AnweshGangula
Copy link
Contributor

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
Copy link
Contributor Author

AnweshGangula commented Jun 11, 2023

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

  • I updated the webpack.config.js to read the argument from the terminal - const target = env.TARGET ?? process.env.npm_config_target;
  • then I can run the command npm run build --target=chrome in the terminal to manually pass the target and for this to work

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

@AnweshGangula
Copy link
Contributor Author

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
Copy link
Contributor Author

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

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

No branches or pull requests

2 participants