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

PROBLEMS pane: file path is not correctly prefixed with forward slash / #1915

Closed
zfields opened this issue May 2, 2018 · 14 comments
Closed
Labels
Feature Request fixed Check the Milestone for the release in which the fix is or will be available. help wanted Can be fixed in the public (open source) repo. Language Service
Milestone

Comments

@zfields
Copy link

zfields commented May 2, 2018

Forwarded from: microsoft/vscode#48841

Example output from file pane:

src_file.cpp Users/zfields/dev/source/application/lib/src_file.cpp
* use of undeclared identifier 'id' (213,5)

When I click on the problem, I get the following error message.

Error message:

Unable to open 'src_file.cpp': File not found
(file:///Users/zfields/dev/source/application/Users/zfields/dev/source/application/lib/src_file.cpp).

It looks like VSCode is trying to use a relative path from ${workspaceFolder}, even though the PROBLEMS pane is showing an absolute-ish path. Perhaps the path from the PROBLEMS pane would be appropriately identified as an absolute path if it was prefixed with a forward slash /.

@sean-mcmanus
Copy link
Contributor

The messages "Unable to open … File not found" and "use of undeclared identifier" are not from our extension. Do you have another C++ extension installed? This doesn't sound like our issue, right?

@zfields
Copy link
Author

zfields commented May 3, 2018

First, please don't close issues in less than 24 hours without giving me an opportunity to respond.

Here is the extension I have installed - no other cpp extension.

screen shot 2018-05-03 at 10 04 10 am

I had already raised an issue with the VSCode team first, and they directed me to you.

jrieken:
It's the extension that feeds those uris into the system. @zfields please forward this to the cpp-extension. Thanks

Perhaps it isn't your error message, but instead you have a poorly constructed URI. Therefore, the file path would in turn be handed off to some module that would generate such an error message.

Is your extension responsible for constructing the URIs?

@bobbrow bobbrow added Language Service more info needed The issue report is not actionable in its current state labels May 3, 2018
@bobbrow
Copy link
Member

bobbrow commented May 3, 2018

If the message doesn't come from our extension, then we didn't construct the URI. Can you provide more details as to how this message was generated? Were you running a task? Were you editing code? What other extensions have you installed?

@bobbrow bobbrow reopened this May 3, 2018
@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented May 3, 2018

Our extension has a problem matcher, which assumes the path is relative to your workspace as you describe. It's currently "by design". We could treat this as a feature request to enable this to work with absolute paths (no one else has asked for this yet though). You could modify the package.json yourself as a workaround for your scenario, by changing the fileLocation to "absolute" (see https://code.visualstudio.com/docs/editor/tasks-appendix ). I'm not sure yet if there's a way to get it detect the absolute path and switch to the correct problem matcher. The code is in our package.json, search for problemMatchers: (https://github.com/Microsoft/vscode-cpptools/blob/master/Extension/package.json ). This part of the extension is open source.

@sean-mcmanus sean-mcmanus added Feature Request help wanted Can be fixed in the public (open source) repo. and removed external more info needed The issue report is not actionable in its current state labels May 3, 2018
@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented May 3, 2018

The ability to auto-detect if a problem path is absolute or relative is being tracked by microsoft/vscode#449 . I have upvoted the issue.

However, it sounds like we might be able to workaround the issue via adding an absolute path problem matcher before the relative path one.

@zfields
Copy link
Author

zfields commented May 7, 2018

These are all the extensions I have installed...

screen shot 2018-05-03 at 2 29 37 pm

The message is generated when I run a task of "type": "shell", using the "problemMatcher": ["$gcc"].

I'm running a python script that compiles my project using a makefile.

Sorry for the delay, I've been trying to collect better examples, but they are very specific to my work and I haven't found any that are completely free of IP.

@zfields
Copy link
Author

zfields commented May 7, 2018

@sean-mcmanus I believe your intuition is right, that they appear to be related to the problem matcher.

@hzcheng
Copy link

hzcheng commented Mar 2, 2019

It seems like when we use "make -C" to make on top level, the problem shows. Any update on this problem?

@merlijn-sebrechts
Copy link

merlijn-sebrechts commented May 17, 2019

Note: if you can change the GCC commands themselves, you can fix this issue by using only absolute paths in GCC calls.

                "command": "g++",
                "args": [
                    "-g",
                    "-Wall",
                    // When GCC displays errors, it uses the paths you supply it to show the 
                    // file or the error, even if those paths are relative. However, GCC uses
                    // absolute paths for errors in system libraries.
                    // VSCode however, requires all paths in errors to be either relative OR absolute.
                    // so we append ${workspaceRoot} to the relative paths in this command so that all
                    // paths are absolute.
                    // Note: this requires configuring problemmatcher to use absolute paths too.
                    "${workspaceRoot}/*.cpp",
                    "-static-libgcc",
                    "-static-libstdc++",
                    "-lallegro",
                    "-lallegro_audio",
                    "-lallegro_acodec",
                    "-lallegro_dialog",
                    "-lallegro_font",
                    "-lallegro_image",
                    "-lallegro_primitives",
                    "-lallegro_ttf",
                    "-o",
                    "project.exe"
                ]

and then change the problemmatcher to use absolute paths.

            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": "absolute"
            },

@bobbrow bobbrow modified the milestones: On Deck, Post-v1 Sep 27, 2019
@AlexandreBossard
Copy link

Any update on this?

I have a c++ project which uses conan, cmake and ninja. When configured and built from a subdirectory, for example ${workspaceFolder}/build, all the path given by gcc are of the form '../path/to/file.cpp'. vs code resolves this relative paths from the ${workspaceFolder}, which does not work. Changing the fileLocation does not help. This seem to me a normal workflow, (building from a subdirectory), is there a workaround ?

@bobbrow bobbrow modified the milestones: Post-v1, 0.28.0 Apr 20, 2020
@bobbrow bobbrow added the fixed Check the Milestone for the release in which the fix is or will be available. label Apr 20, 2020
@bobbrow
Copy link
Member

bobbrow commented Apr 20, 2020

Fixed via #3916

@sean-mcmanus
Copy link
Contributor

But the fix won't be available to try until 0.28.0-insiders is released.

@sean-mcmanus
Copy link
Contributor

Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/0.28.0-insiders

@elahehrashedi
Copy link
Contributor

This issue is fixed in 0.28.0.
0.28.0 release: https://github.com/microsoft/vscode-cpptools/releases/tag/0.28.0

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature Request fixed Check the Milestone for the release in which the fix is or will be available. help wanted Can be fixed in the public (open source) repo. Language Service
Projects
None yet
Development

No branches or pull requests

7 participants