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?
c++ regex visual-studio-code
add a comment |
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?
c++ regex visual-studio-code
related: stackoverflow.com/questions/47775169/…
– Florian Castellane
Nov 14 at 9:34
add a comment |
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?
c++ regex visual-studio-code
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
c++ regex visual-studio-code
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
add a comment |
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
related: stackoverflow.com/questions/47775169/…
– Florian Castellane
Nov 14 at 9:34