Phpunit has been installed but is not recognized

I installed exercism locally. Then I went into my folder : exercism/php and from that folder installed PHPUnit. However, when I run
./phpunit --version
I get
bash: ./phpunit: : File or folder does not exist. If try to run a test with
./phpunit sweethearts.php
I get
/usr/bin/env: ‘php’: File or folder does not exist.
When I open the php directory I can see a file in there called phpunit and one other called sweethearts. I can open phpunit and read it. But there is this message at the top that says (translated).
A problem has occurred opening /home/karil/exercism/php/phpunit. The opened file contains some invalid characters .
Then it goes on to say that changing the file may corrupt it totally and it suggests I use another character set. I see a dropdown list with a caption current language environment. This is set to UTF-8. I selected UTF-16 and click on again. Now I can’t open it any more. I try Western(ISO 8859-15) and now the text editor won’t respond any more, I close it down. There is another ISO option and the same thing happens.
Or is the problem something different ? Right now When I run
exercism debug | grep Workspace
I get
workspace: /home/karil/exercism.
Exercism has been installed and I’ve gone through all the instructions : added it to path, configured, everything returned what I was suppsed to see, but, I cannot run any tests.

Can you help me please?

Thank you and Greetings,

It sounds like neither php nor phpunit are in your PATH. You may want to follow these instructions to install both. Installing PHP locally | Exercism's Docs


I installed php using apt-get install php and it did that.
Makes no difference.

I believe I have installed phpunit using wget -O phpunit and then all the commands that follow that. I have done everything and always got the output I should be expecting.

By the way, I have spent full days trying to install a LAMP stack and ended up reinstalling ubuntu from scratch because I got into some loop, could not kill a process and nobody could help. I am a learner, I don’t know much about ubuntu and certainly not anything about php.

That’s why I turn to exercism.
I have no idea what I should do next.

Thank you and greetings,

If you open a new terminal and run php, does that work?
If you open a new terminal and run phpunit, does that work?

That’s the quickest way to very which are in your PATH (or home dir).

If i type in php, the cursor continues to blink.
If i enter php -v i get :
PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.2, Copyright (c) Zend Technologies with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies
If I enter phpunit I get : not found but can be found with : sudo apt install phpunit
So I do that. When I then run : phpunit. THINGS HAPPEN! :heart_eyes:The first line is see is : PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Now when I go into exercism/php and run ./phpunit --version it does print : PHPUnit 9.6.13 by Sebastian Bergmann and contributors.

But that doesn’t happen in the folder where the test file sits, in this case sweethearts. I get the same file or folder doesn’t exist.

BUT I got it.
Either I stay in the php folder and attach the right path : ./phpunit sweethearts/HighSchoolSweetheartTest.php
I go into the sweethearts folder and I drop ./ , it works and i get test results. phpunit HighSchoolSweetheartTest.php

I got into the ‘right’ (?) folder, (DROPPED ./) and I installed phpunit with apt install. That did it.

I think the problem has been resolved.

Thank you for the almost immediate support,



path/executable looks in the path (eg ./) for that executable. executable searches the PATH for that executable. They do very different things.

I do not understand at all what you are saying. The executable is that the file I downloaded ? Do I need to understand this to get all the exercises done? I’m glad I got it to work but I’d like to understand what you are writing.


An executable is a file which can be run (aka a program). In this particular instance, we’d be discussing the executables php and phpunit. If you installed phpunit using apt-get and also downloaded it using curl, there are multiple phpunit files/programs/executables on your system, located in different folders/directories/paths. When you run ./phpunit, the system looks for a phpunit executable file in the ./ path (current working directory). If you run phpunit, the system looks for a phpunit executable file in the directories specified by the PATH variable, which typically includes /bin and /usr/bin – one of which likely contains the phpunit file installed by apt-get.

1 Like

Thank you, I get it now. The file works with wget and uses the current working directory. Exercism is added to the PATH. I didn’t see the difference between the two. It might be useful to add phpunit to the path as well. Or, to state very precisely where people should open what.

Now I’ve got two versions of things and I don’t like that. I think something similar created a loop that I couldn’t get out of and I ended up reinstalling ubuntu from scratch.

I’ll remove one of the versions.

Thank you for your explanation and help,


To be clear, the PATH contains directories which contain executable files. Individual executable files are not added to the PATH. For instance, most Linux executables tend to live in /bin or /usr/bin. There can be hundreds or thousands of executables in those directories. But that’s only two directories added to the PATH.

I need to learn ubuntu. I really do.
Thanks again