-
Notifications
You must be signed in to change notification settings - Fork 135
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
[Generator] Fix generator failing on Windows using WSL #385
Conversation
@@ -388,7 +388,7 @@ const extractTemplate = (templateName, outputDir) => { | |||
cwd: p.join(tmp), | |||
sync: true | |||
}) | |||
sh.mv(p.join(tmp, templateName), outputDir) | |||
sh.cp('-R', p.join(tmp, templateName), outputDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a summary of our discussion. I'd like to see some numbers showing whether or not this will be a significant slow down to project generation. Now that the delete command on line 392 will be deleting more than just an empty temp folder, I suspect that this kind of action can be relatively slow on windows machines specifically.
If it is, maybe we discuss not deleting it at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bendvc Time generating a project generator-shelljs-cp-to-extract-template
vs release-1.4.x
branch.
Steps to measure the time per branch:
- Using Windows Command line checkout branch.
git clean -dxf && npm ci
.set GENERATOR_PRESET=retail-react-app-demo
.- Run the
create-mobify-app.js
script. - Repeat the process 3 times.
Results:
generator-shelljs-cp-to-extract-template
branch
C:\Users\User\git\pwa-kit>timecmd.bat node packages/pwa-kit-create-app/scripts/create-mobify-app.js --outputDir ./preset-retail-react-app-demo
Installing dependencies for the generated project...
To change your ecommerce back end you will need to update your storefront configuration. More information: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/configuration-options
Successfully generated a project in ./preset-retail-react-app-demo
command took 0:0:59.11 (59.11s total)
C:\Users\User\git\pwa-kit>timecmd.bat node packages/pwa-kit-create-app/scripts/create-mobify-app.js --outputDir ./preset-retail-react-app-demo
Installing dependencies for the generated project...
To change your ecommerce back end you will need to update your storefront configuration. More information: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/configuration-options
Successfully generated a project in ./preset-retail-react-app-demo
command took 0:0:52.47 (52.47s total)
C:\Users\User\git\pwa-kit>timecmd.bat node packages/pwa-kit-create-app/scripts/create-mobify-app.js --outputDir ./preset-retail-react-app-demo
Installing dependencies for the generated project...
To change your ecommerce back end you will need to update your storefront configuration. More information: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/configuration-options
Successfully generated a project in ./preset-retail-react-app-demo
command took 0:0:53.28 (53.28s total)
release-1.4.x
branch
C:\Users\User\git\v2-pwa-kit>timecmd.bat node packages/pwa-kit-create-app/scripts/create-mobify-app.js --outputDir ./preset-retail-react-app-demo
Installing dependencies for the generated project (this can take a while)
Successfully generated a project in ./preset-retail-react-app-demo
command took 0:0:59.40 (59.40s total)
C:\Users\User\git\v2-pwa-kit>timecmd.bat node packages/pwa-kit-create-app/scripts/create-mobify-app.js --outputDir ./preset-retail-react-app-demo
Installing dependencies for the generated project (this can take a while)
Successfully generated a project in ./preset-retail-react-app-demo
command took 0:0:54.47 (54.47s total)
C:\Users\User\git\v2-pwa-kit>timecmd.bat node packages/pwa-kit-create-app/scripts/create-mobify-app.js --outputDir ./preset-retail-react-app-demo
Installing dependencies for the generated project (this can take a while)
Successfully generated a project in ./preset-retail-react-app-demo
command took 0:0:57.39 (57.39s total)
GUS: https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00000m7lbMYAQ/view
Description
The generator fails to create a project on Windows when running the App Generator
npx pwa-kit-create-app
using Windows Subsystem for Linux (WSL) from the Windows drive file system folder mounted in/mnt/c
or/mnt/<LOGIC_UNIT>
.The root of the issue seems to be a lack of permissions on the WSL command line to manipulate the Windows drive temporal folder
/tmp/
.The
extractTemplate
function in the App generator tries to move a folder inside the OS temporal directory/tmp/
to the final directory. The generator process fails due to a lack of permissions.This PR replaces the
shelljs.mv()
method with the alternativeshelljs.cp()
method and its-R
recursively option to copy the template files from the OS temporal director to the final output directory.Limitations of using WSL to run processes from Windows drive file system folder mounted in
/mnt/c
The project is now generated successfully, and the project start and works properly when running
npm start
.However, we start to see other issues related to running processes using WSL from the Windows drive file system folder mounted in
/mnt/c
.Like these Webpack watch errors that don't have a proper solution other than not running process from the Windows drive file system when using WSL.
Related Webpack thread: webpack/watchpack#187 (comment)
Types of Changes
Changes
How to Test-Drive This PR
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
cd /mnt/c
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization