Closed8

cursorを導入したらwslの環境がぶち壊れた件

torohashtorohash

大げさな表現ではあるけど、codeコマンドが機能しなくなったり、cursorで立ち上げができなかったり色々。

修正せざるを得ないので色々やってみるスレッド。

torohashtorohash

https://github.com/getcursor/cursor/issues/807#issuecomment-1728885825

とりあえずこれ。
該当パスのcursorを提示しているものに書き換えるとのこと。
確かに単純にコピペしたらcursorコマンドは動くようになった。

Warning: 'ms-enable-electron-run-as-node' is not in the list of known options, but still passed to Electron/Chromium.

っていう警告あり。

torohashtorohash

codeコマンドが効かない件についてはcursorアンインストールしたら直った。
issue見ていた感じ、cursorがcodeコマンドに対してなんやかんややってるっぽい

torohashtorohash

とりあえずcodeコマンドハイジャックされる問題はwsl上での問題の場合、pathの順序を以下のようにしてちょうせいすることで対処することにした。

# Remove VS Code and cursor from PATH if they exist
PATH=$(echo "$PATH" | sed -e 's|:/mnt/c/Users/USERNAME/AppData/Local/Programs/Microsoft VS Code/bin||g')
PATH=$(echo "$PATH" | sed -e 's|:/mnt/c/Users/USERNAME/AppData/Local/Programs/cursor/resources/app/bin||g')

# Add VS Code to PATH
PATH="$PATH:/mnt/c/Users/USERNAME/AppData/Local/Programs/Microsoft VS Code/bin"

# Add cursor after VS Code
PATH="$PATH:/mnt/c/Users/USERNAME/AppData/Local/Programs/cursor/resources/app/bin"

export PATH

実際修正された。
もしpower shell上などでcodeコマンドがハイジャックされている場合はシステムの詳細設定から環境変数の順序を調整すれば多分うまくいくと思う、多分、、。

torohashtorohash
  1. WSLでPATHを調整する
# Remove VS Code and cursor from PATH if they exist
PATH=$(echo "$PATH" | sed -e 's|:/mnt/c/Users/USERNAME/AppData/Local/Programs/Microsoft VS Code/bin||g')
PATH=$(echo "$PATH" | sed -e 's|:/mnt/c/Users/USERNAME/AppData/Local/Programs/cursor/resources/app/bin||g')

# Add VS Code to PATH
PATH="$PATH:/mnt/c/Users/USERNAME/AppData/Local/Programs/Microsoft VS Code/bin"

# Add cursor after VS Code
PATH="$PATH:/mnt/c/Users/USERNAME/AppData/Local/Programs/cursor/resources/app/bin"

export PATH

上記を.bashrcに書き込む形

vim ~/.bashrc
source ~/.bashrc
  1. cursorファイルを修正
    https://gist.github.com/Thivieira/f393168860614bd57f36353e1f8703e4

上記ページを参照。
cursorファイルは

C:\Users\USERNAME\AppData\Local\Programs\cursor\resources\app\bin

にあるやつ。

torohashtorohash

なんかまた壊れたので対応した方法を追記
多分間違えてctrl + shift + pから選択できるFix WSL Installを間違って実行したからだと思われる。

/mnt/c/Users/USERNAME/.cursor/extensions/ms-vscode-remote.remote-wsl-0.81.8/scripts/wslCode.sh: 63: /home/USERNAME/.cursor-server/bin/xxx/bin/remote-cli/code: not found

みたいなエラーがcursorコマンドを使うと出るようになった。
なんとも直らないのでcusorをアンインストールして再インストール
これでも直らなかった。

torohashtorohash

次に~/.cursor-serverをrm -rfした

rm -rf ~/.cursor-server

これで再インストールがかかるようになって直るかなーと思ったが以下のエラーが出るように

ln: failed to create symbolic link '/home/USERNAME/.cursor-server/bin//-1726840467.tar.gz/bin/remote-cli/code': Not a directory
Updating VS Code Server to version -1726840467.tar.gz
Removing previous installation...
Installing VS Code Server for x64 (-1726840467.tar.gz)
Downloading: 100%
Failed
--2024-09-20 22:56:22--  https://update.code.visualstudio.com/commit:-1726840467.tar.gz/server-linux-x64/stable
Resolving update.code.visualstudio.com (update.code.visualstudio.com)... 13.107.246.47, 2620:1ec:bdf::47
Connecting to update.code.visualstudio.com (update.code.visualstudio.com)|13.107.246.47|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2024-09-20 22:56:22 ERROR 404: Not Found.

ERROR: Failed to download https://update.code.visualstudio.com/commit:-1726840467.tar.gz/server-linux-x64/stable to /home/torohash/.cursor-server/bin/-1726840467.tar.gz-1726840582.tar.gz

どうやらcursor-serverのdownloadに失敗しているらしく、
cursorバイナリを
https://github.com/getcursor/cursor/issues/807#issuecomment-1728885825
こっちに書き直したら正常に動作するようになった。
ただこのままだとcursor-serverの再インストールが毎回走って面倒なので、
https://gist.github.com/Thivieira/f393168860614bd57f36353e1f8703e4
こちらに書き直して運用している感じ。

もしかしたら最終的なcursorバイナリの状態は健全じゃないかもなーと思ったりするなど。

このスクラップは2024/09/20にクローズされました