freedev
freedev

Reputation: 30047

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

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.

Upvotes: 8

Views: 2516

Answers (5)

freedev
freedev

Reputation: 30047

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'

Upvotes: 6

Eugen Mihailescu
Eugen Mihailescu

Reputation: 3711

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.

Upvotes: 0

coredumperror
coredumperror

Reputation: 9100

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.

Upvotes: 3

kaorukobo
kaorukobo

Reputation: 2383

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. :)

Upvotes: 1

Pierre
Pierre

Reputation: 146

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.

Upvotes: 0

Related Questions