Chromebookにソースコードエディター「VSCode」をインストール・日本語化する。

IT技術

はじめに

Visual Studio Code(以下、VSCode)は、Microsoft社が開発しているソースコードエディターである。
VSCodeをChromebookにインストールしたので、その手順をまとめる。

システム環境

Acer Chromebook Spin 311 CP311-3H-A14N/E
Google Chrome OS 94.0.4606.114

インストール方法

Linux環境の有効化

ChomebookにLinuxをインストール(有効化)したを参照。

debパッケージのダウンロード

Linuxターミナルを起動し、以下のコマンドを実行してChromebook Linux環境のCPUアーキテクチャの種類を確認する。
筆者の環境では以下のように表示された。

testuser@penguin:~$ uname -m
aarch64
testuser@penguin:~$ 

VSCodeの公式ダウンロードページより、対応したdebパッケージをダウンロードする。
筆者の環境では、「.deb 64bit」を選択した。

保存先は「マイファイル→Linuxファイル」にする。

aptコマンドでインストール

Linuxターミナルでlsコマンドを実行し、ダウンロードしたdebパッケージが存在することを確認する。

testuser@penguin:~$ ls -l
total 72624
-rw-r--r-- 1 testuser testuser 74365412 Nov 14 16:44 code_1.62.2-1636663931_arm64.deb
testuser@penguin:~$ 

apt installコマンドを実行し、インストールを行う。

testuser@penguin:~$ sudo apt install ./code_1.62.2-1636663931_arm64.deb 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'code' instead of './code_1.62.2-1636663931_arm64.deb'
The following additional packages will be installed:
  libnspr4 libnss3 libsecret-1-0 libsecret-common libxkbfile1
The following NEW packages will be installed:
  code libnspr4 libnss3 libsecret-1-0 libsecret-common libxkbfile1
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,378 kB/75.7 MB of archives.
After this operation, 313 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://deb.debian.org/debian buster/main arm64 libnspr4 arm64 2:4.20-1 [105 kB]
Get:2 https://deb.debian.org/debian buster/main arm64 libnss3 arm64 2:3.42.1-1+deb10u3 [1,082 kB]
Get:3 https://deb.debian.org/debian buster/main arm64 libxkbfile1 arm64 1:1.0.9-2+b11 [71.4 kB]
Get:4 /home/testuser/code_1.62.2-1636663931_arm64.deb code arm64 1.62.2-1636663931 [74.4 MB]
Get:5 https://deb.debian.org/debian buster/main arm64 libsecret-common all 0.18.7-1 [25.7 kB]
Get:6 https://deb.debian.org/debian buster/main arm64 libsecret-1-0 arm64 0.18.7-1 [93.9 kB]
Fetched 1,378 kB in 2s (687 kB/s)       
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libnspr4:arm64.
(Reading database ... 33289 files and directories currently installed.)
Preparing to unpack .../0-libnspr4_2%3a4.20-1_arm64.deb ...
Unpacking libnspr4:arm64 (2:4.20-1) ...
Selecting previously unselected package libnss3:arm64.
Preparing to unpack .../1-libnss3_2%3a3.42.1-1+deb10u3_arm64.deb ...
Unpacking libnss3:arm64 (2:3.42.1-1+deb10u3) ...
Selecting previously unselected package libxkbfile1:arm64.
Preparing to unpack .../2-libxkbfile1_1%3a1.0.9-2+b11_arm64.deb ...
Unpacking libxkbfile1:arm64 (1:1.0.9-2+b11) ...
Selecting previously unselected package libsecret-common.
Preparing to unpack .../3-libsecret-common_0.18.7-1_all.deb ...
Unpacking libsecret-common (0.18.7-1) ...
Selecting previously unselected package libsecret-1-0:arm64.
Preparing to unpack .../4-libsecret-1-0_0.18.7-1_arm64.deb ...
Unpacking libsecret-1-0:arm64 (0.18.7-1) ...
Selecting previously unselected package code.
Preparing to unpack .../5-code_1.62.2-1636663931_arm64.deb ...
Unpacking code (1.62.2-1636663931) ...
Setting up libnspr4:arm64 (2:4.20-1) ...
Setting up libxkbfile1:arm64 (1:1.0.9-2+b11) ...
Setting up libsecret-common (0.18.7-1) ...
Setting up libnss3:arm64 (2:3.42.1-1+deb10u3) ...
Setting up libsecret-1-0:arm64 (0.18.7-1) ...
Setting up code (1.62.2-1636663931) ...
Processing triggers for mime-support (3.62) ...
Processing triggers for libc-bin (2.28-10) ...
Processing triggers for shared-mime-info (1.10-1) ...
Processing triggers for desktop-file-utils (0.23-4) ...
testuser@penguin:~$ 

VSCodeの日本語化

メニューの日本語表示

Chromebookのアプリ一覧にVSCodeが追加されていることを確認し、ダブルクリックして起動する。

上部メニュー「View」→「Command Palette」→「Configure Display Language」→「Install Additional Languages」と選択/入力する。
「Japanese Language Pack for Visual Studio Code 〜」の「Install」を選択する。

インストール完了後、右下に以下のような選択肢が表示される。「Change Language and Restart」を選択する。

