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?

Windsurf を WSL2 に接続すると Server installation が失敗する問題(プロキシ環境)

0
Posted at

Windsurf を WSL2 に接続すると Server installation が失敗する問題(プロキシ環境)

Windows 版 Windsurf から WSL2 に接続する際に、Server installation が失敗する問題に遭遇しました。
原因は WSL 内で実行されるインストールスクリプトがプロキシ設定を読めていないことでした。

同様の環境の人の参考になればと思い、調査内容と解決方法をまとめます。


発生したエラー

Windsurf から WSL 接続した際に以下のエラーが出ました。

connect to WSL > Ubuntu 24.04LTS

Warning: could not get sha256 hash from manifest: will not verify checksum.
Waiting for lock...
Lock acquired, proceeding with installation.
Error downloading server from https://windsurf-stable.codeiumdata.com/linux-reh-x64/stable/.../windsurf-reh-linux-x64-1.9552.21.tar.gz
Error: installation failed.

WSL 側で同じ URL を "curl" すると問題なく取得できました。

curl -L https://windsurf-stable.codeiumdata.com/linux-reh-x64/stable/.../windsurf-reh-linux-x64-1.9552.21.tar.gz

そのため最初は

  • ネットワーク
  • SSL
  • WSL設定

などを疑いましたが、原因は別のところにありました。


原因

Windsurf が実行するインストールスクリプトを見ると、ダウンロード処理は次のようになっています。

if [[ ! -z $(which wget) ]]; then
    wget --tries=3 --timeout=10 --continue --quiet -O $temp_file $SERVER_DOWNLOAD_URL
elif [[ ! -z $(which curl) ]]; then
    curl --retry 3 --connect-timeout 10 --location --show-error --silent --output $temp_file $SERVER_DOWNLOAD_URL
else
    echo "Error no tool to download server binary"
fi

つまり

  1. "wget" が存在すれば wgetを使用
  2. "wget" が無ければ "curl"

という実装になっています。

自分の環境では "wget" が入っていたため、curlではなくwgetが使用されていました。


なぜプロキシ設定が効かなかったのか

WSLで実行されるコマンドは次の形式でした。

wsl.exe --distribution Ubuntu-22.04 -- bash -c 'install script'

この "bash -c" は

  • 非ログインシェル
  • 非インタラクティブシェル

のため通常は次のファイルが読み込まれません。

  • ".bashrc"
  • ".bash_profile"
  • ".profile"

つまり

export http_proxy=http://proxy:8080
export https_proxy=http://proxy:8080

を ".bashrc" に書いても 環境変数が設定されない状態になります。


解決方法

"wget" の設定ファイル ".wgetrc" にプロキシを書いたところ解決しました。

~/.wgetrc

http_proxy = http://proxy.example.com:8080
https_proxy = http://proxy.example.com:8080

これにより "wget" が直接プロキシ設定を読み込むため、Windsurf のインストールが成功しました。


なぜ ".wgetrc" だと動くのか

"wget" のプロキシ設定の読み込み順は次の通りです。

  1. コマンドラインオプション
  2. 環境変数
  3. ".wgetrc"
  4. "/etc/wgetrc"

".wgetrc" は wget自身が直接読み込む設定ファイルのため、

  • bash の設定
  • 環境変数

に依存せず利用できます。

そのため今回のような 非ログインシェル環境でもプロキシ設定が有効になります。


まとめ

Windsurf を WSL で使う場合、プロキシ環境では次の点に注意が必要です。

  • Windsurf の server install script は wgetを優先して使用する
  • WSL は bash -c で実行されるため bashrc が読まれない
  • プロキシ環境では ".wgetrc" に設定を書くと解決する

同じ問題で詰まっている方の参考になれば幸いです。

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?