-
Notifications
You must be signed in to change notification settings - Fork 55
Always use LOCALAPPDATA to generate Windows CLI install path #2465
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
base: trunk
Are you sure you want to change the base?
Conversation
|
This Sentry issue confirms our theory. It was triggered by me and the error message reads: |
| if ( ! process.env.LOCALAPPDATA ) { | ||
| throw new Error( 'LOCALAPPDATA environment variable is not set' ); | ||
| } |
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.
An obvious question is, how do we know that process.env.LOCALAPPDATA is defined? Well, there's no official guarantee, and I can't find any Microsoft documentation on this, but it appears the system sets this variable for each process. It's not editable by users either, AFAICT. That's probably as good a guarantee as we'll get.
Still, it makes sense to ensure that we handle errors thrown from here gracefully, so I'll take a look at that now…
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.
Done in b942405
📊 Performance Test ResultsComparing 61e372a vs trunk site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change |
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.
This LGTM and I can consistently see the toggle working correctly now, both on Parallels and on x64. 👍
When trying to open a Command Prompt using the button on the site details page, I see an Access denied message when I try to use the studio command.
Opening a new tab and using the command in a different directory also prints the same message:
The contents of the bat file seems correct to me, I think the issue might be that we don't have rights to run the batch file under WindowsApps:
@echo off
"C:\Program Files\WindowsApps\22490Automattic.StudiobyWordPress.com_1.6.8.0_arm64__9qb1eemr42qj0\app\resources\bin\studio-cli.bat" %*
That seems like a good theory. We probably lack permission to execute that file (but we can read it). I'm not immediately sure what the best way to solve that is… |
Related issues
Proposed Changes
As noted by @gcsecsey in #2463 (comment), CLI installation doesn't work when the app was installed using an AppX installer on Windows.
When Studio installs the CLI on Windows, it writes a "proxy
studio.batfile" to a directory relative to its installation directory (as determined by the value Electron returns fromapp.getPath( 'exe' ). However, Microsoft Store installs Studio in a directory likeC:\Program Files\WindowsApps\22490Automattic.StudiobyWordPress.com_1.6.8.0_arm64__9h07f78gwnchpthat has heavy read and write limitations. Therefore, we believe the CLI installation fails because Studio cannot write the file.This PR solves the problem by always writing the proxy batch file to a known stable location in
%LOCALAPPDATA%.Testing Instructions
I haven't figured out how to install an AppX dev build on Windows, so code review might have to suffice
Pre-merge Checklist