XDebug PHP Eclipse - Error No appropriate file located or no file selected
Asked Answered
S

5

8

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".

enter image description here

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:

enter image description here

Xdebug is correctly installed, I see it enabled in phpinfo() output.

Sustainer answered 28/2, 2013 at 14:43 Comment(0)
S
6

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'
Sustainer answered 28/2, 2013 at 16:57 Comment(8)
Thanks :) The error message was really annoying, even because it didn't explain exactly what's wrong.Sustainer
Comment deleted: found the solution. Thank you very, very much for posting this!!Bevatron
You have just to create a new PHP project from scratch, inside your eclipse workspace and copy the missing file(s) into. Actually the real problem is figure out what file(s) is/are missing.Sustainer
Very good, it was hard for me understand what's wrong. That error message is really so... mundane.Sustainer
Very annoying error message indeed. A details button where you could see the cause would be a good addition there.Bevatron
your solution didn't help me (yet) but definitely glad that you did the looking. I may just need to dig a bit deeper into the traceCulpepper
@Culpepper all you need is that every source PHP involved into the project is inside your eclipse repository. In my digging I never imagined what's the missing source. Hope in your case you'll be luckier.Sustainer
@Sustainer - as far as I can tell I do have every file ( even with your dtruss suggestion ). I probably missed that one file... I have this marked to go back to when I have time. Your solution is honestly, 1 I didn't even know was possible! (your question and answer deserve a bigger up vote :-) )Culpepper
C
3

I had this same problem, and while freedev's answer pointed me in the right direction, it didn't actually solve it.

Using dtruss didn't help: I didn't see that XML <init> element anywhere. But I was able to find it once I set xdebug.remote_log=/tmp/xdebug.log in php.ini, and then tailed the /tmp/xdebug.log file as I attempted to start a remote debugging session. The /opt/local/var/db/php5/pear/pear-ini.php was again being mentioned. But I have that file in my filesystem, so I have no idea why I was still getting this vague error message about a file being missing.

However, now that I knew that Pear was involved in the problem, I tried simply uninstalling Pear (sudo port uninstall php53-pear), since I wasn't actually using it any more. And lo and behold, that fixed it! I no longer get the "No appropriate file" error message, and I can debug like normal.

With php53-pear uninstalled, the fileuri setting in that XML data is now the index.php file for the Drupal site I've been trying to debug. So I'm thinking that you should expect the entrypoint file for your web requests to appear in that XML <init> element. I wish I knew why having Pear installed changes that fileuri attribute, though. Being able to configure Pear to stop messing with Xdebug would be a lot better than uninstalling Pear.

Coben answered 4/12, 2014 at 19:34 Comment(2)
Thanks for the debug.remote_log suggestion, it is a easier and cleaner solution. BTW, I'm not sure you get this: you should create a new Eclipse project and copy pear-ini.php there. In other words, only when pear-ini.php is inside an Eclipse project you should be able to debug without this annoying popup.Sustainer
That's really just a hack that happens to work. What's happening here is that Pear is somehow screwing with Xdebug's entry point. The real solution would be to reconfigure Pear to stop doing that. I just wish I knew how.Coben
D
1

I met same problem, and the cause was not pear.ini or pear-ini.php as mentioned above.

The reason was so simple. I've installed both of PDT and Aptana PHP Plugin on my Eclipse environment. Just switching both of the project type and the debug configuration type to PDT's, everything worked fine.

Thank you for posting a nice thread. :)

Dilative answered 26/2, 2014 at 14:3 Comment(0)
L
0

I am using Linux and attaching the Eclipse process using strace (the real Java subprocess of course) I wasn't able to catch such errors.

For those who experience the same problem but are unsuccesful in solving it and if you've done an Eclipse or PDT update not long ago, attempt to delete your project and recreate it. It solved my problem where xdebug debugging and Eclipse project cleanup didn't.

Liselisetta answered 5/8, 2013 at 12:6 Comment(0)
P
0

If your debugger used to work but then suddenly it started to throw that message then probably you've just bookmarked a source file that Eclipse doesn't see it as being part of the project or cannot locate it at all.

For instance while I debugged a plugin I wrote for Wordpress I've bookmarked some external Wordpress file that it seems the Eclipse/Xdebug cannot access/locate. Once I remove that bookmark everything returns to normal.

If that's the case then just Remove All Bookmarks.

Promenade answered 22/5, 2015 at 18:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.