LoginSignup
1
1

Local版VSCodeServerのインストール方法

Last updated at Posted at 2023-10-03

自分のLocal環境でVSCodeServer動かして、ブラウザ開発できるVScode。
Dockerで開発用ライブラリ含めまとめて構築して使っています。

お手軽に使ってたのですが、現在非推奨になってます!!
https://code.visualstudio.com/blogs/2022/07/07/vscode-server

We've released changes to how you can connect to the VS Code Server since this blog was >published. Check out the December 2022 blog post for the latest guidance.

このブログの公開以来、VS Code サーバーへの接続方法の変更をリリースしました。最新のガイダンスについては、2022 年 >>12 月のブログ投稿をご覧ください。

久しぶりに新規インストールしようとしたらエラーが出て気づきました。

以下だとインストールファイルではなくHTMLがダウンロードされ、実行時にエラーになります。
wget -O- https://aka.ms/install-vscode-server/setup.sh | sh

色々調べると今でもLinux版ならインストールできましたが、かなりお手軽からは離れてしまいました。。。。。
この方法もいつまで使えるか不明ですが。。。。

インストール方法紹介 Linux版

公式インストール方法は使えないので、ソースファイルを手動で手に入れて手動でインストールします。
私の場合はDocker内にインストールしています。

mvss_setup.sh

#!/bin/sh

INSTALL_LOCATION="/usr/local/mvss"

mkdir $INSTALL_LOCATION
cd $INSTALL_LOCATION

ARCH=x64 # x64 or arm64
HASHKEEY=$(curl https://update.code.visualstudio.com/api/commits/stable/server-linux-$ARCH-web | cut -d '"' -f 2) # 2番目のキー取得
INSTALL_URL=https://az764295.vo.msecnd.net/stable/$HASHKEEY/vscode-server-linux-$ARCH-web.tar.gz

wget "$INSTALL_URL"
tar -zxvf vscode-server-linux-$ARCH-web.tar.gz -C ./ --strip-components 1

ダウンロード先ですが段階を踏む必要があります。

  1. CPUアーキテクチャを選択します。 Intel&AMDはx64で、MacM1やRaspberryPiとかはarm64になるかと思います。
  2. update.code.visualstudio.com/~にアクセスして、アクセス文字列のリストを取得します。
  3. 複数のアクセス文字列ります。上記サンプルスクリプトでは2番目を使用します。(追加情報有)
  4. ここまでの情報からダウンロードURLを作ってダウンロードします。

最近スクリプト動かしたら、エラーになりました。2番目のアクセス文字列が無効だったようです。アクセス文字列は大量にあるので、2番目がダメでも、他の物を使用すれば問題なくダウンロード可能(適当に10個目にしたらOK)でした。何らかのダウンロードエラーが起きた場合は、上記スクリプトの動作を手作業のブラウザで実施し、ダウンロードが成功するかチェックしてみて下さい。

ダウンロードしたら解凍します。

  1. tarの解凍、第一階層のフォルダいらないのでstrip-componentsで消してます。
  2. 必要に応じて実行権限(chmod x)をしてください。私は不要でした。
  3. ./bin/code-server で起動できます。

起動コマンド

/binの場所や起動ポートは適時変えてください。

/usr/local/mvss/bin/code-server serve-local --host 0.0.0.0 --port 9090 --accept-server-license-terms

起動時のメッセージ中に初回アクセスURLが出ているので、そこに初回アクセスが必要です。
上記を飛ばして任意のURLにアクセスすると、404?だったかな?のエラーになります。

参考サイト:Installing code-server downloads a HTML file #8768

Installing code-server downloads a HTML file #8768
https://github.com/microsoft/vscode-remote-release/issues/8768

おまけ:Dcokerfileで構築時にVSCode拡張までいっきに入れる

code-serverコマンドのパスは適時インストール場所に読み替えてください。

RUN set -ex \
	&& /usr/local/mvss/bin/code-server serve-local --install-extension aaron-bond.better-comments --accept-server-license-terms \
	&& /usr/local/mvss/bin/code-server serve-local --install-extension esbenp.prettier-vscode --accept-server-license-terms \
	&& /usr/local/mvss/bin/code-server serve-local --install-extension formulahendry.auto-close-tag --accept-server-license-terms
1
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
1
1