-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix and improve WSL process #1949
Conversation
Should be in the users home directory, not root
Just like other php versions
They do the same thing, prevent copy/pasting and what not
nginx didn't allow to restart as the restart command was in a loop and resulted in ``` Feb 03 15:09:01 systemd[1]: Failed to start A high performance web server and a reverse proxy server. Feb 03 15:09:01 systemd[1]: nginx.service: Start request repeated too quickly. Feb 03 15:09:01 systemd[1]: nginx.service: Failed with result 'exit-code'. ``` So just restart once at the end :)
What's the plan with this PR? Actually I am working on more features for WSL provisioning, and all these changes seems to make sense. If there isn't any plan to merge this PR soon I will copy these changes to my branch manually. Note that there are few conflicts to be fixed. |
Without this PR homestead + WSL simply doesn't work properly, so it's kinda priority in my eyes and wanna see this merged in asap Then you also can pull it into your fork and work on the provisioning more @karmendra PS: solved the merge conflict |
@MichaelBelgium I've noticed another discrepancy in wsl-init: MySQL isn't being installed. The issue arises because there's currently no script to handle MySQL installation afterward. My understanding, based on the Vagrant installation and the settlers amd64.sh, is that Vagrant provisions with MySQL by default. If a user later updates the Homestead.yaml file to install MariaDB, it then uninstalls MySQL and installs MariaDB instead. In light of this, I propose two potential solutions: We maintain the current behavior in wsl-init by including MySQL installation. What are your thoughts? |
@karmendra Yeah correct, wsl-init expects mysql already being installed before running the file itself Line 151 in 5125ef3
I changed that in this PR to execute the mariadb.sh feature bash file but it's in there too homestead/scripts/features/mariadb.sh Line 27 in 5125ef3
I assume the command will fail but provisioning will not
These separate feature (bash) files are extremely useful for WSL provisioning to be honest. Eg I saw that the mailpit feature got removed (#1933) because - just like mysql - it's included in the vagrant base box, but what if i want mailpit in WSL? I can't because the script is gone. (Ofcourse i can manually grab said mailpit script, and it would work tho after changing homestead yml) Perhaps there needs to be a decision whether or not the included base box features should be a seperate feature script (again). Just because homestead users are not only using vagrant now. My initial thought is putting mysql as a feature/script, calling that bash file from wsl-init as default database engine. Or hear me out .... perhaps asking the user which database technology in the wsl-init script and then running the mysql or mariadb script accordingly The behaviour to remove mysql or mariadb could be included in the mariadb or mysql file. We can check if mysql feature or mariadb feature is installed and if so, remove it Like so: if [ -f /home/$WSL_USER_NAME/.homestead-features/mysql]; then
apt-get -o Dpkg::Options::="--force-confnew" remove -y --purge mysql-server mysql-client
apt-get autoremove -y
apt-get autoclean
rm -rf /var/lib/mysql/*
rm -rf /var/log/mysql
rm -rf /etc/mysql
fi
|
I believe MySQL should be included in the wsl-init script, as it's part of the default software list in the documentation. We can also add a feature script (mysql.sh) for users who wish to switch from MariaDB back to MySQL. If you refer to the settlers/amd64.sh script, you'll notice that MySQL is installed by default. According to the Laravel documentation for Homestead, the list of default packages installed in Homestead is outlined here. Currently, WSL does not install the following software, and users need to be aware of it. We should provide an option to install these as features eventually by writing feature installation scripts:
Taking all this into consideration, I will update the wsl-init script to include MySQL by default, instead of MariaDB, and also create a feature script to install MySQL later. |
@svpernova09 |
Apologies I've not had time to get to this. ETA would be late next week. |
No problem at all, it's great to hear from you. |
Fine for me! Creating the feature script and let wsl init call that script will be the cleanest
What we're doing about mysql <> mariadb, we're gonna have to do the same with apache <> nginx no? Also in my opinion, there's way too much default software being installed, In my case i'd have to uninstall a lot more than installing if the WSL init script follows the settler script. I like how minimal my WSL environment is right now I would at least propose to not default install
Agree, for most of them there is already a script |
Hi @MichaelBelgium, I have created a Draft PR, #1956 Have a look at it. Let me know your opinion. One thing I didn't make any changes in wsl-init, instead created new file wsl-init.sh. But in the final PR i want to replace wsl-init with wsl-init.sh Thanks, |
Thanks for the ton of work that's gone into this. RE: MySQL or Maria DB? We should follow Settler's lead in a build-time configuration that users can override to get exactly what they want. The purpose of WSL-INIT is to be a lightweight alternative. I don't want every PHP version installed typically, this should easily be a runtime option. So we would have something at the top of the wsl-init that would be ~
Then we can wrap the installer scripts around the feature checks. Thoughts? |
Hi @svpernova09 I suggest maintaining wsl-init as lightweight as it is, with MySQL as the default database. Users can opt to install MariaDB if required, streamlining the setup process. In my draft PR I have added the documentation for wsl installation, I have tried to maintain what I suggested above. ##Update: As a second thought, instead of following steps to provision wsl.
we can change the steps to following:
|
Cool, will check it out later!
Those script variables look the same as setting the feature to true in homestead.yml. In my opinion, the only things that are located in wsl-init should be things that are going to be installed by default. Eg mysql and php 8.3 at least. No questions asked (other than wsl user and group), just execute the thing. Execute, boom, you got 8.3 and mysql on your wsl instance. Then if the user wants more php versions or other database engine, edit the features in homestead.yaml I feel like this approach would be easier? Ok random thought with the deploy variables, if you want to make it a choice, whether or not default things get installed, might aswell make a feature script for them too and on deploy don't install php 8.3 / mysql but let the user decide it in homstead.yaml I don't know, there's a lot of approaches 😅 |
One concern I've noticed is the lack of uninstall scripts for software other than MySQL and MariaDB. Presently, when MariaDB is set to true in the YAML configuration, it uninstalls MySQL and installs itself, as they cannot run simultaneously. Similarly, in my pull request where I added the MySQL feature script, I followed the same approach: uninstalling MariaDB before installing MySQL. Do we need to have uninstall scripts to remove features if user changes feature from true to false? |
No, not at all. This is a weird situation for the WSL because in Vagrant-land you would just delete the VM and re-provision. This isn't nearly as possible in WSL. In my opinion feature uninstallation is going to be a nightmare and likely leave a mess of things. I don't want to debug a 4th or 5th set of installations and uninstallations. |
The only reason there is an uninstall of MySQL is because it can't coexist on the same system (easily) with MariaDB. To install MariaDB we have to purge MySQL. |
Merging this into a |
As every feature has this
The
bin/wsl-init
script does not create the homestead-features folder and neither thewsl_user_name
/wsl_user_group
file.This PR "starts to fix" the commandbin/homestead wsl:apply-features
basicly, but I noticed there are more references to /home/vagrant in the features files. I believe they all have to be/home/$WSL_USER_NAME
no?eg
homestead/scripts/features/golang.sh
Line 34 in f406c0e
This command would fail because /home/vagrant doesnt exist, except if the WSL user is called "vagrant". Would it be ok to replace all these references too?EDIT: meanwhile changed all references.
This also covers the stuff i encountered here last year #1484 (comment)
The above, to provision and configure WSL with Ubuntu, is bit outdated now too.
It should be ubuntu 22.04 now, and the commands should be executed in this order, with sudo - after installing and logging in WSL/ubuntu 22.04: