0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Clineで「コマンドの実行結果が表示されていないようです」対策(PowerShell用)

Last updated at Posted at 2025-03-13

目的

Windows環境でVSCode+Clineを試していると、Clineがコマンドを実行してその結果を取得しようとし、「コマンドの実行結果が表示されていないようです」というエラーが出ることがある。

解決にそれなりの手間を取ったのでメモとして残す。
といっても、英語がすらすら読める人はここを直接読んだ方が速い。

環境

  • Windows 11
  • VSCode + Cline
  • PowerShellをターミナルとして利用

手順

PowerShellをデフォルトのシェルとして設定する

  • Ctrl + Shift + Pを押して、「Terminal: Select Default Profile」を選択する
  • PowerShellを選択する

PowerShellのバージョンが7以上であることを確認する

  • $PSVersionTable.PSVersionコマンドを実行してバージョンを確認する
  • 必要に応じて、最新バージョンのPowerShellをインストールする

PowerShellの実行ポリシーの調整

実行ポリシーを確認し、AllSignedRestrictedになっている場合はポリシーを緩和する。

Get-ExecutionPolicy

以下のコマンドでPowerShellの実行ポリシーをRemoteSignedに設定する。

Set-ExecutionPolicy RemoteSigned

尚、RemoteSignedは、ローカルに保存されているスクリプトの実行に署名が不要になる設定。但し、インターネットから保存したファイルには署名が必要なので、それなりに安全性が保たれつつ、便利になる。

VSCodeの再起動

VSCodeを完全に終了し、再度開く。

まだ問題が解決しない場合は、手動でシェル統合をインストールする

1. PowerShellのプロファイルスクリプトを開く

code $PROFILE

上記のコマンドは、ユーザーのドキュメントフォルダにMicrosoft.PowerShell_profile.ps1というファイルを作成し、編集の為に開いてくれる。

2. 以下のスクリプトを上記のプロファイルに追加する

if ($env:TERM_PROGRAM -eq "vscode") { . "$(code --locate-shell-integration-path pwsh)" }

このスクリプトは、vscodeからPowerShellが実行されている場合に、vscodeのシェル統合機能を使ってコマンドを実行するように設定している。

その他

bashを使いたい場合は記事の先頭で示したリンク先にやり方が書かれているのでご参考までに。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?