0

I have installed php 7.3.27 version

I want to work with zsh but when I type "php -v", it is showing me following error:

zsh: command not found: php

And when I installed wp-cli, on typing "wp --info", it is showing me following error:

/usr/bin/env: ‘php’: No such file or directory

In git bash, "php -v" is working fine, but in zsh it not working.

My php is located here: /mnt/c/Program Files/php-7.3.27/php On running:

stat "/mnt/c/Program Files/php-7.3.27/php"

it is showing me the following:

stat: cannot stat '/mnt/c/Program Files/php-7.3.27/php': No such file or directory
Solanki Ketul
  • 31
  • 1
  • 7
  • If you want to run an executable file by just entering its name, the directory where the file is located must be in your PATH. This applies to Linux, Windows, and MacOS. – user1934428 Jun 30 '21 at 10:15
  • @user1934428 So you are saying that I need to add path in environment variables. I already did that and my OS is Windows. But still the issue persists. – Solanki Ketul Jul 01 '21 at 05:44
  • (1) How did you verify that the PATH is set correctly? in zsh, the cleanest way is to do a `echo $path` just right before trying to fiddle with zsh. (2) When you are using zsh under Windows, are you on WSL, or Cygwin, or something else? – user1934428 Jul 01 '21 at 06:17
  • @user1934428 (1) I verified the path with "echo $path" and it is there. My php path is /mnt/c/Program Files/php-7.3.27. And it showing me the path. (2) Yes i am on WSL, I can use all teh command of linux. – Solanki Ketul Jul 01 '21 at 06:51
  • And if you do a `type php`, you also get a _php not found_ from zsh? In this case, I would check whether the file has execution rights. Do a `stat /mnt/c/Program Files/php-7.3.27/php` and include the output in your question. It could be that your PHP installation is broken. – user1934428 Jul 01 '21 at 06:56
  • @user1934428 Yes, `type php` is showing me **php not found**. And on doing `stat /mnt/c/Program Files/php-7.3.27/php` it is showing **stat: cannot stat '/mnt/c/Program Files/php-7.3.27/php': No such file or directory** – Solanki Ketul Jul 01 '21 at 07:07
  • So you are simply missing `php` from your PHP installation. :-DDDD If PHP is not there, you can't expect zsh to find it. – user1934428 Jul 01 '21 at 07:08
  • Just for the safe side: I hope you quoted your argument, since your path contains a space (I forgot the quoting in my comment), i.e. `stat '/mnt/c/Program Files/php-7.3.27/php'` – user1934428 Jul 01 '21 at 07:10
  • @user1934428 PHP executable file is there, why zsh is not finding it. On git bash 'php -v' shows me the expected results but zsh is giving me error. why is that? (2) yes, I quoted the path – Solanki Ketul Jul 01 '21 at 07:13
  • If _stat_ says the file does not exist, then the file really does not exist. You can also look with `ls -l '/mnt/c/Program Files/php-7.3.27/php'` - I bet that you also get a _not found_ error. The point is that _stat_ is oblivious to what shell it is called from, so it does not matter whether or not you are using zsh or something else. What **could** matter is _WSL_ vs. _git bash_. – user1934428 Jul 01 '21 at 07:17
  • @user1934428 yeah, you are right. `ls -l '/mnt/c/Program Files/php-7.3.27/php'` gave me _not found_ error. So, what should I do now?. How should I fix php error issue? – Solanki Ketul Jul 01 '21 at 07:25
  • What I would also do is a `stat '/mnt/c/Program Files/php-7.3.27'/* ` (be careful with the quoting), to find out **what** exactly _stat_ finds in this directory, if it does not find your executable. – user1934428 Jul 01 '21 at 07:27
  • Another useful diagnostics would be a `find '/mnt/c/Program Files' -name 'php*'` (again be careful with the quoting). – user1934428 Jul 01 '21 at 07:28
  • @user1934428 php executable file php.exe is there after running `stat '/mnt/c/Program Files/php-7.3.27'/*` and `find '/mnt/c/Program Files' -name 'php*'` gave me permission denied – Solanki Ketul Jul 01 '21 at 09:00
  • So, since `stat` suddenly finds it, what are its permissions? And what is the output of `find`, **except** the error message? Could be that there are incorrect permissions somewhere along the path from `/mnt` up to `php-7.3.27`, so I would check each component separately. – user1934428 Jul 01 '21 at 11:30
  • @user1934428 `stat` shows me the list of some files including the path of _php.exe_ file i.e `/mnt/c/Program Files/php-7.3.27/php.exe` and showing me the error of _permission denied_ for this: `find: ‘/mnt/c/Program Files/WindowsApps’: Permission denied` – Solanki Ketul Jul 01 '21 at 11:59
  • @user1934428 You suggested me to run `stat "/mnt/c/Program Files/php-7.3.27/php"` command. Shouldn't I add `.exe` extension at the end of command? Like `stat "/mnt/c/Program Files/php-7.3.27/php.exe"`. – Solanki Ketul Jul 01 '21 at 12:03
  • You said first that it is about a program named `php`, and now you are talking about a `php.exe`. You certainly should use the correct file name. I know from the Cygwin environment that they under certain situations apply the `.exe` implicitly, but you are not using Cygwin, and for debugging **this** type of problems, you should certainly use the correct filename and not hope for some magic going on under the hood. – user1934428 Jul 01 '21 at 12:40
  • @user1934428 I have installed php 7.3.27, and all the files and folders in that folder are built-in, provided after installing php in my device. I haven't named any file or folder by my own. All the names are default one. – Solanki Ketul Jul 02 '21 at 06:10
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/234432/discussion-between-user1934428-and-solanki-ketul). – user1934428 Jul 02 '21 at 06:51

0 Answers0