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

Add Windows setup script #403

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

headquarter8302
Copy link
Contributor

This PR (which now uses the correct base branch) adds a Windows-specific setup script located in dev/windows/setup.ps1 using PowerShell.

The script's actions is as follows:

  1. Create the variables $phpDir and $fullPhpDir
  2. Asks for the PHP install directory, because it isn't standardized in Windows
  3. Checks if the given path exists
  4. Checks if the PHP executable exists
  5. If the script was started in the dev/windows folder, go to the project root
  6. Create the variables $composerInstallerUrl and $composerInstallerPath
  7. Downloads composer's installer using the two variables aforementioned
  8. Checks if composer exists after the download
  9. Runs composer's installer using the PHP in $fullPhpDir
  10. Runs the install command from composer to install dependencies
  11. Cleans up the downloaded installer

Copy link
Contributor

@rubiefawn rubiefawn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have yet to test it, but I did look over the changes and left a few non-blocking suggestions (they should not prevent this PR from getting merged). I'll approve it once I have tested it.

@headquarter8302
Copy link
Contributor Author

Added a whole lot of .ini validation stuff. Works with nearly all but the most extreme edge cases on my machine

@rubiefawn
Copy link
Contributor

Tested this as well on my Windows partition that was not set up at all to do dev work (with php installed through choco, that is lmao) and the script just works! Fantastic job!

@tresf
Copy link
Member

tresf commented Mar 27, 2025

I was going to install WAMP but the website creeped me out, so I used choco per @rubiefawn's steps. This is a really cool script.

Some issues:

  1. It never yelled at me to fix my php.ini file.
  2. I fixed it anyway but before I did I received some warnings (also screenshotted below):
    Failed to download symfony/deprecation-contracts from dist: The zip extension and unzip/7z commands are both missing, skipping.
    The php.ini used by your command-line PHP is: C:\tools\php84\php.ini
        Now trying to download from source
    
  3. The website still will not run, it says pear is missing (also screenshotted below):
    Warning: Unknown: Failed to open stream: Permission denied in Unknown on line 0
    Fatal error: Failed opening required '.\public\' (include_path='.;C:\php\pear') in Unknown on line 0
    

(I don't think this is relevant, but I'm running this all through x64 emulation using Prism)

zip image

@headquarter8302
Copy link
Contributor Author

I was going to install WAMP but the website creeped me out, so I used choco per @rubiefawn's steps. This is a really cool script.

Some issues:

  1. It never yelled at me to fix my php.ini file.
  2. I fixed it anyway but before I did I received some warnings (also screenshotted below):
    Failed to download symfony/deprecation-contracts from dist: The zip extension and unzip/7z commands are both missing, skipping.
    The php.ini used by your command-line PHP is: C:\tools\php84\php.ini
        Now trying to download from source
    
  3. The website still will not run, it says pear is missing (also screenshotted below):
    Warning: Unknown: Failed to open stream: Permission denied in Unknown on line 0
    Fatal error: Failed opening required '.\public\' (include_path='.;C:\php\pear') in Unknown on line 0
    

(I don't think this is relevant, but I'm running this all through x64 emulation using Prism)

zip image

Yeah, looks like you're missing some of the common dependencies that otherwise Composer would use.

You also possibly have permission/access restrictions that makes Composer fail reading/writing to directories.

I'll see if I can include dependency and access checks in the script

@headquarter8302
Copy link
Contributor Author

@tresf I figured out that the permission error on the second screenshot is due to PHP trying to run at its directory instead of /lmms.io's base dir due to the include_path setting being set to a fixed path instead of the current working directory, which probably is write-protected. Unfortunately, the best that I can do with this is to warn the user that PHP functions will try to access that directory instead of CWD, since changing that will probably break existing PHP installs or other PHP apps

@headquarter8302 headquarter8302 requested a review from tresf March 29, 2025 14:33
@tresf
Copy link
Member

tresf commented Mar 29, 2025

include_path setting being set to a fixed path instead of the current working directory, which probably is write-protected.

So... Just cd to public first or will that not fix this? Furthermore, why wouldn't the include path be configurable at runtime? Is that not a thing?

Invoke-WebRequest -Uri $composerInstallerUrl -OutFile $composerInstallerPath
function Setup-Composer {
# shift to root dir
if ($pwd -match "(\\dev\\windows)") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... Probably best to get the script path and cd up twice rather than rely on string comparisons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So use $PSScriptRoot instead of $pwd? We're still trying to detect if the user started the script in the \dev\windows directory instead of the base dir

Copy link
Member

@tresf tresf Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're still trying to detect if the user started the script in the \dev\windows directory instead of the base dir

Yes however it doesn't matter where they start the script if everything is setup relative to its location.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, on it

@headquarter8302 headquarter8302 requested a review from tresf March 30, 2025 03:47
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

Successfully merging this pull request may close these issues.

3 participants