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

Allow alterations to the $PATH in an environmentSetupScript to take effect before searching for the CMake executable #2301

Open
bobbrow opened this issue Dec 27, 2021 Discussed in #2299 · 13 comments
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure
Milestone

Comments

@bobbrow
Copy link
Member

bobbrow commented Dec 27, 2021

Discussed in #2299

Currently the extension searches for the CMake executable before environmentSetupScript is evaluated. In the event that the setup script alters the $PATH, those changes won't be in effect when looking for the CMake binary.

@bobbrow bobbrow added enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure labels Dec 27, 2021
@wKavey
Copy link

wKavey commented Jan 25, 2022

+1 for this feature -- I use a python virtual environment to install my desired cmake version, and I'd either need to activate that virtual environment (preferred) or modify the path to point cmake-tools at the correct binary.

@EmilVogt
Copy link

EmilVogt commented Jul 8, 2022

+1, There's unfortunately no documentation on environmentSetupScript and I expected it to run before the first call to cmake.

@jfchenier
Copy link

jfchenier commented Aug 5, 2022

I would not call this a clean solution, but this work for me on both Windows and Linux : I created a single script that can act both as batch and bash script. This script activate my virtual environment then call CMake.

.vsode/settings.json

  "cmake.cmakePath": "${workspaceFolder}/.vscode/run-cmake.cmd",

.vscode/run-cmake.cmd

:<<BATCH
    @echo off
    set SOURCE=%~dp0
    call %SOURCE%..\activate.bat
    @echo on
    call cmake %*
    @echo off
    exit /b
BATCH

SOURCE=$( realpath $( dirname -- "${BASH_SOURCE[0]}"; ); )
source $SOURCE/../activate.sh
cmake "$@"

@alan-wr
Copy link
Contributor

alan-wr commented Oct 25, 2022

@jfchenier
Thanks for you workaround.
But I still get problem.

Now
I create .vscode/run-cmake.cmd, just same as you and

linux-64 - ssh /buildarea/ashi/tmp_ws/z_cmake_failed_prj1/.vscode> /buildarea/ashi/tmp_ws/z_cmake_failed_prj1/.vscode/run-cmake.cmd
Usage

cmake [options]
cmake [options]
cmake [options] -S -B

Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

linux-64 - ssh /buildarea/ashi/tmp_ws/z_cmake_failed_prj1/.vscode> ./run-cmake.cmd -version
cmake version 3.23.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Seems fine now,
But still get error like

Bad CMake executable: "/buildarea/ashi/tmp_ws/z_cmake_failed_prj1/.vscode/run_cmake.cmd". Check to make sure it is installed or the value of the "cmake.cmakePath" setting contains the correct path

@alan-wr
Copy link
Contributor

alan-wr commented Oct 25, 2022

+1, It is better to support environmentSetupScript and then call to cmake.

@jfchenier
Copy link

jfchenier commented Oct 25, 2022

@alan-wr

On some Linux distro, I had to add #!/bin/bash At the top of the run-cmake.cmd script. This cause an error message on Windows, but it can be ignored. Adding this might solve your issue.

@alan-wr
Copy link
Contributor

alan-wr commented Oct 27, 2022

@jfchenier

Typo error

run_cmake.cmd from ".vscode/setting.json"

And run-cmake.cmd from ".vscode/run-cmake.cmd" file.

"_" and "-".

Anyway, fine now.

Many Thanks.

@Pesc0
Copy link

Pesc0 commented Jul 27, 2023

Sorry @bobbrow, can I ask if there's currently any plan to support this feature?

@adrianinsaval
Copy link

From what I'm seeing I think this has to be modified to run environmentSetup script first:

async getCMakePath(wsc: DirectoryContext, overWriteCMakePathSetting?: string): Promise<string | null> {

for reference here's how it's done for the kits:

export async function getShellScriptEnvironment(kit: Kit, opts?: expand.ExpansionOptions): Promise<Environment | undefined> {

I don't know basically anything about typescript so I can't make a PR myself

@gcampbell-msft
Copy link
Collaborator

@Pesc0 @adrianinsaval and others, thanks for all of your comments. I am placing this on our backlog and we will work to prioritize this issue among our other bugs and requests. Thank you!

In the meantime, please up-vote this issue to let us know that it is important to you.

@gcampbell-msft gcampbell-msft added this to the 1.16 milestone Aug 2, 2023
@Pesc0
Copy link

Pesc0 commented Aug 2, 2023

Thank you!

@astronomaestro
Copy link

@gcampbell-msft This would really simplify setting up the debugger for my VS code environment. I currently have a workaround but it is a hack.

@Pesc0
Copy link

Pesc0 commented Oct 13, 2023

@benmcmorran Hey seeing you postponed this issue for the next release, can I please ask if it could get tackled for the current release cycle? Over at FreeCAD we are kinda depending on this to finally have proper integration with VSCode, and the work on that has been stalled for months now. Many thanks in advance :)

@github-project-automation github-project-automation bot moved this to Triage Needed in CMake Tools Nov 29, 2023
@gcampbell-msft gcampbell-msft moved this from Triage Needed to Pending Prioritization in CMake Tools Nov 29, 2023
@gcampbell-msft gcampbell-msft modified the milestones: 1.17, On Deck Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure
Projects
Status: Pending Prioritization
Development

No branches or pull requests

10 participants