JoliNotif icon indicating copy to clipboard operation
JoliNotif copied to clipboard

The notify() function in a WSL environment

Open mark-alexandre opened this issue 1 year ago • 9 comments

Hello,

I'm in a WSL2 environment under Windows 11 in order to launch my Castor commands and with the Castor.PHAR archive for Windows (since it's this one to take even for WSL). I just tried your notification function but it doesn't trigger any notification.

I have checked my notifications options btw, and everything is properly configured. I wonder the reason behind this : is this a WSL related issue which can't communicate properly with Windows ?

#[AsTask(description: 'Suppression des volumes, conteneurs et réseaux créés pour le projet')]
function clean(bool $force = false)
{
    notify('The infrastructure has been destroyed.');
}

mark-alexandre avatar Mar 27 '24 12:03 mark-alexandre

Hey,

WSL user too, can you provide some information about version of Windows and WSL ? wsl --version

See a little discussion here about WSL 2 notification : https://github.com/jolicode/castor/pull/334

I had the same problem before, but now it works, but I'm on WSL pre-release (W11).

TheoD02 avatar Mar 27 '24 15:03 TheoD02

Hi,

I had to do a wsl --list --verbose for this (wsl --version just doesn't work and display the wsl help) :

image

I'm on WSL 2.

[EDIT] Don't pay attention to the docker-data which is stopped, It is usually on and was on during the notification test.

mark-alexandre avatar Mar 28 '24 08:03 mark-alexandre

Hi,

I had to do a wsl --list --verbose for this (wsl --version just doesn't work and display the wsl help) :

image

I'm on WSL 2.

[EDIT] Don't pay attention to the docker-data which is stopped, It is usually on and was on during the notification test.

Strange, you have an older version of WSL, I think. When did you install it, and did you update it? (wsl --update)

Can you attempt to run wsl --status ?

Which distribution do you use? Windows 10 or 11 ?

TheoD02 avatar Mar 28 '24 14:03 TheoD02

I'm using Windows 11. It's a professionnal computer delivered by my company in which I have limited rights. But yeah, you have probably right : my system seems to not be up to date.

image

I have just few seconds ago activated the necessary additionnal options in Windows Update (as described on the provided screenshot) and I'm waiting for the update to complete. This will probably resolve the issue. I was sure that WSL was already managed by Windows Update, but this is not the case and probably the reason behind this notification command not working.

When done, i'll reply to this thread in order to close it or give your more details about the issue.

mark-alexandre avatar Mar 28 '24 16:03 mark-alexandre

Well, wsl 2 is now fully updated, but the notification just doesn't appear when the function is launched. Because I'm on a locked system (limited Windows privileges), I don't know if I should close the ticket or if you would like to investigate further. Maybe the issue is not related to these system limitations and a real issue could really exists in the base code, but maybe not.

[EDIT] When doing a wsl --version (which works now), I have this output :

image

As you can see, WSL is up to date. But I have just noted a weird information : the Windows version. I'm on Windows 11 for 2 years on this PC, and I wonder why it says it's in v10.0.22631.3374

mark-alexandre avatar Mar 28 '24 16:03 mark-alexandre

Ok good to known, you have been updated to latest and higher Windows version 😄 (10.0.x is OK for W11)

But the strange thing is that on my professional PC I have no problem running notify whatever the executable (Windows or Linux phar/binary).

Except that on my personal PC it doesn't work, and all versions are up-to-date except Windows.

I got an error about the missing sonartoast. But it appeared once and then disappeared.

Now, castor plays the script without errors, but no notification is displayed 😞

What is your use case compared to mine?

Test script: image

Error throwed with linux phar/binary (only one time): image

When using Windows phar/binary: Nothing appear (no throw, no notification on Windows)

EDIT:

Okay, I've figured out my error, I've used the repo's castor.php with the deps installed, that makes it resolve snoretoast and show me the notifications properly.

I'll try to find a fix for this case. Because even the windows phar doesn't seem to fix the problem on my side.

@lyrixx, @pyrech Did you have any confirmation that the use of Windows phar fix notifications internally at your company ?

TheoD02 avatar Mar 29 '24 08:03 TheoD02

@lyrixx, @pyrech Did you have any confirmation that the use of Windows phar fix notifications internally at your company ?

I (We) don't use Windows :/

lyrixx avatar Apr 01 '24 16:04 lyrixx

For the record, I have moved the issue from castor to jolinotif.

lyrixx avatar Apr 04 '24 08:04 lyrixx

When using Windows phar/binary: Nothing appear (no throw, no notification on Windows)

I have exactly the same behavior.

mark-alexandre avatar Apr 04 '24 11:04 mark-alexandre

Since JoliNotif 2.7 was released with a better support of WSL, I'm going to close the issue as completed.

JoliNotif has also been updated inside Castor, so notification support should be quite better in the next release of Castor.

Thanks everyone

pyrech avatar May 14 '24 18:05 pyrech