Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitution Value of ${workspaceFolder} Not As Expected #43867

Closed
deltoss opened this issue Feb 17, 2018 · 4 comments
Closed

Substitution Value of ${workspaceFolder} Not As Expected #43867

deltoss opened this issue Feb 17, 2018 · 4 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@deltoss
Copy link

deltoss commented Feb 17, 2018

  • VSCode Version: 1.20.1
  • OS Version: Windows 10 Pro

See resolved issue from PHP Debug repo:
xdebug/vscode-php-debug#240

The issue there was resolved, but it seems like it might be an issue with VSCode variable substitution.

Essentially I'm trying to get PHP Debug to work over docker, I have a launch.json file of:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "pathMappings": {
                "/var/www/html": "${workspaceFolder}/htdocs"
            },
            "port": 9000,
            "log": true
        },
    ]
}

However, I expected ${workspaceFolder} to be my workspace root folder, something like:
c:/path/to/folder

That doesn't seem to be the case. When I define my VSLaunch code with absolute paths, everything works.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "pathMappings": {
                "/var/www/html": "c:/path/to/folder/htdocs"
            },
            "port": 9000,
            "log": true
        },
    ]
}

Are there any way I can figure out the value of "${workspaceFolder}" to see what's its substituting with?

@isidorn
Copy link
Contributor

isidorn commented Feb 19, 2018

@oniisaki currently we do not have builtin support to show the value of ${workspaceFolder} and other variables.
What I suggest is to create a task which simply prints out the value of a ${workspaceFolder}.

Another alternative is to simply launch this javascript launch.json. Have a simple one line javascript file, and you will see in the the debug console something like (where the last part is the workspaceFolder resovled)
node --inspect-brk=30275 sdadsadsa/test.js /Users/isidor/Development/w/new

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${file}",
            "args": [
                "${workspaceFolder}"
            ]
        }
    ]
}

If you find that $workspaceFolder is not resolved as expected please give us more details so we can investigate. What is the expected value, what is the actual value and steps to reproduce

@isidorn isidorn added the info-needed Issue requires more information from poster label Feb 19, 2018
@sndrsnk
Copy link

sndrsnk commented Feb 19, 2018

I'm also experiencing the same issue as @oniisaki with the felixfbecker xDebug extension. I followed the suggestions made by @isidorn and created a task to print out the values of ${workspaceFolder} as follows:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "echo",
      "type": "shell",
      "command":
        "echo workspaceFolder: ${workspaceFolder} \n workspaceRoot: ${workspaceRoot}"
    }
  ]
}

I receive the following output when executed:

> Executing task in folder myproject.local: echo workspaceFolder: C:\Users\kevin\Development\___webroot\myproject.local; workspaceRoot: C:\Users\kevin\Development\___webroot\myproject.local;
  ...
  ...

I performed some further tests and found that the xDebug configuration is initialised, as per the following output from the xDebug extension

{ command: 'setBreakpoints',
  arguments: 
   { source: 
      { name: 'tests_controller.php',
        path: 'c:\\Users\\kevin\\Development\\___webroot\\myproject.local\\app\\controllers\\tests_controller.php' },
     lines: [ 43, 44, 45 ],
     breakpoints: [ { line: 43 }, { line: 44 }, { line: 45 } ],
     sourceModified: false },
  type: 'request',
  seq: 4 }

As you can see, it looks like the lowercase drive letter is referenced here. I went ahead and set this as a hard value in my launch.json xDebug configuration:

  ...
   "pathMappings": {
       "/var/www/myproject.local": "c:\\Users\\kevin\\Development\\___webroot\\myproject.local
    }

When executed, the code execution stopped on the correct breakpoints. I then changed the drive letter to an uppercase 'C', re-launched the debugger and this time the code execution was not stopped on my specified breakpoints.

I hope you find the above information helpful and let me know if you need anything else.

@isidorn
Copy link
Contributor

isidorn commented Feb 19, 2018

Seems like a duplicate of #43959
fyi @weinand @DanTup

@vscodebot vscodebot bot closed this as completed Feb 26, 2018
@vscodebot
Copy link

vscodebot bot commented Feb 26, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants