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

CMake tools not honoring absolute path #3475

Closed
wjk opened this issue Nov 30, 2023 · 9 comments
Closed

CMake tools not honoring absolute path #3475

wjk opened this issue Nov 30, 2023 · 9 comments
Assignees
Labels
bug a bug in the product Feature: build more info needed More info is needed from the community for us to properly triage and investigate.
Milestone

Comments

@wjk
Copy link

wjk commented Nov 30, 2023

Brief Issue Summary

I have a project. When I configure it in VSCode, I get an error stating that the names of the C and C++ compiler binaries are not found in the system path. These binaries cannot be put in the path due to the fact that the OS launches VSCode for me, instead of my running the binary directly, so I have no way to influence its environment. However, these binaries’ absolute paths are located in the CMakeCache.txt, and are correct. VSCode configures CMake just fine, but then it complains that it cannot find the compilers and as such all editor features are disabled. The build does not fail, as long as I only use the command line. What can I do about this?

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

The log fields were too big for GitHub to handle, so I have attached them as files below.

This is the CMake > Log Diagnostics output.
This is what I find in the output window when running under debug logging.

@gcampbell-msft gcampbell-msft added bug a bug in the product Feature: build and removed triage labels Dec 4, 2023
@gcampbell-msft
Copy link
Collaborator

@wjk Thanks for notifying us of this. This definitely seems like a bug that we should investigate.

Are you using this on Linux? Or is this possibly an Msys environment? Any more info about your environment may be helpful to us when we investigate.

@gcampbell-msft gcampbell-msft added this to the On Deck milestone Dec 4, 2023
@wjk
Copy link
Author

wjk commented Dec 4, 2023

macOS 14, actually. My apologies for leaving this out of the original report.

@gcampbell-msft gcampbell-msft modified the milestones: On Deck, 1.17 Dec 12, 2023
@lukka lukka self-assigned this Dec 19, 2023
@lukka
Copy link
Member

lukka commented Jan 12, 2024

@wjk thank you for reporting this issue! I have forked your project repository and added a CMakePresets.json (which is the recommended way to use CMake with), and I got IntelliSense working in the C/C++ files. Here my steps:

  • using a Linux Ubuntu WSL2 Ubuntu 22.04.1 LTS (jammy).
  • cloned the repository git@github.com:lukka/ReactOS.git .
  • Running: sudo add-apt-repository ppa:reactos/rosbe-unix and sudo apt install rosbe-unix to install the RosBE environment.
  • Launching the build environment with: /usr/RosBE/RosBE.sh .
  • From the RosBE shell (and its environment), I started up code and opened the folder of the repository.
  • Using the CMakePresets.json I could configure and build the source code and have the IntelliSense working, here the output of configure and build: configure-and-build.txt

Let us know if leveraging a CMakePresets.json is a viable way for you as well and also if this is going to help you working on your codebase. If you are experiencing any problem just reach out to me. And if CMakePresets.json is not not possible to be used for you, we'd need to repro the problem with the kit files on your system at /Users/williamkent/.local/share/CMakeTools/cmake-tools-kits.json.
Please keep the feedback coming and thank you for the detailed report!

@wjk
Copy link
Author

wjk commented Jan 12, 2024

Unfortunately, your steps don’t work for me at all, because I am using macOS and not Linux or Windows. I have no way to influence the PATH or environment of the VSCode process.

@lukka
Copy link
Member

lukka commented Jan 16, 2024

@wjk given that macOS and Linux are both unix-like OSes, I thought it could be possible to follow the steps from "Launching the build environment with /usr/RosBE/RosBE.sh" (included) onward. I hope it is possible for you to install the RosBE environment on macOS using the RosBE Unix archive (provided here) .

An additional thought: do you think it would help if you could describe your steps as I've done so that I can try to repro this issue on macOS? I am looking forward to see how you install RosBE, how you spawn the build environment, and how you start vscode.

@gcampbell-msft gcampbell-msft added the more info needed More info is needed from the community for us to properly triage and investigate. label Jan 16, 2024
@wjk
Copy link
Author

wjk commented Jan 16, 2024

I have very much installed the RosBE tools, but it does not matter. I can run RosBE.sh as much as I want, but if I launch VSCode, it will be forked from a system process that I have no way to touch. I cannot put any environment variables into the VSCode process.

@lukka
Copy link
Member

lukka commented Jan 18, 2024

@wjk please note that in the steps I described in this message, VS Code is being launched by the RosBE environment prompt, hence it runs inside the build environment: this is accomplished by launching from a terminal the ReactOS Build Environment (in my case launching command /usr/RosBE/RosBE.sh, where it was installed), and then from the same terminal at the RosBE prompt I launched code, which is the executable launching up VS Code. At that point, VS Code is running inside the RosBE environment, and all the environment variables are the ones defined by RosBE. This is leveraging the knowledge that a process inherits the initial environment (e.g., the environment variables) from the process it was spawn from.

Is this a viable approach for you? Let us know!

@wjk
Copy link
Author

wjk commented Jan 18, 2024

It works!

@lukka
Copy link
Member

lukka commented Jan 19, 2024

@wjk thank you for reporting back! Let us know if you encounter other problems or have any suggestion!

Note: The following feature described at microsoft/vscode#152806 was proposed time ago and it would help supporting scenario similar to the RosBE where the build needs to run in a specially crafted environment. Since that feature has not moved forward from its initial proposal, the only solution nowadays is to start the VS Code process from the required environment as suggested in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: build more info needed More info is needed from the community for us to properly triage and investigate.
Projects
Status: Completed
Development

No branches or pull requests

3 participants