How to link directories for VS Code problem matcher











up vote
1
down vote

favorite












I am writing a new build task for compiling C++ in VS Code. The task involves compiling the code inside of a Docker container. For example



docker exec -it my_container make


Here is what I have in my task.json file



{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "docker",
"args": [
"exec",
"-it",
"my_container",
"make"
],
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": {
"base": "$gcc",
"fileLocation": "absolute"
}
}
]
}


I'm able to run the task, and everything compiles correctly. However, VS Code cannot find the files that have build errors in them. That is because the output for an looks something like this:



/host/my_project/src/my_file.cpp:105:46: error: passing 'const SomeClass' as 'this' argument discards qualifiers [-fpermissive]


The path that is listed is the absolute path to the file in the Docker container. When you click on one of the files in the Problems tab, it tries to jump to /host/my_project/src/my_file.cpp, but it doesn't exist. Instead, the file lives in /home/me/projects/my_project/src/my_file.cpp.



I've tried a few things to fix this, none of which seem to work. I tried changing the problemMatcher to the one outlined in the documentation and trying to use a different regex that would remove the absolute part of the path (e.g. convert /host/my_project/src/my_file.cpp to /src/my_file.cpp, and set the fileLocation to relative). However I'm not well-versed enough in regex to get it right. Referencing some regex from here, I came up with this



"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^[^/]/[^/]*/[^/]*/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}


I also tried the other options in that answer, but none of them work. Another thing I tried was creating a symlink between the folders by running ln -s /host ~/projects. This also did not work, and still tried to open the file in the Docker container



Does anyone have any suggestions?










share|improve this question
























  • related: stackoverflow.com/questions/47775169/…
    – Florian Castellane
    Nov 14 at 9:34















up vote
1
down vote

favorite












I am writing a new build task for compiling C++ in VS Code. The task involves compiling the code inside of a Docker container. For example



docker exec -it my_container make


Here is what I have in my task.json file



{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "docker",
"args": [
"exec",
"-it",
"my_container",
"make"
],
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": {
"base": "$gcc",
"fileLocation": "absolute"
}
}
]
}


I'm able to run the task, and everything compiles correctly. However, VS Code cannot find the files that have build errors in them. That is because the output for an looks something like this:



/host/my_project/src/my_file.cpp:105:46: error: passing 'const SomeClass' as 'this' argument discards qualifiers [-fpermissive]


The path that is listed is the absolute path to the file in the Docker container. When you click on one of the files in the Problems tab, it tries to jump to /host/my_project/src/my_file.cpp, but it doesn't exist. Instead, the file lives in /home/me/projects/my_project/src/my_file.cpp.



I've tried a few things to fix this, none of which seem to work. I tried changing the problemMatcher to the one outlined in the documentation and trying to use a different regex that would remove the absolute part of the path (e.g. convert /host/my_project/src/my_file.cpp to /src/my_file.cpp, and set the fileLocation to relative). However I'm not well-versed enough in regex to get it right. Referencing some regex from here, I came up with this



"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^[^/]/[^/]*/[^/]*/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}


I also tried the other options in that answer, but none of them work. Another thing I tried was creating a symlink between the folders by running ln -s /host ~/projects. This also did not work, and still tried to open the file in the Docker container



Does anyone have any suggestions?










share|improve this question
























  • related: stackoverflow.com/questions/47775169/…
    – Florian Castellane
    Nov 14 at 9:34













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am writing a new build task for compiling C++ in VS Code. The task involves compiling the code inside of a Docker container. For example



docker exec -it my_container make


Here is what I have in my task.json file



{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "docker",
"args": [
"exec",
"-it",
"my_container",
"make"
],
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": {
"base": "$gcc",
"fileLocation": "absolute"
}
}
]
}


I'm able to run the task, and everything compiles correctly. However, VS Code cannot find the files that have build errors in them. That is because the output for an looks something like this:



/host/my_project/src/my_file.cpp:105:46: error: passing 'const SomeClass' as 'this' argument discards qualifiers [-fpermissive]


