ubuntu内でHeroku CLIをインストールできない方(certificate has expired or is not yet valid))


Heroku CLIをインストールする

qiita.rb
vagrant@ubuntu-bionic:~$ sudo snap install --classic heroku
error: cannot perform the following tasks:
- Download snap "core" (7396) from channel "stable" (Get https://fastly-global.cdn.snapcraft.io/download-origin/fastly/99T7MUlRhtI3U0QFgl5mXXESAiSwt776_7396.snap?token=1567764000_9696ad515c77cc35b28a63cdd87f4d8b98845441: x509: certificate has expired or is not yet valid)

原因

ローカルとの時刻が合っていない可能性が高い。
参照記事
https://qiita.com/celeron1ghz/items/c8a9276d7d71e4f52760

解決策

NTPサーバで現在時刻の取得を行う。
Ubuntu 18.04 LTS環境では、ntpdateコマンドがデフォルトでインストールされていないそうなので、インストールを行う

vagrant@ubuntu-bionic:~$ sudo apt install ntpdate
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  ntpdate
0 upgraded, 1 newly installed, 0 to remove and 24 not upgraded.
Need to get 51.8 kB of archives.
After this operation, 183 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 ntpdate amd64 1:4.2.8p10+dfsg-5ubuntu7.1 [51.8 kB]
Fetched 51.8 kB in 2s (33.7 kB/s)                    
Selecting previously unselected package ntpdate.
(Reading database ... 90216 files and directories currently installed.)
Preparing to unpack .../ntpdate_1%3a4.2.8p10+dfsg-5ubuntu7.1_amd64.deb ...
Unpacking ntpdate (1:4.2.8p10+dfsg-5ubuntu7.1) ...
Setting up ntpdate (1:4.2.8p10+dfsg-5ubuntu7.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

ntp.nict.jpと時刻を合わせる

qiita.rb
vagrant@ubuntu-bionic:~$ sudo ntpdate ntp.nict.jp
 6 Sep 06:14:41 ntpdate[5718]: step time server 133.243.238.163 offset 130672.522992 sec

インストールとversionの確認

qiita.rb
vagrant@ubuntu-bionic:~$ sudo snap install --classic heroku
2019-09-06T06:16:33Z INFO Waiting for restart...
heroku v7.29.0 from Heroku installed
vagrant@ubuntu-bionic:~$ heroku --version
heroku/7.29.0 linux-x64 node-v11.14.0

参照記事
(https://www.atmarkit.co.jp/ait/articles/1906/21/news013.html)

一助になれば幸いです。