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

CMakePresets fail to load on RedHat. Error on Output: Invalid variable reference ${which_declare} #3961

Closed
pilarArr opened this issue Aug 7, 2024 · 6 comments · Fixed by #3997
Assignees
Labels
bug a bug in the product
Milestone

Comments

@pilarArr
Copy link

pilarArr commented Aug 7, 2024

Brief Issue Summary

Issue Related to #1841

I'm not able to produce an example repo.
But I'll try to layout a MWE.
Since it's the presets loading that fails. I don't think the rest of the project does matter.

My project layout would be somethin like this

(root)
├── CMakePresets.json
├── CMakeLists.txt
├── scr
│   ├── hello_world.c
├── include
│   ├── hello_world.h

This would be my CMakePresets.json file:

{
  "version": 7,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 27,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "base",
      "hidden": true,
      "binaryDir": "${sourceDir}/build/${presetName}",
      "cacheVariables": {
        "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/${presetName}/delivery",
        "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
      }
    },
    {
      "name": "windows_only",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "linux_only",
      "hidden": true,
      "condition": {
        "type": "notEquals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "VS2019_x64_config",
      "inherits": ["base"],
      "hidden": true,
      "generator": "Visual Studio 16 2019",
      "toolset": {
        "value": "host=x64",
        "strategy": "set"
      },
      "architecture": {
        "value": "x64",
        "strategy": "set"
      }
    },
    {
      "name": "VS2019_NoTests_config",
      "inherits": ["VS2019_x64_config", "windows_only"],
      "displayName": "VS2019 NoTests"
    },
    {
      "name": "mai001_NinjaMulti_GCC_13_64bits",
      "inherits": ["base"],
      "cacheVariables": {
        "CMAKE_C_COMPILER": "/usr/local/bin/gcc",
        "CMAKE_CXX_COMPILER": "/usr/local/bin/g++"
      },
      "hidden": true,
      "generator": "Ninja Multi-Config"
    },
    {
      "name": "mai001_NoTests_config",
      "inherits": ["mai001_NinjaMulti_GCC_13_64bits", "linux_only"],
      "displayName": "mai001 NoTests"
    }
  ],
  "buildPresets": [
    {
      "name": "build_base",
      "inheritConfigureEnvironment": true
    },
    {
      "name": "VS2019_NoTests_build",
      "configurePreset": "VS2019_NoTests_config",
      "inherits": ["build_base"],
      "displayName": "Release"
    }
  ]
}

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.88.0",
  "cmtVersion": "1.19.36",
  "configurations": [
    {
      "folder": "/my_folder/test_example",
      "cmakeVersion": "3.27.7",
      "configured": false,
      "generator": "",
      "usesPresets": true,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "always",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[proc] Executing command: /opt/cmake-3.27.7-linux-x86_64/bin/cmake --version
[proc] Executing command: /opt/cmake-3.27.7-linux-x86_64/bin/cmake -E capabilities
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[expand] expanded ${workspaceFolder}
[kit] Reading kits file /home/user/.local/share/CMakeTools/cmake-tools-kits.json
[kit] Successfully loaded 4 kits from /home/user/.local/share/CMakeTools/cmake-tools-kits.json
[kit] Not reading non-existent kits file: /myfolder/test_example/.vscode/cmake-kits.json
[presetController] Reading presets file /myfolder/test_example/CMakePresets.json
[presetController] Reading and validating the presets "file /myfolder/test_example/CMakePresets.json"
[presetController] Successfully validated /myfolder/test_example/CMakePresets.json against presets schema
[presetController] Expanding presets file /myfolder/test_example/CMakePresets.json
[proc] Executing command: uname -s
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded ${sourceDir}/build/${presetName}
[preset] Configure preset windows_only: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[preset] Configure preset linux_only: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[expand] expanded ${sourceDir}/build/${presetName}
[expand] expanded ${sourceDir}/build/${presetName}
[expand] expanded ${sourceDir}/build/${presetName}
[expand] expanded ${sourceDir}/build/${presetName}
[expand] expanded ${sourceDir}/build/${presetName}/delivery
[expand] expanded ${hostSystemName}
[expand] expanded ${hostSystemName}
[expand] expanded ${sourceDir}/build/${presetName}/delivery
[expand] expanded ${sourceDir}/build/${presetName}/delivery
[expand] expanded ${sourceDir}/build/${presetName}/delivery
[expand] expanded ${sourceDir}/build/${presetName}/delivery
[expand] expanded ${hostSystemName}
[expand] expanded ${hostSystemName}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded ${sourceDir}/build/${presetName}
[expand] expanded ${sourceDir}/build/${presetName}/delivery
[expand] expanded ${hostSystemName}
[expand] Invalid variable reference ${which_declare} in string: () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[expand] expanded () {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
[presetController] Expansion errors found in the presets file.
[main] CMakeProject instance initialization complete.
[extension] Attempting to use cache to configure workspace file:///myfolder/test_example
[main] Starting new CMake driver
[main] Starting CMake driver
[cmakefileapi-driver] Creating instance of CMakeFileApiDriver
[driver] Initializing base driver using preset
[main] Unable to configure with existing cache

Additional Information

Using CMakeTools 1.18.19 works.

Visual Studio Code v1.88.0
CMakeTools 1.19.36
OS information
NAME="Red Hat Enterprise Linux"
VERSION="9.0 (Plow)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="9.0"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Red Hat Enterprise Linux 9.0 (Plow)"

EDIT: pressed enter before finishing issue.

@pilarArr
Copy link
Author

pilarArr commented Aug 7, 2024

Tested the vsix provided on #3959 (comment) and it does not solve the problem. Same error.

@gcampbell-msft
Copy link
Collaborator

@pilarArr I'm curious if you have some answers that might help investigate.

Where is this ${which_declare} defined? Is it defined as an environment variable itself?

@pilarArr
Copy link
Author

pilarArr commented Aug 7, 2024

@gcampbell-msft I found these mentions to which_declare on the env,
but I haven't touched that, I believe that is just how it is out of the box.

BASH_FUNC_which%%=() {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}
which_declare=typeset -f

@gcampbell-msft
Copy link
Collaborator

Is this defined in the environment variables for the linux installs?

@pilarArr
Copy link
Author

pilarArr commented Aug 7, 2024

that would be the default environment on login

@gcampbell-msft gcampbell-msft added this to the 1.19 milestone Aug 7, 2024
@gcampbell-msft gcampbell-msft added bug a bug in the product and removed triage labels Aug 7, 2024
@gcampbell-msft gcampbell-msft moved this from Blocked to In Progress in CMake Tools Aug 7, 2024
@Yingzi1234
Copy link
Collaborator

Yingzi1234 commented Aug 15, 2024

@pilarArr Based on the file information you provided for CMakePresets.json, we are unable to surface your issue on Linux platform and we can Configure success. In order to better solve your problem, could you provide me your reproduction file and reproduction steps? Thank you in advance!
image

@github-project-automation github-project-automation bot moved this from In Progress to Completed in CMake Tools Aug 21, 2024
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
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

4 participants