# 运行/调试配置

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/clion/llms.txt).

> **TL;DR**
> 配置：  `运行 | 编辑配置`

CLion 使用运行/调试配置来运行、调试和测试您的代码。 每个配置是一组命名的启动属性，用于定义要执行的内容以及应使用的参数和环境。

> **Tip:**
> 本文概述了 CLion 的运行/调试配置概念。 有关更多信息，请参阅 [CMake 应用程序](run-debug-configuration-application.html)、 [本机应用程序](run-debug-configuration-makefile-application.html)、 [自定义构建应用程序](custom-build-targets.html#custom-rundebug) 或 [运行/调试配置](run-debug-configurations-dialog.html) 部分中的其他页面。
>
>
>
> 要快速访问描述特定配置的帮助页面，请在  `运行 | 编辑配置`  中打开其设置并按 `F1` (Windows), `⌘ ⇧ F1` (macOS), `F1` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ F1` (macOS System Shortcuts), `F1` (XWin), `F1` (GNOME), `F1` (KDE), `F1` (Emacs), `F1` (Sublime Text), `⌘ ⇧ F1` (Sublime Text (macOS)), `⌘ ⇧ F1` (Xcode), `F1` (Visual Studio), `F1` (Visual Studio (macOS)), `F1` (ReSharper), `F1` (ReSharper (macOS)), `F1` (QtCreator), `F1` (QtCreator (macOS)), `F1` (NetBeans), `F1` (Eclipse), `⌘ ⇧ F1` (Eclipse (macOS))。

有两种 运行/调试 配置：

* 临时 — 在使用装订区域图标 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.actions.execute.svg)/ ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.runConfigurations.testState.run_run.svg) 运行/调试测试、测试套件、固定例程或 `main()` 条目时创建。

* 永久 —由模板显式创建或通过保存临时配置创建。 永久配置将作为您项目的一部分，直到您删除它们。

每当您运行、调试或测试代码时，CLion 要么使用现有的永久运行/调试配置，要么创建一个新的临时配置。

永久配置的图标是不透明的，而临时配置的图标是半透明的。 配置图标上的红色叉号表示配置设置中存在错误。

临时配置的最大数量为 5。 添加新版本时，旧版本会被自动删除。 如有必要，您可以在  `设置 | 高级设置 | 运行/调试 | 临时配置限制` 中增加此限制。

![永久配置和临时配置有不同的图标](https://resources.jetbrains.com/help/img/idea/2026.3/cl_rdconfigslist_temporary.png)

## 创建永久运行/调试配置

CLion 提供以下方法来创建永久运行/调试配置：

* [将临时运行/调试配置保存为永久配置](#save-as-permanent)。

* [从模板创建](#createExplicitly)或复制现有配置。

Procedure: 将临时配置保存为永久配置

* 在 运行/调试 配置切换器中选择一个临时配置，点击 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.actions.more.svg) 并选择   保存配置  。

![使用配置切换器保存临时配置](https://resources.jetbrains.com/help/img/idea/2026.3/cl_rdconfigslist_temporary_save.png)

* 或者，在“运行/调试配置”对话框中选择一个临时配置，然后点击工具栏上的 ![保存](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.general.save.svg)。

![保存临时配置](https://resources.jetbrains.com/help/img/idea/2026.3/cl_temporaryconfigs_save.png)

CLion 为不同的语言、工具和框架提供运行/调试配置 [模板](#templates)。 可用模板的列表会因已安装和启用的 [plugins](managing-plugins.html) 而有所不同。

Procedure: 从模板创建运行/调试配置

1. 转到  `运行 | 编辑配置` 。 或者，按 `Alt+Shift+F10` (Windows), `⌃ ⌥ R` (macOS), `⌥ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ R` (macOS System Shortcuts), `Alt+Shift+F10` (XWin), `Alt+Shift+F10` (GNOME), `Alt+Shift+F10` (KDE), `Alt+Shift+F10` (Emacs), `Alt+Shift+F10` (Sublime Text), `⌃ ⌥ R` (Sublime Text (macOS)), `⌘ ⌃ ⌥ ⇧ R` (Xcode), `Ctrl+Alt+Shift+R` (Visual Studio), `⌘ ⌥ ⇧ R` (Visual Studio (macOS)), `Ctrl+Alt+Shift+R` (ReSharper), `⌘ ⌥ ⇧ R` (ReSharper (macOS)), `Ctrl+T` (QtCreator), `⌘ T` (QtCreator (macOS)), `Alt+Shift+F10` (NetBeans), `Alt+Shift+F10` (Eclipse), `⌃ ⌥ R` (Eclipse (macOS))，然后 `0` (Windows), `0` (macOS), `0` (IntelliJ IDEA Classic (macOS)), `0` (macOS System Shortcuts), `0` (XWin), `0` (GNOME), `0` (KDE), `0` (Emacs), `0` (Sublime Text), `0` (Sublime Text (macOS)), `0` (Xcode), `0` (Visual Studio), `0` (Visual Studio (macOS)), `0` (ReSharper), `0` (ReSharper (macOS)), `0` (QtCreator), `0` (QtCreator (macOS)), `0` (NetBeans), `0` (Eclipse), `0` (Eclipse (macOS))。

2. 在   运行/调试配置  对话框中，点击工具栏上的 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)或按 `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌥ Insert` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS))。 该列表显示运行/调试配置模板。

![新建运行/调试配置](https://resources.jetbrains.com/help/img/idea/2026.3/cl_addconfiguration.png)

3. 在   名称   字段中指定运行/调试配置名称。 此名称将用于在列表和菜单中标识运行/调试配置。

4. 如果您希望允许同时运行多个配置实例，请选择   允许多个实例  。 如果禁用此选项，尝试重新运行配置将终止活动会话。

5. 根据选择的模板，填写配置设置。 例如， [CMake 应用程序](quick-cmake-tutorial.html#targets-configs)、 [自定义构建应用程序](custom-build-targets.html#custom-rundebug)、 [Gradle / Gradle 本机应用程序](gradle-support.html#CreateConfig)。

6. 在   启动前   部分中，定义是否要在启动应用程序之前执行任何特定操作，例如启动一个 [外部工具](configuring-third-party-tools.html) 或另一个构建配置。 要跳过构建阶段，请从   启动前   列表中移除   构建  。

7. 您可以立即运行该配置，也可以保存配置以便稍后运行。

* 要保存运行配置以供稍后运行，请点击 确定 。

* 若要立即运行此配置，请点击 运行 。

### 启动前

在此区域，您可以指定在启动所选运行/调试配置之前要执行的任务。 任务按它们在列表中出现的顺序执行。

|  项  |  快捷方式  |  描述  |
| --- | --- | --- |
|  ![添加按钮](https://resources.jetbrains.com/help/img/idea/2026.3/调试配置](run-debug-multiple.html#compound-configs)。    * 运行 File Watchers​ ：选择此选项以让 CLion 应用所有当前活动的 [文件监视器](using-file-watchers.html)。    * 运行 Grunt 任务 ：选择此选项来运行 Grunt 任务。 在打开的 Grunt 任务 对话框中，指定定义所需任务的 `Gruntfile.js` ，选择要执行的任务，并指定传递给 Grunt 工具的参数。 指定 Node.js 解释器的位置、传递给它的参数以及 grunt-cli 包的路径。    * 运行 Gulp 任务 ：选择此选项以运行 Gulp task。 在打开的 Gulp 任务 对话框中，指定定义所需任务的 `Gulpfile.js` ，选择要执行的任务，并指定要传递给 Gulp 工具的参数。 指定 Node.js 运行时的位置、要传递给它的参数，以及 gulp 包的路径。    * 运行 npm 脚本 ：选择此选项来执行 npm 脚本。 在 NPM Script 对话框中，指定 [npm run/debug configuration settings](null)。    * 编译 TypeScript ：选择运行内置的 TypeScript 编译器，从而确保您对 TypeScript 代码所做的所有更改都反映在生成的 JavaScript 文件中。 在打开的 TypeScript 编译设置 对话框中，选择或清除此 检查错误 复选框，以配置编译器在检测到错误时的行为: * 如果选中了 检查错误 复选框，编译器会显示所有错误，并且运行配置将不会启动。 * 如果清除了 检查错误 复选框，编译器将显示所有检测到的错误，但运行配置仍将启动。    * 生成 CoffeeScript 源地图 ：选择此选项以生成 [CoffeeScript](coffeescript.html) 源代码的源映射。 在打开的对话框中，指定您的 CoffeeScript 源文件所在的位置。    |
|  !["移除"按钮](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg)  |  `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `⌘ ⌦` (Xcode), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (ReSharper), `⌥ ⌦` (ReSharper (macOS)), `Alt+Delete` (QtCreator), `⌘ ⌦` (QtCreator (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS))  |  点击此图标可将所选任务从列表中移除。  |
|  ![编辑](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.edit.svg)  |  `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `⏎` (Xcode), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (ReSharper), `⏎` (ReSharper (macOS)), `Enter` (QtCreator), `⏎` (QtCreator (macOS)), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS))  |  点击此图标可编辑选定的任务。 在打开的对话框中进行必要的更改。  |
|     ![方法向上](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.moveUp.svg)       ![方法 down](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.moveDown.svg)     |     `Alt+Up` (Windows), `⌃ ⇧ ↑` (macOS), `⌃ ↑` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ ↑` (macOS System Shortcuts), `Alt+Up` (XWin), `Alt+Up` (GNOME), `Alt+Up` (KDE), `Alt+Up` (Emacs), `Alt+Up` (Sublime Text), `Alt+Up` (Sublime Text (macOS)), `⌥ ↑` (Xcode), `Alt+Up` (Visual Studio), `⌃ ⇧ ↑` (Visual Studio (macOS)), `Alt+Up` (ReSharper), `⌃ ⇧ ↑` (ReSharper (macOS)), `Alt+Up` (QtCreator), `⌃ ⇧ ↑` (QtCreator (macOS)), `Ctrl+Alt+Up` (NetBeans), `Ctrl+Shift+Up` (Eclipse), `⌃ ⌥ ↑` (Eclipse (macOS))       `Alt+Down` (Windows), `⌃ ⇧ ↓` (macOS), `⌃ ↓` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ ↓` (macOS System Shortcuts), `Alt+Down` (XWin), `Alt+Down` (GNOME), `Alt+Down` (KDE), `Alt+Down` (Emacs), `Alt+Down` (Sublime Text), `Alt+Down` (Sublime Text (macOS)), `⌥ ↓` (Xcode), `Alt+Down` (Visual Studio), `⌃ ⇧ ↓` (Visual Studio (macOS)), `Alt+Down` (ReSharper), `⌃ ⇧ ↓` (ReSharper (macOS)), `Alt+Down` (QtCreator), `⌃ ⇧ ↓` (QtCreator (macOS)), `Ctrl+Alt+Down` (NetBeans), `Ctrl+Shift+Down` (Eclipse), `⌃ ⌥ ↓` (Eclipse (macOS))     |  点击这些图标以在列表中将所选任务上移或下移一行。 任务将按照它们在列表中出现的顺序执行。  |
|  显示此页面  |  |  选择此复选框，以便在实际启动运行/调试配置之前显示运行/调试配置设置。  |
|  激活工具窗口  |  |     默认情况下，此复选框处于选中状态，并且在您启动 run/debug 配置时， [Run](run-tool-window.html) 或 [Debug](debug-tool-window.html) 工具窗口会打开。       否则，如果复选框未选中，工具窗口将被隐藏。 但是，当配置正在运行时，您可以通过按 `Alt+4` (Windows), `⌘ 4` (macOS), `⌘ 4` (IntelliJ IDEA Classic (macOS)), `⌘ 4` (macOS System Shortcuts), `Alt+4` (XWin), `Alt+4` (GNOME), `Alt+4` (KDE), `Alt+4` (Emacs), `Alt+4` (Sublime Text), `⌘ 4` (Sublime Text (macOS)), `⌘ 6` (Xcode), `Alt+4` (Visual Studio), `⌘ 4` (Visual Studio (macOS)), `Alt+4` (ReSharper), `⌘ 4` (ReSharper (macOS)), `Alt+3` (QtCreator), `⌘ 3` (QtCreator (macOS)), `Alt+4` (NetBeans), `Alt+4` (Eclipse), `⌘ 4` (Eclipse (macOS)) 或 `Alt+5` (Windows), `⌘ 5` (macOS), `⌘ 5` (IntelliJ IDEA Classic (macOS)), `⌘ 5` (macOS System Shortcuts), `Alt+5` (XWin), `Alt+5` (GNOME), `Alt+5` (KDE), `Alt+5` (Emacs), `Alt+5` (Sublime Text), `⌘ 5` (Sublime Text (macOS)), `⌘ 7` (Xcode), `Alt+5` (Visual Studio), `⌘ 5` (Visual Studio (macOS)), `Alt+5` (ReSharper), `⌘ 5` (ReSharper (macOS)), `Alt+5` (QtCreator), `⌘ 5` (QtCreator (macOS)), `Alt+5` (NetBeans), `Alt+5` (Eclipse), `⌘ 5` (Eclipse (macOS)) 自行打开相应的工具窗口。     |
|  聚焦工具窗口  |  |     选中此复选框以在启动运行/调试配置时自动将焦点移至 [Run](run-tool-window.html) 或 [Debug](debug-tool-window.html) 工具窗口。     |

## 共享运行/调试配置

您可能希望共享您的 运行/调试 配置，以便您的团队成员可以使用相同的配置运行应用程序，或者使他们能够远程附加到您正在运行的进程。

CLion 提供了一种机制，可以将您的 运行/调试 配置存储为项目文件并通过 VCS 共享。 当您希望将配置作为文件发送给其他人、创建运行/调试配置的本地备份或从文件导入它们时，也可以使用相同的机制。

Procedure:

1. 转到  `运行 | 编辑配置` 。 或者，按 `Alt+Shift+F10` (Windows), `⌃ ⌥ R` (macOS), `⌥ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ R` (macOS System Shortcuts), `Alt+Shift+F10` (XWin), `Alt+Shift+F10` (GNOME), `Alt+Shift+F10` (KDE), `Alt+Shift+F10` (Emacs), `Alt+Shift+F10` (Sublime Text), `⌃ ⌥ R` (Sublime Text (macOS)), `⌘ ⌃ ⌥ ⇧ R` (Xcode), `Ctrl+Alt+Shift+R` (Visual Studio), `⌘ ⌥ ⇧ R` (Visual Studio (macOS)), `Ctrl+Alt+Shift+R` (ReSharper), `⌘ ⌥ ⇧ R` (ReSharper (macOS)), `Ctrl+T` (QtCreator), `⌘ T` (QtCreator (macOS)), `Alt+Shift+F10` (NetBeans), `Alt+Shift+F10` (Eclipse), `⌃ ⌥ R` (Eclipse (macOS))，然后 `0` (Windows), `0` (macOS), `0` (IntelliJ IDEA Classic (macOS)), `0` (macOS System Shortcuts), `0` (XWin), `0` (GNOME), `0` (KDE), `0` (Emacs), `0` (Sublime Text), `0` (Sublime Text (macOS)), `0` (Xcode), `0` (Visual Studio), `0` (Visual Studio (macOS)), `0` (ReSharper), `0` (ReSharper (macOS)), `0` (QtCreator), `0` (QtCreator (macOS)), `0` (NetBeans), `0` (Eclipse), `0` (Eclipse (macOS))。

2. 请选择您要共享的 运行/调试 配置，启用   存储为项目文件  选项，并指定配置文件的存储位置。

您可以配置任何位置，除非需要与 CLion 2019.3 及更早版本兼容。 为了与这些版本兼容，请将文件存储在建议的位置。

![存储配置文件](https://resources.jetbrains.com/help/img/idea/2026.3/cl_rdconfigs_share.png)

3. （可选）如果将  `.idea` 目录添加到 VCS 忽略文件中，那么  `.idea/runConfigurations` 子文件夹也将被忽略。 如果项目使用 Git，您可以共享  `.idea/runConfigurations`  并保留  `.idea`  被忽略，通过修改  `.gitignore`  如下：

```
/.idea/*
!/.idea/runConfigurations

```

> **Note:**
> 启用   存储为项目文件   选项不会将任何内容提交到 VCS。 为了使 运行/调试 配置进入共享存储库，您必须像其他版本化文件一样将它们签入。

## 运行/调试配置模板

所有运行/调试配置都基于模板，这些模板实现了启动逻辑，定义参数列表及其默认值。 安装中预定义了 [可用模板列表](null)，只能通过 [插件](managing-plugins.html)进行扩展。 但是，您可以编辑每个模板中的默认参数值，以便于新运行/调试配置的设置。

Procedure: 配置模板的默认值

1. 转到  `运行 | 编辑配置` 。 或者，按 `Alt+Shift+F10` (Windows), `⌃ ⌥ R` (macOS), `⌥ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ R` (macOS System Shortcuts), `Alt+Shift+F10` (XWin), `Alt+Shift+F10` (GNOME), `Alt+Shift+F10` (KDE), `Alt+Shift+F10` (Emacs), `Alt+Shift+F10` (Sublime Text), `⌃ ⌥ R` (Sublime Text (macOS)), `⌘ ⌃ ⌥ ⇧ R` (Xcode), `Ctrl+Alt+Shift+R` (Visual Studio), `⌘ ⌥ ⇧ R` (Visual Studio (macOS)), `Ctrl+Alt+Shift+R` (ReSharper), `⌘ ⌥ ⇧ R` (ReSharper (macOS)), `Ctrl+T` (QtCreator), `⌘ T` (QtCreator (macOS)), `Alt+Shift+F10` (NetBeans), `Alt+Shift+F10` (Eclipse), `⌃ ⌥ R` (Eclipse (macOS))，然后 `0` (Windows), `0` (macOS), `0` (IntelliJ IDEA Classic (macOS)), `0` (macOS System Shortcuts), `0` (XWin), `0` (GNOME), `0` (KDE), `0` (Emacs), `0` (Sublime Text), `0` (Sublime Text (macOS)), `0` (Xcode), `0` (Visual Studio), `0` (Visual Studio (macOS)), `0` (ReSharper), `0` (ReSharper (macOS)), `0` (QtCreator), `0` (QtCreator (macOS)), `0` (NetBeans), `0` (Eclipse), `0` (Eclipse (macOS))。

2. 在 运行/调试 配置对话框的左侧窗格中，点击   编辑配置模板…  。

3. 在打开的   运行/调试配置模板​​  对话框中，选择一个配置类型。

4. 请指定所需的默认参数，然后点击   确定   以保存模板。

![编辑配置模板](https://resources.jetbrains.com/help/img/idea/2026.3/cl_rdconfigs_template_settings.png)

> **Tip:**
> 您可以像常规运行/调试配置一样与您的团队成员 [共享运行/调试配置模板](#share-configurations)。

## 环境变量和程序参数

您可以通过向合适的运行/调试配置添加程序参数和环境变量来影响应用程序的运行时行为。

> **Tip:**
> 配置环境仅影响运行/调试过程，不影响构建或其他阶段，例如 CMake 生成。 有关更多信息，请参阅 [工具链环境](how-to-create-toolchain-in-clion.html#env-scripts) 和 [CMake 环境](cmake-profile.html#EnvVariables)。

Procedure:

1. 转到  `运行 | 编辑配置` 。 或者，按 `Alt+Shift+F10` (Windows), `⌃ ⌥ R` (macOS), `⌥ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ R` (macOS System Shortcuts), `Alt+Shift+F10` (XWin), `Alt+Shift+F10` (GNOME), `Alt+Shift+F10` (KDE), `Alt+Shift+F10` (Emacs), `Alt+Shift+F10` (Sublime Text), `⌃ ⌥ R` (Sublime Text (macOS)), `⌘ ⌃ ⌥ ⇧ R` (Xcode), `Ctrl+Alt+Shift+R` (Visual Studio), `⌘ ⌥ ⇧ R` (Visual Studio (macOS)), `Ctrl+Alt+Shift+R` (ReSharper), `⌘ ⌥ ⇧ R` (ReSharper (macOS)), `Ctrl+T` (QtCreator), `⌘ T` (QtCreator (macOS)), `Alt+Shift+F10` (NetBeans), `Alt+Shift+F10` (Eclipse), `⌃ ⌥ R` (Eclipse (macOS))，然后 `0` (Windows), `0` (macOS), `0` (IntelliJ IDEA Classic (macOS)), `0` (macOS System Shortcuts), `0` (XWin), `0` (GNOME), `0` (KDE), `0` (Emacs), `0` (Sublime Text), `0` (Sublime Text (macOS)), `0` (Xcode), `0` (Visual Studio), `0` (Visual Studio (macOS)), `0` (ReSharper), `0` (ReSharper (macOS)), `0` (QtCreator), `0` (QtCreator (macOS)), `0` (NetBeans), `0` (Eclipse), `0` (Eclipse (macOS))。

2. 在打开的 [运行/调试配置](run-debug-configuration-application.html)对话框中，选择一个您希望传递参数并添加环境变量的配置。

3. 在   程序参数   字段中输入参数。 参数应以空格或换行符分隔。

点击 ![展开字段图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.general.expandComponent.svg) 以展开文本字段，这样您可以将参数作为列表查看和编辑。

4. 在   环境变量   字段中输入变量名称和值：  `<name>=<value>` 。 如果添加多个变量，它们应以分号分隔。

或者，点击 ![环境变量图标](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.inline.variables.svg)并将变量名称和值添加到   用户环境变量  列表。

![添加环境变量](https://resources.jetbrains.com/help/img/idea/2026.3/cl_configs_envvariables.png)

在打开的对话框中，您还可以看到可用的系统环境变量列表。 清除   系统环境变量   复选框，如果您不想为所选配置使用系统环境变量。

您可以使用  `$VAR$`  语法引用现有变量，包括父环境变量。 请注意，此类引用区分大小写：例如，  `PATH=xxx:$PATH$` 用于 Linux/macOS，  `Path=xxx;$Path$` 用于 Windows。 引用现有变量目前不适用于 [远程工具链](remote-projects-support.html)（ [CPP-15693](https://youtrack.jetbrains.com/issue/CPP-15693)）。

> **Tip:**
> 另请参阅 [CMake 环境](cmake-profile.html#EnvVariables)。

5. 使用   从文件加载变量   字段指向 CLion 的脚本，该脚本配置环境。 此选项适用于 [CMake](run-debug-configuration-application.html)、 [Makefile](run-debug-configuration-makefile-application.html)、 [Gradle 本机](run-debug-configuration-gradle-native-application.html)、 [自定义构建](custom-build-targets.html#custom-rundebug) 和测试配置（ [Boost.Test](run-debug-configuration-boost-test.html)、 [Catch](run-debug-configuration-catch.html)、 [Google Test](run-debug-configuration-google-test.html)、 [Doctest](doctest-support.html#doctest-config)、 [CTest](ctest-application.html)）。

![从文件加载环境变量](https://resources.jetbrains.com/help/img/idea/2026.3/cl_envvariables_script.png)

在脚本中设置变量时使用以下语法：

Windows:

```SHELL
set VAR=value
```

Linux/macOS:

```SHELL
export VAR=value
```

请注意，由脚本创建的环境仅适用于相应配置的一次启动，并优先于自定义值。

指定的脚本将在所有   启动前   步骤完成后运行。

## 运行/调试配置文件夹

当有许多相同类型的 运行/调试 配置时，您可以将它们分组到文件夹中以便于访问。

![分组运行配置](https://resources.jetbrains.com/help/img/idea/2026.3/cl_runConfigFolder.png)

Procedure: 为运行/调试配置创建一个文件夹

1. 转到  `运行 | 编辑配置` 。 或者，按 `Alt+Shift+F10` (Windows), `⌃ ⌥ R` (macOS), `⌥ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ R` (macOS System Shortcuts), `Alt+Shift+F10` (XWin), `Alt+Shift+F10` (GNOME), `Alt+Shift+F10` (KDE), `Alt+Shift+F10` (Emacs), `Alt+Shift+F10` (Sublime Text), `⌃ ⌥ R` (Sublime Text (macOS)), `⌘ ⌃ ⌥ ⇧ R` (Xcode), `Ctrl+Alt+Shift+R` (Visual Studio), `⌘ ⌥ ⇧ R` (Visual Studio (macOS)), `Ctrl+Alt+Shift+R` (ReSharper), `⌘ ⌥ ⇧ R` (ReSharper (macOS)), `Ctrl+T` (QtCreator), `⌘ T` (QtCreator (macOS)), `Alt+Shift+F10` (NetBeans), `Alt+Shift+F10` (Eclipse), `⌃ ⌥ R` (Eclipse (macOS))，然后 `0` (Windows), `0` (macOS), `0` (IntelliJ IDEA Classic (macOS)), `0` (macOS System Shortcuts), `0` (XWin), `0` (GNOME), `0` (KDE), `0` (Emacs), `0` (Sublime Text), `0` (Sublime Text (macOS)), `0` (Xcode), `0` (Visual Studio), `0` (Visual Studio (macOS)), `0` (ReSharper), `0` (ReSharper (macOS)), `0` (QtCreator), `0` (QtCreator (macOS)), `0` (NetBeans), `0` (Eclipse), `0` (Eclipse (macOS))。

2. 在   运行/调试配置  对话框中，选择配置类型并在工具栏上点击 ![新建文件夹图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.actions.newFolder.svg)。 已创建一个新的空文件夹用于所选类型。

3. 请在右侧的文本框中指定文件夹名称或接受默认名称。

4. 选择所需的 运行/调试 配置并将它们移动到目标文件夹下。

![创建运行/调试配置文件夹](https://resources.jetbrains.com/help/img/idea/2026.3/调试配置对话框](run-debug-configurations-dialog.html) [CMake Application](run-debug-configuration-application.html) [Native Application](run-debug-configuration-makefile-application.html) [Custom Build Application](custom-build-targets.html#custom-rundebug)

### 外部链接

[JetBrains CLion Blog](http://blog.jetbrains.com/clion/)