VSCodeが再起動されて、日本語表記になる。

日本語入力を可能にする

Linuxターミナルを起動し、apt installコマンドで日本語フォントをインストールする。

testuser@penguin:~$ sudo apt install task-japanese locales-all fonts-ipafont
Reading package lists... Done
Building dependency tree       
Reading state information... Done
〜〜〜省略〜〜〜
testuser@penguin:~$ 
testuser@penguin:~$ sudo localectl set-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja"
testuser@penguin:~$ 
testuser@penguin:~$ source /etc/default/locale
testuser@penguin:~$ 

続いてfcitx-mozcをインストールする。

testuser@penguin:~$ sudo apt install fcitx-mozc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  aspell aspell-en bubblewrap dictionaries-common emacsen-common enchant fcitx fcitx-bin
  fcitx-config-common fcitx-config-gtk fcitx-data fcitx-frontend-all fcitx-frontend-gtk2
  fcitx-frontend-gtk3 fcitx-frontend-qt4 fcitx-frontend-qt5 fcitx-module-dbus fcitx-module-kimpanel
  fcitx-module-lua fcitx-module-x11 fcitx-modules fcitx-ui-classic fcitx5-module-quickphrase-editor
〜〜〜中略〜〜〜
aspell-autobuildhash: processing: en [en_US-w_accents-only].
aspell-autobuildhash: processing: en [en_US-wo_accents-only].
testuser@penguin:~$ 
testuser@penguin:~$ sudo apt list fcitx-mozc
Listing... Done
fcitx-mozc/oldstable,now 2.23.2815.102+dfsg-4 arm64 [installed]
testuser@penguin:~$ 

設定ファイル「/etc/systemd/user/cros-garcon.service.d/cros-garcon-override.conf」に、環境設定3つを追加する。

testuser@penguin:~$ cat /etc/systemd/user/cros-garcon.service.d/cros-garcon-override.conf
[Service]
Environment="BROWSER=/usr/bin/garcon-url-handler"
Environment="NCURSES_NO_UTF8_ACS=1"
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/local/games:/usr/sbin:/usr/bin:/usr/games:/sbin:/bin"
Environment="QT_AUTO_SCREEN_SCALE_FACTOR=1"
Environment="QT_QPA_PLATFORMTHEME=gtk2"
Environment="XCURSOR_THEME=Adwaita"
Environment="XDG_CONFIG_HOME=%h/.config"
Environment="XDG_DATA_DIRS=%h/.local/share:%h/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share"
testuser@penguin:~$ 
testuser@penguin:~$ sudo mkdir /etc/systemd/user/cros-garcon.service.d/.backup
testuser@penguin:~$ sudo cp -ip /etc/systemd/user/cros-garcon.service.d/cros-garcon-override.conf /etc/systemd/user/cros-garcon.service.d/.backup/cros-garcon-override.conf.`date +%Y%m%d`
testuser@penguin:~$ 
testuser@penguin:~$ sudo sed -i -e '$ a Environment="GTK_IM_MODULE=fcitx"' /etc/systemd/user/cros-garcon.service.d/cros-garcon-override.conf
testuser@penguin:~$ sudo sed -i -e '$ a Environment="QT_IM_MODULE=fcitx"' /etc/systemd/user/cros-garcon.service.d/cros-garcon-override.conf
testuser@penguin:~$ sudo sed -i -e '$ a Environment="XMODIFIERS=@im=fcitx"' /etc/systemd/user/cros-garcon.service.d/cros-garcon-override.conf
testuser@penguin:~$ 
testuser@penguin:~$ diff /etc/systemd/user/cros-garcon.service.d/cros-garcon-override.conf /etc/systemd/user/cros-garcon.service.d/.backup/cros-garcon-override.conf.`date +%Y%m%d`
10,12d9
< Environment="GTK_IM_MODULE=fcitx"
< Environment="QT_IM_MODULE=fcitx"
< Environment="XMODIFIERS=@im=fcitx"
testuser@penguin:~$ 

Linux起動時、自動的にFcitxが起動するよう設定する。

testuser@penguin:~$ echo "/usr/bin/fcitx-autostart" >> ~/.sommelierrc
testuser@penguin:~$ cat ~/.sommelierrc
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Use this file to customize per-user sommelier options.
#
# For documentation, see:
# https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/vm_tools/sommelier/
# Example: Set default X resources at startup.
#if [ -f ~/.Xresources ]; then
#  xrdb -merge ~/.Xresources
#fi
/usr/bin/fcitx-autostart
testuser@penguin:~$ 

設定反映のため、一度Linuxを再起動する。

testuser@penguin:~$ sudo reboot

Linux再起動後に再度Linuxターミナルを開き、以下のコマンドを実行してFcitx設定画面を開く。

testuser@penguin:~$ fcitx-configtool

設定画面左下の+ボタンを選択する。

「Mozc 日本語」を選択し、OKを選択する。

設定画面下部の上下ボタンを操作し、「Mozc 日本語」を一番上に移動する。
移動後、✕ボタンを選択して設定画面を閉じる。

これでVSCodeを開き直すと、日本語で入力できるようになる。

タイトルとURLをコピーしました