The path that is listed is the absolute path to the file in the Docker container. When you click on one of the files in the Problems tab, it tries to jump to /host/my_project/src/my_file.cpp, but it doesn't exist. Instead, the file lives in /home/me/projects/my_project/src/my_file.cpp.



I've tried a few things to fix this, none of which seem to work. I tried changing the problemMatcher to the one outlined in the documentation and trying to use a different regex that would remove the absolute part of the path (e.g. convert /host/my_project/src/my_file.cpp to /src/my_file.cpp, and set the fileLocation to relative). However I'm not well-versed enough in regex to get it right. Referencing some regex from here, I came up with this



"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^[^/]/[^/]*/[^/]*/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}


I also tried the other options in that answer, but none of them work. Another thing I tried was creating a symlink between the folders by running ln -s /host ~/projects. This also did not work, and still tried to open the file in the Docker container



Does anyone have any suggestions?










share|improve this question















I am writing a new build task for compiling C++ in VS Code. The task involves compiling the code inside of a Docker container. For example



docker exec -it my_container make


Here is what I have in my task.json file



{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "docker",
"args": [
"exec",
"-it",
"my_container",
"make"
],
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": {
"base": "$gcc",
"fileLocation": "absolute"
}
}
]
}


I'm able to run the task, and everything compiles correctly. However, VS Code cannot find the files that have build errors in them. That is because the output for an looks something like this:



/host/my_project/src/my_file.cpp:105:46: error: passing 'const SomeClass' as 'this' argument discards qualifiers [-fpermissive]


The path that is listed is the absolute path to the file in the Docker container. When you click on one of the files in the Problems tab, it tries to jump to /host/my_project/src/my_file.cpp, but it doesn't exist. Instead, the file lives in /home/me/projects/my_project/src/my_file.cpp.



I've tried a few things to fix this, none of which seem to work. I tried changing the problemMatcher to the one outlined in the documentation and trying to use a different regex that would remove the absolute part of the path (e.g. convert /host/my_project/src/my_file.cpp to /src/my_file.cpp, and set the fileLocation to relative). However I'm not well-versed enough in regex to get it right. Referencing some regex from here, I came up with this



"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^[^/]/[^/]*/[^/]*/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}


I also tried the other options in that answer, but none of them work. Another thing I tried was creating a symlink between the folders by running ln -s /host ~/projects. This also did not work, and still tried to open the file in the Docker container



Does anyone have any suggestions?







c++ regex visual-studio-code






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 18:03

























asked Nov 9 at 17:30









TFischer

64411433




64411433












  • related: stackoverflow.com/questions/47775169/…
    – Florian Castellane
    Nov 14 at 9:34


















  • related: stackoverflow.com/questions/47775169/…
    – Florian Castellane
    Nov 14 at 9:34
















related: stackoverflow.com/questions/47775169/…
– Florian Castellane
Nov 14 at 9:34




related: stackoverflow.com/questions/47775169/…
– Florian Castellane
Nov 14 at 9:34












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










It looks like you just have to include the container name plus slashes: /host/ in the regex (and treat the path as relative), so here goes:



The slashes must be escaped, so you have to add /host/ after the beginning of that regex.



Try this config, I can run it as a task (control-shift-B) and generate problems with it (control-shift-M). However it doesn't let me control-click the errors in the console, I guess one would need to edit the c++ extension's regex for this.



