SublimeTextXdebug
SublimeTextXdebug copied to clipboard
Breakpoints failing on NFS mount Vagrant setup
I've read through the discussions on breakpoints not calling and am running into what I think might be a new issue. My setup is the following:
- Sublime Text 2 installed on OSX Mavericks.
- Vagrant server for remote host
- Sublime text project folder the docroot locally but that same folder in NFS mounted to vagrant.
Local Path: /Users/path/docroot Remote Path: /home/vagrant/docroot
Neither path is a symbolic link.
When I run a break_on_start xDebug connects with no issue and breaks. When I proceed to a breakpoint though the following line is thrown in my xdebug.log on the Vagrant box:
<- breakpoint_set -i 4 -n 62 -t line -f file%3A///Users/path/docroot/...
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="13890016"></response>
The path it is trying to get is the path from my Host and not my vagrant box. As a test I setup a local host running same xdebug configuration and Sublime sees the breakpoints and stops with no issue against local. Only against Vagrant.
Wondering if this is an issue with the NFS mounted file system?
My project settings file:
{
"folders":
[
{
"path": "/Users/path/docroot"
}
],
"settings": {
"xdebug": {
//"path_mapping": {
// "/home/vagrant/docroot" : "/Users/path/docroot"
//},
"url": "http://vagrant.dev",
"port": 9001,
"super_globals": true,
"close_on_stop": true,
"break_on_start": true
}
}
}
Xdebug configuration:
xdebug.remote_handler="dbgp"
xdebug.profiler_enable_trigger="1"
xdebug.remote_host="10.0.2.2"
xdebug.profiler_output_dir="/tmp"
xdebug.remote_port="9001"
xdebug.profiler_output_name="cachegrind.out.%t-%s"
xdebug.trace_output_dir="/tmp"
xdebug.default_enable="1"
xdebug.remote_autostart="0"
xdebug.profiler_append="0"
xdebug.remote_enable="1"
xdebug.remote_log="/tmp/xdebug.log"
@kbasarab Which version of the Xdebug extension do you have installed?
Can you add the following configuration settings to your xdebug.ini:
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
Make sure you uncomment the path_mapping configuration in your *.sublime-project.
@martomo Here is the information:
Version is: 2013.12.14.15.41.44
Log opened at 2014-04-01 12:55:34
I: Checking remote connect back address.
I: Remote address found, connecting to 192.168.50.1:9001.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/vagrant/docroot/index.php" language="PHP" protocol_version="1.0" appid="2399" idekey="sublime.xdebug"><engine version="2.2.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2014 by Derick Rethans]]></copyright></init>
<- feature_set -i 1 -v 1 -n show_hidden
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>
<- breakpoint_set -i 2 -n 20 -t line -f file%3A///Volumes/500/www/site.d7/docroot/index.php
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="23990001"></response>
<- breakpoint_set -i 3 -n 19 -t line -f file%3A///Volumes/500/www/site.d7/docroot/install.php
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="23990002"></response>
I uncommented the path mapping again (had it commented out for debugging). And above is what I get with those changes. It hits the right file location. I'm also getting at the bottom of the xdebug.log:
<- context_get -i 20
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="20" status="starting" reason="ok"><error code="301"><message><![CDATA[stack depth invalid]]></message></error></response>
<- stack_get -i 21
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="21"></response>
Sublime console shows no errors and the status bar says connected on the first break on true. After I run to a break point or step into then the connection breaks.
So on the first connect my Sublime watch looks correct but after that I can't get it to stop on individual breakpoints.
I also tried to abstract this from my full project and created a test.php file:
<?php
// Test
echo 'test1';
$node = array(
'test1' => 'this test',
'test2' => 'that test',
);
print_r($node);
function test_function($node) {
$math = 1+1;
$node_str = implode(',', $node);
}
test_function($node);
I set a breakpoint on the function test_function declaration line as well as on the implode line. If I use Step into after the initial break on true then I can step into each piece and work through the code. If I run or run to line then it doesn't ever hit a breakpoint.
It might be that the path_mapping is misconfigured, make sure the paths are absolute and have the absolute folder path opened in Sublime Text.
What about if you open the folder /Volumes/500/www/site.d7/docroot
on your local machine in Sublime Text and set the path_mapping as followed?
{
"path_mapping": {
"/home/vagrant/docroot" : "/Volumes/500/www/site.d7/docroot",
}
}
I agree it seems to be in path_mapping somehow. I have /Volumes/500/www/site.d7/docroot opened as the folder in the project and path mapping setup in that way.
The /Volumes/500/www/site.d7/docroot is the absolute path on my local machine and /home/vagrant/docroot is absolute path on the Vagrant box. I think the issue has to do with the NFS mount possibly though. Technically /Volumes/500/www/site.d7/docroot and /home/vagrant/docroot are the same file location. The /Volumes is just mounted into Vagrant via NFS.
When I change the project to point to MAMP and avoid Vagrant the breakpoints all work as expected. Also if I try to duplicate issue in PHP Storm the breakpoints work as expected. Trying to debug to have additional information to add to the debugging section of Readme.
When I have the project setup to point to Local MAMP I use the same path mapping:
{
"path_mapping": {
"/Volumes/500/www/sites/site.d7/docroot" : "/Volumes/500/www/sites/site.d7/docroot"
}
}
When trying via Vagrant I use:
{
"path_mapping": {
"/home/vagrant/docroot" : "/Volumes/500/www/sites/site.d7/docroot"
}
}
Also verified in the vagrant build /home/vagrant/docroot is the absolute path and not symlinked. In addition it is what apache is looking for as the docroot.
In your suggestion above do you want me to not create project and just set Xdebug user defaults to use the specific path mapping and open a folder so we aren't tied to a "project" in sublime?
Either *.sublime-project or Xdebug.sublime-settings will do, just keep in mind that *.sublime-project overwrites path_mapping from Xdebug.sublime-settings.
Are you using any PHP frameworks?
Yeah the path_mapping I setup is in the "site.sublime-project" project settings so that it would be used.
The site is based in Drupal but for trying to test I'm testing against the test.php page I setup above so I'm only running these tests against a single file and not an entire giant project.
I just enabled the debug mode also on the Sublime side of things for xdebug and here is the value being sent for setting the breakpoint:
This is upon initalization on Vagrant:
[04/01/2014 04:24:53PM] DEBUG - [Send command] breakpoint_set -i 2 -n 18 -t line -f file%3A///Volumes/500/www/site.d7/docroot/test.php
[04/01/2014 04:24:53PM] DEBUG - [Response data] <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="24040025"></response>
[04/01/2014 04:24:53PM] DEBUG - breakpoint_set: /Volumes/500/www/site.d7/docroot/test.php:18
[
And initialization on local MAMP:
[04/01/2014 04:27:47PM] DEBUG - [Send command] breakpoint_set -i 2 -n 18 -t line -f file%3A///Volumes/500/www/site.d7/docroot/test.php
[04/01/2014 04:27:47PM] DEBUG - [Response data] <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="499270001"></response>
[04/01/2014 04:27:47PM] DEBUG - breakpoint_set: /Volumes/500/www/site.d7/docroot/test.php:18
[
I don't see any differences between the initialization of the breakpoints between the Vagrant and Local.
However when running to a breakpoint I see differences. When I test against local MAMP and then run to a breakpoint the local sublime debug log responds with:
[04/01/2014 04:19:34PM] DEBUG - [Send command] run -i 17
[04/01/2014 04:19:34PM] DEBUG - [Response data] <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="17" status="break" reason="ok"><xdebug:message filename="file:///Volumes/500/www/site.d7/docroot/test.php" lineno="14"></xdebug:message></response>
[04/01/2014 04:19:34PM] INFO - Break: /Volumes/500/www/site.d7/docroot/test.php:14
At that same part when I test against Vagrant I get:
[04/01/2014 04:25:06PM] DEBUG - [Send command] run -i 17
[04/01/2014 04:25:06PM] DEBUG - [Response data] <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="17" status="stopping" reason="ok"></response>
Not sure why against Vagrant it is responding with status stopping.
The log on the actual vagrant box shows the following on that stopping command:
<- run -i 17
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="17" status="stopping" reason="ok"></response>
Log closed at 2014-04-01 20:25:06
For some background on how the shared folder setup is done in Vagrant we are using:
config.vm.synced_folder "/Volumes/500/www/site.d7/docroot", "/home/vagrant/docroot", nfs: true
Any success is solving this? I have the exact same problem. Xdebug breaks as supposed to when break_on_start
is true
. However it does not break at any breakpoints.