-3

I'm making a website about 3D printing, and I want to be able to slice a 3D model with a php backend, as an instant quote system, to determine the amount of filament used, time taken, etc. I found this curaengine wrapper (https://github.com/Spiritdude/Cura-CLI-Wrapper), and I'm trying to use this, because it seems like it does exactly what I'm looking for. The only problem is that it's Linux only, and I'm running an IIS server with PHP on Windows. I have a WSL distro installed and configured with the cura slicer program, and the command I want to execute is (for testing purposes): wsl cura-slicer.

I can run this command just fine in a regular cmd window, both as user and admin, and it displays the help page for the slicer. My PHP code is the following:

<?php
$command = 'wsl cura-slicer';
$output = shell_exec($command);
echo $output;

But when I run this, it gives this output:

Windows Subsystem for Linux has no installed distributions.


Distributions can be installed by visiting the Microsoft Store:


https://aka.ms/wslstore

It says that there are no distributions installed (which there are).

I tried listing distributions (using wsl --list), and it gives the exact same output. I also tried installing Ubuntu again (with wsl --install -d Ubuntu), and the same output again.

I also tried the solution in this post: https://stackoverflow.com/questions/72420488/iis-php-exec-to-run-linux-commands-with-wsl-not-working

I thought the problem might be with using the Application Pool Identity user (IIS AppPool\DefaultAppPool), but I changed it to my local user account, and instead, it showed no output for any wsl command.

  • What did you use to run PHP code? AMPPS? or XAMPP? – Bình Ông Aug 27 '23 at 03:35
  • PHP runs natively on Linux, so why cannot you host everything on a Linux machine? WSL has quite a few limitations, so calling it from a web app on IIS is probably never a supported feature. – Lex Li Aug 27 '23 at 04:57
  • Perhaps [this SO question and answers](https://stackoverflow.com/questions/72420488/iis-php-exec-to-run-linux-commands-with-wsl-not-working) will be of use to you. – FiddlingAway Aug 27 '23 at 10:08

1 Answers1

0

"Windows Subsystem for Linux has no installed distributions."

If you receive this error after you have already installed WSL distributions:

  1. Run the distribution at least once before invoking it from the command line.

  2. Check whether you may be running separate user accounts. Running your primary user account with elevated permissions (in admin mode) should not result in this error, but you should ensure that you aren't accidentally running the built-in Administrator account that comes with Windows. This is a separate user account and will not show any installed WSL distributions by design. For more info, see Enable and Disable the Built-in Administrator Account.

  3. The WSL executable is only installed to the native system directory. When you’re running a 32-bit process on 64-bit Windows (or on ARM64, any non-native combination), the hosted non-native process actually sees a different System32 folder. (The one a 32-bit process sees on x64 Windows is stored on disk at \Windows\SysWOW64.) You can access the “native” system32 from a hosted process by looking in the virtual folder: \Windows\sysnative. It won’t actually be present on disk, mind you, but the filesystem path resolver will find it.

Reference document link: Troubleshooting Windows Subsystem for Linux.

YurongDai
  • 1,362
  • 1
  • 2
  • 7
  • I tried changing the application pool identity to my local user account, and confirmed it by running `whoami`. I can run other applications in the system32 folder using this method, but `wsl.exe` doesn't provide any output, if it is running or not. – OrangeIsBetter Aug 29 '23 at 00:24
  • Have you checked the PHP error log? Are there any error messages related to running WSL commands? – YurongDai Sep 01 '23 at 07:52