{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"echoCommand": true,
"tasks": [
{
"label": "build",
"command": "YOUR BUILD COMMAND HERE",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}",
},
"problemMatcher": {
"base": "gcc",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^/host/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}


However, the path detection in the terminal is unaffected. I wish this regex would let us control+click the GCC messages to jump to the code.






share|improve this answer























  • Thank you! I had to slightly modify /host/ to match my folder structure, but it works. I also links back to the correct file when I click a problem in the list
    – TFischer
    Nov 15 at 14:14













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230663%2fhow-to-link-directories-for-vs-code-problem-matcher%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










It looks like you just have to include the container name plus slashes: /host/ in the regex (and treat the path as relative), so here goes:



The slashes must be escaped, so you have to add /host/ after the beginning of that regex.



Try this config, I can run it as a task (control-shift-B) and generate problems with it (control-shift-M). However it doesn't let me control-click the errors in the console, I guess one would need to edit the c++ extension's regex for this.



{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"echoCommand": true,
"tasks": [
{
"label": "build",
"command": "YOUR BUILD COMMAND HERE",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}",
},
"problemMatcher": {
"base": "gcc",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^/host/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}


However, the path detection in the terminal is unaffected. I wish this regex would let us control+click the GCC messages to jump to the code.






share|improve this answer























  • Thank you! I had to slightly modify /host/ to match my folder structure, but it works. I also links back to the correct file when I click a problem in the list
    – TFischer
    Nov 15 at 14:14

















up vote
1
down vote



accepted










It looks like you just have to include the container name plus slashes: /host/ in the regex (and treat the path as relative), so here goes:



The slashes must be escaped, so you have to add /host/ after the beginning of that regex.



Try this config, I can run it as a task (control-shift-B) and generate problems with it (control-shift-M). However it doesn't let me control-click the errors in the console, I guess one would need to edit the c++ extension's regex for this.



{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"echoCommand": true,
"tasks": [
{
"label": "build",
"command": "YOUR BUILD COMMAND HERE",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}",
},
"problemMatcher": {
"base": "gcc",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^/host/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}


However, the path detection in the terminal is unaffected. I wish this regex would let us control+click the GCC messages to jump to the code.






share|improve this answer























  • Thank you! I had to slightly modify /host/ to match my folder structure, but it works. I also links back to the correct file when I click a problem in the list
    – TFischer
    Nov 15 at 14:14















up vote
1
down vote



accepted







up vote
1
down vote



accepted






It looks like you just have to include the container name plus slashes: /host/ in the regex (and treat the path as relative), so here goes:



The slashes must be escaped, so you have to add /host/ after the beginning of that regex.



Try this config, I can run it as a task (control-shift-B) and generate problems with it (control-shift-M). However it doesn't let me control-click the errors in the console, I guess one would need to edit the c++ extension's regex for this.



{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"echoCommand": true,
"tasks": [
{
"label": "build",
"command": "YOUR BUILD COMMAND HERE",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}",
},
"problemMatcher": {
"base": "gcc",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^/host/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}


However, the path detection in the terminal is unaffected. I wish this regex would let us control+click the GCC messages to jump to the code.






share|improve this answer














It looks like you just have to include the container name plus slashes: /host/ in the regex (and treat the path as relative), so here goes:



The slashes must be escaped, so you have to add /host/ after the beginning of that regex.



Try this config, I can run it as a task (control-shift-B) and generate problems with it (control-shift-M). However it doesn't let me control-click the errors in the console, I guess one would need to edit the c++ extension's regex for this.



{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"echoCommand": true,
"tasks": [
{
"label": "build",
"command": "YOUR BUILD COMMAND HERE",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}",
},
"problemMatcher": {
"base": "gcc",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^/host/(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}


However, the path detection in the terminal is unaffected. I wish this regex would let us control+click the GCC messages to jump to the code.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 at 9:42

























answered Nov 14 at 9:14









Florian Castellane

232420




232420












  • Thank you! I had to slightly modify /host/ to match my folder structure, but it works. I also links back to the correct file when I click a problem in the list
    – TFischer
    Nov 15 at 14:14




















  • Thank you! I had to slightly modify /host/ to match my folder structure, but it works. I also links back to the correct file when I click a problem in the list
    – TFischer
    Nov 15 at 14:14


















Thank you! I had to slightly modify /host/ to match my folder structure, but it works. I also links back to the correct file when I click a problem in the list
– TFischer
Nov 15 at 14:14






Thank you! I had to slightly modify /host/ to match my folder structure, but it works. I also links back to the correct file when I click a problem in the list
– TFischer
Nov 15 at 14:14




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230663%2fhow-to-link-directories-for-vs-code-problem-matcher%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?