IdeaPad duet で開発環境を整える

# IdeaPad duet はイイぞ

普段メインマシンとして Macbook Pro 13 インチ を使ってるんだけど、持ち歩くにはちょっと重いからサブ機がほしいなと思っていたところに見つけたこちらの商品
Chromebook って今まで使ったことなかったけど Linux の環境が使えるということで買ってみた

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/353538/7bec59be-c8c0-5d1e-b4b6-e0eb4675d931.png)


# 本題
せっかく Linux が使えるんだからとちょっとした開発環境を整えた
あえてログも残すのでうまくいかない人は参考にしてみてください

```
$ uname -a
Linux penguin 5.4.40-04224-g891a6cce2d44 #1 SMP PREEMPT Tue Jun 23 20:13:49 PDT 2020 aarch64 GNU/Linux
```

上の結果を見て分かるとおり、CPU のアーキテクチャが **x86 ではなく ARM** なのがミソ


## AWS CLI v2

[参考: AWS CLI v2 now available for Linux ARM](https://aws.amazon.com/blogs/developer/aws-cli-v2-now-available-for-linux-arm/)

```shell

$ curl -O 'https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 28.7M  100 28.7M    0     0  3687k      0  0:00:07  0:00:07 --:--:-- 3914k
```

```shell

$ unzip awscli-exe-linux-aarch64.zip
# 結果は省略
```

```shell

$ sudo ./aws/install
You can now run: /usr/local/bin/aws --version
```

```shell

$ aws --version
aws-cli/2.0.45 Python/3.7.3 Linux/5.4.40-04224-g891a6cce2d44 exe/aarch64.debian.10
```


## Google Cloud SDK

[参考: Google Cloud SDK for ARM architecture](https://stackoverflow.com/questions/43409469/google-cloud-sdk-for-arm-architecture)

```shell

$ sudo apt -y update && sudo apt -y upgrade 
Get:1 https://deb.debian.org/debian buster InRelease [122 kB]
Get:2 https://deb.debian.org/debian-security buster/updates InRelease [65.4 kB]
Ign:3 https://storage.googleapis.com/cros-packages/84 buster InRelease
Get:4 https://storage.googleapis.com/cros-packages/84 buster Release [3,119 B]
Get:5 https://storage.googleapis.com/cros-packages/84 buster Release.gpg [819 B]
Get:6 https://deb.debian.org/debian buster/main arm64 Packages [7,736 kB]
Get:7 https://storage.googleapis.com/cros-packages/84 buster/main arm64 Packages [16.1 kB]
Get:8 https://deb.debian.org/debian buster/main Translation-en [5,968 kB]
Get:9 https://deb.debian.org/debian-security buster/updates/main arm64 Packages [219 kB]                                                              
Get:10 https://deb.debian.org/debian-security buster/updates/main Translation-en [122 kB]                                                             
Fetched 14.3 MB in 12s (1,217 kB/s)                                                                                                                   
Reading package lists... Done
Building dependency tree       
Reading state information... Done
30 packages can be upgraded. Run 'apt list --upgradable' to see them.
N: Repository 'https://deb.debian.org/debian buster InRelease' changed its 'Version' value from '10.4' to '10.5'
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
```

```shell

$ sudo apt-get update && sudo apt-get install google-cloud-sdk
Hit:1 https://deb.debian.org/debian buster InRelease
Hit:2 https://deb.debian.org/debian-security buster/updates InRelease
Ign:3 https://storage.googleapis.com/cros-packages/84 buster InRelease
Get:4 https://packages.cloud.google.com/apt cloud-sdk InRelease [6,349 B]
Hit:5 https://storage.googleapis.com/cros-packages/84 buster Release
Get:6 https://packages.cloud.google.com/apt cloud-sdk/main arm64 Packages [76.3 kB]
Fetched 82.7 kB in 3s (32.8 kB/s) 
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  python3-crcmod
Suggested packages:
  google-cloud-sdk-app-engine-java google-cloud-sdk-app-engine-python google-cloud-sdk-pubsub-emulator google-cloud-sdk-bigtable-emulator
  google-cloud-sdk-datastore-emulator kubectl
The following NEW packages will be installed:
  google-cloud-sdk python3-crcmod
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 69.9 MB of archives.
After this operation, 399 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://packages.cloud.google.com/apt cloud-sdk/main arm64 google-cloud-sdk all 308.0.0-0 [69.9 MB]
Get:2 https://deb.debian.org/debian buster/main arm64 python3-crcmod arm64 1.7+dfsg-1+b1 [19.0 kB]
Fetched 69.9 MB in 16s (4,339 kB/s)                                                                                                                   
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package python3-crcmod.
(Reading database ... 33282 files and directories currently installed.)
Preparing to unpack .../python3-crcmod_1.7+dfsg-1+b1_arm64.deb ...
Unpacking python3-crcmod (1.7+dfsg-1+b1) ...
Selecting previously unselected package google-cloud-sdk.
Preparing to unpack .../google-cloud-sdk_308.0.0-0_all.deb ...
Unpacking google-cloud-sdk (308.0.0-0) ...
Setting up python3-crcmod (1.7+dfsg-1+b1) ...
Setting up google-cloud-sdk (308.0.0-0) ...
Processing triggers for man-db (2.8.5-2) ...
```

```shell

$ gcloud --version
Google Cloud SDK 308.0.0
alpha 2020.08.28
beta 2020.08.28
bq 2.0.60
core 2020.08.28
gsutil 4.53
kubectl 1.15.11
```


## VSCode

VSCode は残念ながら公式には ARM に対応していないのでコミュニティビルド版を使わなければいけない

[Visual Studio Code for Chromebooks and Raspberry Pi](https://code.headmelted.com/)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/353538/8dc84e45-ed9c-af21-2cdc-fb0b59ed8ab8.png)

このページの `the Releases page` のリンクから [GitHub](https://github.com/headmelted/codebuilds/releases) に飛べる

現時点 (2020/09/02) では、`30-Mar-20` が最新のリリースだが、**20-Jan-20** の方を Linux のフォルダにダウンロード

> 最初、`30-Mar-20` の方をインストールしてみたがなぜか VSCode のプラグインが入れられなかった
> TypeScript のエラーっぽかったから諦めた

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/353538/54fe025f-0a8c-90ce-0f37-2c1eab91f546.png)

> ダウンロードするのはこれの次のページの `code-oss_1.42.0-1579483079_arm64.deb`

あとはダウンロードしてきた `.deb` ファイルをダブルクリックして実行すればインストールが完了

```shell

$ code-oss --version
1.42.0
e107e5c5bf3e22dc63884aa11a410d33f96daad2
arm64
```

## Golang

リリースページで ARM 用のダウンロードリンクを取得

[Downloads - The Go Programming Language](https://golang.org/dl/)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/353538/55b25ca7-ea0b-4f3e-d684-0a93265b27bc.png)

今回はこの中から、`Arch` が `ARMv8` の `go1.15.1.linux-arm64.tar.gz` を使う

```shell

$  wget https://golang.org/dl/go1.15.1.linux-arm64.tar.gz
--2020-09-02 22:17:04--  https://golang.org/dl/go1.15.1.linux-arm64.tar.gz
Resolving golang.org (golang.org)... 172.217.161.241, 2404:6800:400a:806::2011
Connecting to golang.org (golang.org)|172.217.161.241|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.google.com/go/go1.15.1.linux-arm64.tar.gz [following]
--2020-09-02 22:17:06--  https://dl.google.com/go/go1.15.1.linux-arm64.tar.gz
Resolving dl.google.com (dl.google.com)... 172.217.26.110, 2404:6800:400a:807::200e
Connecting to dl.google.com (dl.google.com)|172.217.26.110|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 97722202 (93M) [application/octet-stream]
Saving to: ‘go1.15.1.linux-arm64.tar.gz’

go1.15.1.linux-arm64.tar.gz           100%[========================================================================>]  93.19M  3.26MB/s    in 24s     

2020-09-02 22:17:30 (3.93 MB/s) - ‘go1.15.1.linux-arm64.tar.gz’ saved [97722202/97722202]
```

```shell

$ sudo tar -C /usr/local/ -zxf go1.15.1.linux-arm64.tar.gz 
```

```shell

$ /usr/local/go/bin/go version
go version go1.15.1 linux/arm64
```

PATH が通っていなかったため `~/.bashrc` に追記しシェルを再起動

```shell

$ cat .bashrc | grep PATH
export PATH=$PATH:/usr/local/go/bin

$ exec $SHELL -l 
```

```shell

$ go version
go version go1.15.1 linux/arm64
```