プロジェクト

全般

プロフィール

VSCodeのシェルをMSYS2にする » 履歴 » バージョン 5

開発 次郎, 2025/03/23 12:42

1 1 開発 次郎
h1. VSCodeのシェルをMSYS2にする
2
3 2 開発 次郎
h2. 概要
4 1 開発 次郎
5 2 開発 次郎
統合ターミナルを起動する際にMSYS2プロファイルを選択するには、<code>terminal.integrated.profiles.windows</code> を <code>settings.json</code> に追加する。
6
7
h3. settings.jsonにMSYS2を追加する
8 1 開発 次郎
9 3 開発 次郎
"PowerShell", "Command Prompt", "Git Bash" がデフォルト部分で、"MSYS2 Bash" が追加した個所
10
11
<pre><code class="json">
12
    "terminal.integrated.profiles.windows": {
13
14
        "PowerShell": {
15
            "source": "PowerShell",
16
            "icon": "terminal-powershell"
17
        },
18
        "Command Prompt": {
19
            "path": [
20
                "${env:windir}\\Sysnative\\cmd.exe",
21
                "${env:windir}\\System32\\cmd.exe"
22
            ],
23
            "args": [],
24
            "icon": "terminal-cmd"
25
        },
26
        "Git Bash": {
27
            "source": "Git Bash"
28
        },
29
		"MSYS2 Bash": {
30
			"path": [
31
				"D:\\msys64\\usr\\bin\\bash.exe"
32
			],
33
			"args": [
34
				"--login"
35
			],
36
			"env": {
37
				"MSYSTEM": "MINGW64",
38
				"CHERE_INVOKING": "1"
39
			}
40
		},
41
    }
42
</code></pre>
43
44 4 開発 次郎
h3. MSYS2のgit.exeを使う
45
46
h4. エラー履歴
47
48
* Visual Studio Codeでエラーメッセージ。「Git Failed to execute git」
49
** settings.json で git.pathにMSYS2のgit.exeを設定しただけではエラーになる
50
*** (例)"git.path": "D:/msys64/usr/bin/git.exe"
51
{{collapse(エラー時の出力,閉じる)
52
<pre>
53
2025-03-23 20:27:31.318 [info] [main] ログ レベル: Info
54
2025-03-23 20:27:31.318 [info] [main] Git の検証が検出されました: "D:/msys64/usr/bin/git.exe"
55
2025-03-23 20:27:31.318 [info] [main] "D:/msys64/usr/bin/git.exe" から Git "2.48.1" を使用しています
56
2025-03-23 20:27:31.318 [info] [Model][doInitialScan] Initial repository scan started
57
2025-03-23 20:27:31.439 [info] > git rev-parse --show-toplevel [122ms]
58
2025-03-23 20:27:31.869 [info] > git rev-parse --path-format=relative --show-toplevel [425ms]
59
2025-03-23 20:27:31.997 [info] > git rev-parse --git-dir --git-common-dir [69ms]
60
2025-03-23 20:27:32.007 [info] [Model][openRepository] Opened repository: d:\temp\test01
61
2025-03-23 20:27:32.011 [info] [Model][doInitialScan] Initial repository scan completed - repositories (1), closed repositories (0), parent repositories (0), unsafe repositories (0)
62
2025-03-23 20:27:32.065 [info] > git config --get commit.template [48ms]
63
2025-03-23 20:27:32.108 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/main refs/remotes/main [62ms]
64
2025-03-23 20:27:32.177 [info] > git status -z -uall [63ms]
65
2025-03-23 20:27:32.180 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [61ms]
66
2025-03-23 20:27:32.240 [info] > git config --get commit.template [45ms]
67
2025-03-23 20:27:32.252 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/main refs/remotes/main [64ms]
68
2025-03-23 20:27:32.265 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/main refs/remotes/main [63ms]
69
2025-03-23 20:27:32.297 [info] > git config --get --local branch.main.vscode-merge-base [40ms]
70
2025-03-23 20:27:32.329 [info] > git status -z -uall [60ms]
71
2025-03-23 20:27:32.331 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [57ms]
72
2025-03-23 20:27:32.357 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/origin/main refs/remotes/origin/main [55ms]
73
2025-03-23 20:27:32.395 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/main refs/remotes/main [57ms]
74
2025-03-23 20:27:32.411 [info] > git merge-base refs/heads/main refs/remotes/origin/main [46ms]
75
2025-03-23 20:27:32.438 [info] > git config --get --local branch.main.vscode-merge-base [39ms]
76
2025-03-23 20:27:32.467 [info] > git diff --name-status -z --diff-filter=ADMR 19a777a514e9a13fe4f5bb1c76382d88c37b6688...refs/remotes/origin/main [51ms]
77
2025-03-23 20:27:32.483 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/origin/main refs/remotes/origin/main [41ms]
78
2025-03-23 20:27:32.594 [info] > git check-ignore -v -z --stdin [42ms]
79
2025-03-23 20:27:42.090 [info] > git log --format=%H%n%aN%n%aE%n%at%n%ct%n%P%n%D%n%B -z --shortstat --diff-merges=first-parent -n50 --skip=0 --topo-order --decorate=full --stdin [91ms]
80
2025-03-23 20:27:44.835 [info] > git log --oneline --cherry main...main@{upstream} -- [63ms]
81
2025-03-23 20:27:44.835 [info] fatal: bad revision 'main...main@upstream'
82
2025-03-23 20:27:44.967 [info] > git pull --tags origin main [123ms]
83
2025-03-23 20:27:45.037 [info] > git config --get commit.template [63ms]
84
2025-03-23 20:27:45.053 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/main refs/remotes/main [74ms]
85
2025-03-23 20:27:45.117 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [53ms]
86
2025-03-23 20:27:45.123 [info] > git status -z -uall [63ms]
87
2025-03-23 20:28:23.411 [info] > git log --oneline --cherry main...main@{upstream} -- [61ms]
88
2025-03-23 20:28:23.411 [info] fatal: bad revision 'main...main@upstream'
89
2025-03-23 20:28:23.500 [info] > git pull --tags origin main [84ms]
90
2025-03-23 20:28:23.561 [info] > git config --get commit.template [53ms]
91
2025-03-23 20:28:23.579 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/main refs/remotes/main [68ms]
92
2025-03-23 20:28:23.640 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [51ms]
93
2025-03-23 20:28:23.643 [info] > git status -z -uall [59ms]
94
</pre>
95 1 開発 次郎
}}
96 5 開発 次郎
** sshができていないことが原因と考え、次のページが解決策と仮定してやってみたが、状況は変わらなかった。
97
*** https://qiita.com/yumetodo/items/123cd1d91f913bf0e748
98 4 開発 次郎
99 1 開発 次郎
h2. 参考
100
101
* "Visual Studio Code の統合ターミナルで MSYS2 の bash を選択できるようにする":https://qiita.com/chirimen/items/04e2e10c86c9ecd1e158