0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PostgreSQL Windows版のインストールがgetlocales.ps1で失敗する場合の回避方法

0
Last updated at Posted at 2026-07-22

新人研修実施時に発生した事例の紹介と回避方法です。

Windowsのユーザー名に日本語が含まれている環境で、PostgreSQLのWindows版インストーラーが次のようなエラーで停止しました。
スクリーンショット 2026-07-21 131019.png

Error running ~略~ getlocales.ps1

原因として挙げられているのはWindowsのユーザ名が日本語等になっているというケースで本件も該当しています。
ネット上での解決方法だとユーザー名を変更したり、新しいWindowsユーザーを作成を解決方法として紹介している事例が多いですが、ad環境下や影響範囲を考えると厳しい印象を受けました。

そのため別の方法としてインストーラー実行時だけ一時フォルダーをC:\Tempに変更することで回避できたので共有します。

実行コマンド

PowerShellを開き、以下を実行します。

New-Item -ItemType Directory -Path "C:\Temp" -Force | Out-Null
$env:TEMP = "C:\Temp"
$env:TMP = "C:\Temp"
& "$HOME\Downloads\postgresql-18.4-1-windows-x64.exe"

インストーラーのファイル名が異なる場合は、最後の行を実際のファイル名に変更します。

例:

& "$HOME\Downloads\postgresql-17.10-1-windows-x64.exe"

バージョンを指定せず自動で探す場合

Downloadsフォルダー内のPostgreSQLインストーラーを自動で探して起動する場合は、以下でも実行できます。

New-Item -ItemType Directory -Path "C:\Temp" -Force | Out-Null
$env:TEMP = "C:\Temp"
$env:TMP = "C:\Temp"
& (Get-ChildItem "$HOME\Downloads\postgresql-*.exe" | Select-Object -First 1).FullName

このコマンドで変更されるもの

変更されるのは、インストーラーが一時ファイルを展開する場所だけです。

C:\Temp

PostgreSQL本体のインストール先やデータディレクトリは変更されません。
通常どおりインストーラー上で指定した場所にインストールされます。
例:

C:\Program Files\PostgreSQL\18

また、TEMP と TMP の変更は、このPowerShellから起動したプロセスにだけ適用されます。
PowerShellを閉じれば元に戻るため、Windows全体の環境変数が変わることはありません。

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?