I'm trying to debug remotely a php web app but anytime I try to start a debug session Eclipse flood me with a bunch of popups:
Debugger Error: "No appropriate file located or no file selected. Debug Terminated".
This is my current Xdebug 2.2.1 configuration:
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
This is my Eclipse 4.2.1 debug configuration:
Xdebug is correctly installed, I see it enabled in phpinfo() output.
I tried to debug Eclipse in order to understand what's happening in my Mac OS X.
First find the current Eclipse running process:
$ ps -ef | grep eclipse
501 15160 373 0 4:21PM ?? 2:57.19 /Users/myuser/apps/eclipse/Eclipse.app/Contents/MacOS/eclipse -psn_0_651423
Then trace Eclipse system calls:
$ sudo dtruss -fp 15160
[... omissis ...]
accept(0xA0, 0x1224C37E8, 0x1224C37E4) = 103 0
setsockopt(0x67, 0xFFFF, 0x1002) = 0 0
setsockopt(0x67, 0xFFFF, 0x1001) = 0 0
read(0x67, "4\0", 0x1) = 1 0
read(0x67, "7\0", 0x1) = 1 0
read(0x67, "7\0", 0x1) = 1 0
read(0x67, "\0", 0x1) = 1 0
read(0x67, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<init xmlns=\"urn:debugger_protocol_v1\" xmlns:xdebug=\"http://xdebug.org/dbgp/xdebug\" fileuri=\"file:///opt/local/var/db/php5/pear/pear-ini.php\" language=\"PHP\" protocol_version=\"1.0\" appid=\"14961\" idekey=\"ECLIPSE_DB", 0x1DD) = 477 0
read(0x67, "\0", 0x1) = 1 0
[... omissis ...]
Here I've caught the first line sent from xdebug.
It is the line where eclipse is reading a piece of XML. I suppose this is the DBGp part.
<?xml version="1.0"
encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
fileuri="file:///opt/local/var/db/php5/pear/pear-ini.php"
language="PHP"
protocol_version="1.0"
appid="14961"
idekey="ECLIPSE_DB
Looking at fileuri
I discovered Xdebug is trying to start the debugging session with /opt/local/var/db/php5/pear/pear-ini.php
.
The file pear-ini.php
does not exist in my eclipse projects.
So I create a new project inside my Eclipse workspace and here I have copied the file /opt/local/var/db/php5/pear/pear-ini.php
It works, Eclipse PDT now find the file it was looking for and the debugger finally start correctly. It is even asking me if I would like to switch into Debug perspective.
Conclusion
If you bump into this strange error: "No appropriate file located or no file selected.", well it means exactly what's written.
Okay, my Eclipse was unable to find the file, but it also meant that it is trying to find a file that is out from its workspace.
May be a file that is loaded from the PHP engine for some strange reason.
In my case pear-ini.php
is added automatically by pear.ini
$ cat pear.ini
; Do not edit this file; it is automatically generated by MacPorts.
; Any changes you make will be lost if you upgrade or uninstall php5-pear.
; To configure PHP, edit /opt/local/etc/php5/php.ini.
auto_prepend_file = '/opt/local/var/db/php5/pear/pear-ini.php'