# パス変数

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

パス変数は、絶対ファイルシステムパスのプレースホルダーです。 これにより、ハードコードされた絶対パスを名前付き変数に置き換えることができます。 その結果、プロジェクトの設定を異なるマシン間で移植することが可能になります。

Because such resources may be located in different places on each developer’s computer, user-defined path variables are stored as [global IDE settings](configuring-project-and-ide-settings.html) rather than [project settings](configure-project-settings.html) . プロジェクトには変数名のみが保存され、各開発者はローカルでその値を定義します。 Once configured, a path variable has the same value for all projects opened in your instance of CLion.

CLion には、ホームディレクトリ用の  `$USER_HOME$`  と、プロジェクトが格納されているディレクトリ用の  `$PROJECT_DIR$`  の 2 つの定義済み変数があります。

You can refer to path variables when configuring [external tools](configuring-third-party-tools.html) and run/debug configurations of the following types:

* [CMake アプリケーション](run-debug-configuration-application.html)

* [カスタムビルドアプリケーション](custom-build-targets.html#custom-rundebug)

* [Gradle ネイティブアプリケーション](run-debug-configuration-gradle-native-application.html)

> **Note:**
> Path variables can't be used in [CMakeLists.txt](cmakelists-txt-file.html) scripts.

Procedure: パス変数を作成して使用する

例: プログラムがファイルから入力データを取得する場合、ファイルの場所のパス変数を作成し、VCS を通じてチームメイトと共有する実行 / デバッグ構成でこの変数を参照できます。

1. `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `⌘ Comma` (Xcode), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (ReSharper), `⌘ Comma` (ReSharper (macOS)), `Ctrl+Alt+S` (QtCreator), `⌘ Comma` (QtCreator (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) を押して設定を開き、  `外観 & 振る舞い | パス変数`  を選択します。

2. ![追加ボタン](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg) をクリックして、新しい変数の名前（たとえば、  `DATA_PATH`  ）と、ディスク上のデータファイルを含むターゲットディレクトリを指す値を入力します。

![新しいパス変数を作成する](https://resources.jetbrains.com/help/img/idea/2026.3/cl_pathvariables_create.png)

3. 構成設定で、必須フィールドの ![追加ボタン](https://resources.jetbrains.com/help/img/idea/2026.3/app.general.add_dark.svg) （この例では   入力をリダイレクト   ）をクリックします。   マクロ   ダイアログで変数を選択します。

![構成でのパス変数の使用](https://resources.jetbrains.com/help/img/idea/2026.3/cl_pathvariables_rdconfig.png)

4. プロジェクトファイルとして保存する。   チェックボックスを設定し、設定を含むファイルを保存する場所を指定します。

![構成をファイルに保存する](https://resources.jetbrains.com/help/img/idea/2026.3/cl_rdconfig_withpathvariable_share.png)

5. このファイル（デフォルトでは  `<project directory>.idea/runConfiguration/<configuration name>.xml`  ）の内容を確認できます。

![構成の .xml ファイル内のパス変数](https://resources.jetbrains.com/help/img/idea/2026.3/cl_rdconfig_xml_pathvariable.png)

6. VCS を介してこの  `.xml`  ファイルを共有すると、チームメイトは  `$DATA_PATH$`  を含む構成を取得し、入力データファイルの場所を指すように値を変更できるようになります。

Procedure: パス変数を無視する

Whenever you open or update a project, CLion checks for unresolved path variables. IDE がいずれかを検出すると、それらの値を定義するように求められます。 未解決のパス変数を含むファイルまたはディレクトリを使用しない場合は、無視する変数のリストに追加できます。

実行/デバッグ構成に渡されるプログラム引数がパス変数 (環境変数など) と同じフォーマットの場合は、無視される変数のリストも使用できます。

1. `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `⌘ Comma` (Xcode), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (ReSharper), `⌘ Comma` (ReSharper (macOS)), `Ctrl+Alt+S` (QtCreator), `⌘ Comma` (QtCreator (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) を押して設定を開き、  `外観 & 振る舞い | パス変数`  を選択します。

2. Add the names that CLion shouldn't consider to be path variables to the   無視される変数   field.

3. 変更を適用するには、   OK   をクリックします。

