Rubyと筋肉とギターとわたし

筋トレが仕事です

【Linux】Ubuntuにheroku CLIがインストールできない

f:id:rdwbocungelt5:20181009115813j:plain

段々と寒くなってきましたね。

どうもてぃです。

macだと簡単なheroku cliの導入に手こずりました。

環境

  • Ubuntu 16.04.5 LTS
  • elementary OS 0.4.1 Loki

現象

テスト環境でわりかしデプロイが簡単で多用されるheroku

デプロイコストが少なかったので使おうと思ったのですが、ubuntuでこんなにハマるとは思ってもみなかったですね。

公式ページを参考にやってみました。

devcenter.heroku.com

$ wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
This script requires superuser access to install apt packages.
You will be prompted for your password by sudo.
[sudo] user のパスワード:                
+ dpkg -s apt-transport-https
+ echo deb https://cli-assets.heroku.com/apt ./
+ dpkg -s heroku-toolbelt
+ true
+ curl https://cli-assets.heroku.com/apt/release.key
+ apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1737  100  1737    0     0   9819      0 --:--:-- --:--:-- --:--:--  9869
OK
+ apt-get update
無視:1 http://dl.google.com/linux/chrome/deb stable InRelease
取得:2 https://dl.yarnpkg.com/debian stable InRelease [13.3 kB]                                                                            
取得:3 https://dl.winehq.org/wine-builds/ubuntu xenial InRelease [4,701 B]                                                                                                                    
取得:4 https://download.docker.com/linux/ubuntu zesty InRelease [49.8 kB]                                                                                                                     
取得:5 http://packages.elementary.io/appcenter xenial InRelease [6,128 B]                                                                                                               
取得:6 https://dl.yarnpkg.com/debian stable/main amd64 Packages [7,905 B]                                                                                                                     
取得:7 https://dl.yarnpkg.com/debian stable/main i386 Packages [7,905 B]                                                                                                                      
取得:8 https://dl.yarnpkg.com/debian stable/main all Packages [7,905 B]                                                                                                                       
取得:9 https://dl.winehq.org/wine-builds/ubuntu xenial/main amd64 Packages [43.3 kB]                                                                                                          
取得:10 https://cli-assets.heroku.com/apt ./ InRelease [2,533 B]                                                                                                                      
取得:11 http://dl.google.com/linux/chrome/deb stable Release [1,189 B]                                                                                                                        
取得:12 https://download.docker.com/linux/ubuntu zesty/stable amd64 Packages [2,477 B]                                                                                                 
取得:13 http://dl.google.com/linux/chrome/deb stable Release.gpg [819 B]                                                                                                                      
取得:14 https://cli-assets.heroku.com/apt ./ Packages [620 B]                                                                                                                       
取得:15 http://packages.elementary.io/appcenter xenial/main amd64 Packages [78.3 kB]                                                                     
取得:16 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]                                                            
取得:17 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1,381 B]                                               
取得:18 http://ppa.launchpad.net/elementary-os/stable/ubuntu xenial InRelease [17.5 kB]                                               
取得:19 http://packages.elementary.io/appcenter xenial/main i386 Packages [614 B]                       
取得:20 http://packages.elementary.io/appcenter xenial/main amd64 DEP-11 Metadata [83.4 kB]          
取得:21 http://packages.elementary.io/appcenter xenial/main DEP-11 64x64 Icons [289 kB]                                                 
取得:22 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]                                                 
無視:23 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial InRelease                  
取得:24 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]                
取得:25 http://archive.ubuntu.com/ubuntu xenial-security InRelease [107 kB]                    
取得:26 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu xenial InRelease [23.8 kB]
取得:27 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1,201 kB]
取得:28 http://archive.ubuntu.com/ubuntu xenial/main Translation-ja [290 kB]                                                
取得:29 http://ppa.launchpad.net/philip.scott/elementary-tweaks/ubuntu xenial InRelease [18.1 kB]
取得:30 http://archive.ubuntu.com/ubuntu xenial/main Translation-en [568 kB]                        
取得:31 http://archive.ubuntu.com/ubuntu xenial/main amd64 DEP-11 Metadata [733 kB]                      
取得:32 http://archive.ubuntu.com/ubuntu xenial/main DEP-11 64x64 Icons [409 kB]                                                                                
取得:33 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [8,344 B]                                                                          
取得:34 http://archive.ubuntu.com/ubuntu xenial/restricted Translation-en [2,908 B]                                        
取得:35 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 DEP-11 Metadata [186 B] 
取得:36 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7,532 kB]                                              
取得:37 http://ppa.launchpad.net/ubuntuhandbook1/audacity/ubuntu xenial InRelease [17.5 kB]                                     
取得:38 http://archive.ubuntu.com/ubuntu xenial/universe Translation-ja [1,034 kB]                                            
取得:39 http://archive.ubuntu.com/ubuntu xenial/universe Translation-en [4,354 kB]                                                                        
取得:40 http://archive.ubuntu.com/ubuntu xenial/universe amd64 DEP-11 Metadata [3,410 kB]                                                                 
取得:41 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial InRelease [17.5 kB]               
取得:42 http://archive.ubuntu.com/ubuntu xenial/universe DEP-11 64x64 Icons [7,448 kB]                 
取得:43 http://ppa.launchpad.net/elementary-os/stable/ubuntu xenial/main Sources [21.4 kB]                                                                                                    
取得:44 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [144 kB]                                                                                                            
取得:45 http://archive.ubuntu.com/ubuntu xenial/multiverse Translation-ja [8,704 B]                                                                                                           
取得:46 http://archive.ubuntu.com/ubuntu xenial/multiverse Translation-en [106 kB]                                                                                                            
取得:47 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 DEP-11 Metadata [63.8 kB]                                                                                                    
取得:48 http://archive.ubuntu.com/ubuntu xenial/multiverse DEP-11 64x64 Icons [230 kB]                                                                                                        
取得:49 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [856 kB]                                                                                                          
取得:50 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [349 kB]                                                                                                          
取得:51 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 DEP-11 Metadata [320 kB]                                                                                                   
取得:52 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease [23.5 kB]                                                                                                     
取得:53 http://archive.ubuntu.com/ubuntu xenial-updates/main DEP-11 64x64 Icons [237 kB]                                                                                                      
取得:54 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [7,556 B]                                                                                                   
取得:55 http://archive.ubuntu.com/ubuntu xenial-updates/restricted Translation-en [2,272 B]                                                                                                   
取得:56 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 DEP-11 Metadata [157 B]                                                                                              
取得:57 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [690 kB]                                                                                                      
取得:58 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [279 kB]                                                                                                      
取得:59 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [247 kB]                                                                                               
取得:60 http://ppa.launchpad.net/elementary-os/stable/ubuntu xenial/main amd64 Packages [40.0 kB]                                                                                             
取得:61 http://archive.ubuntu.com/ubuntu xenial-updates/universe DEP-11 64x64 Icons [335 kB]                                                                                                  
取得:62 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [16.4 kB]                                                                                                   
取得:63 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse Translation-en [8,344 B]                                                                                                   
取得:64 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,968 B]                                                                                            
取得:65 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse DEP-11 64x64 Icons [14.3 kB]                                                                                               
取得:66 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [7,304 B]                                                                                                       
取得:67 http://archive.ubuntu.com/ubuntu xenial-backports/main Translation-en [4,456 B]                                                                                                       
取得:68 https://packagecloud.io/slacktechnologies/slack/debian jessie/main amd64 Packages [9,293 B]                                                                                           
取得:69 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,328 B]                                                                                                
取得:70 http://archive.ubuntu.com/ubuntu xenial-backports/main DEP-11 64x64 Icons [29 B]                                                                                                      
取得:71 http://archive.ubuntu.com/ubuntu xenial-backports/restricted amd64 DEP-11 Metadata [194 B]                                                                                            
取得:72 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [7,804 B]                                                                                                   
取得:73 http://archive.ubuntu.com/ubuntu xenial-backports/universe Translation-en [4,184 B]                                                                                                   
取得:74 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [5,104 B]                                                                                            
無視:75 https://packagecloud.io/slacktechnologies/slack/debian jessie/main i386 Packages                                                                                                      
取得:76 http://archive.ubuntu.com/ubuntu xenial-backports/universe DEP-11 64x64 Icons [1,789 B]                                                                                               
取得:77 http://archive.ubuntu.com/ubuntu xenial-backports/multiverse amd64 DEP-11 Metadata [216 B]                                                                                            
取得:78 http://archive.ubuntu.com/ubuntu xenial-backports/multiverse DEP-11 64x64 Icons [29 B]                                                                                                
取得:79 http://archive.ubuntu.com/ubuntu xenial-security/main amd64 Packages [563 kB]                                                                                                         
取得:75 https://packagecloud.io/slacktechnologies/slack/debian jessie/main i386 Packages [4,991 B]                                                                                            
取得:80 http://archive.ubuntu.com/ubuntu xenial-security/main Translation-en [237 kB]                                                                                                         
取得:81 http://archive.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [67.7 kB]                                                                                                 
取得:82 http://archive.ubuntu.com/ubuntu xenial-security/main DEP-11 64x64 Icons [68.0 kB]                                                                                                    
取得:83 http://archive.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [7,204 B]                                                                                                  
取得:84 http://archive.ubuntu.com/ubuntu xenial-security/restricted Translation-en [2,152 B]                                                                                                  
取得:85 http://archive.ubuntu.com/ubuntu xenial-security/restricted amd64 DEP-11 Metadata [200 B]                                                                                             
取得:86 http://ppa.launchpad.net/elementary-os/stable/ubuntu xenial/main i386 Packages [39.9 kB]                                                                                              
取得:87 http://archive.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [387 kB]                                                                                                     
取得:88 http://archive.ubuntu.com/ubuntu xenial-security/universe Translation-en [147 kB]                                                                                                     
取得:89 http://archive.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [108 kB]                                                                                              
取得:90 http://archive.ubuntu.com/ubuntu xenial-security/universe DEP-11 64x64 Icons [145 kB]                                                                                                 
取得:91 http://archive.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3,460 B]                                                                                                  
取得:92 http://archive.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [1,744 B]                                                                                                  
取得:93 http://archive.ubuntu.com/ubuntu xenial-security/multiverse amd64 DEP-11 Metadata [212 B]                                                                                             
取得:94 http://archive.ubuntu.com/ubuntu xenial-security/multiverse DEP-11 64x64 Icons [29 B]                                                                                                 
取得:95 http://ppa.launchpad.net/elementary-os/stable/ubuntu xenial/main Translation-en [13.0 kB]                                                                                             
無視:96 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial Release                                                                                                                      
取得:97 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu xenial/main Sources [24.0 kB]                                                                                                
取得:98 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu xenial/main amd64 Packages [57.1 kB]                                                                                         
取得:99 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu xenial/main i386 Packages [56.6 kB]                                                                                          
取得:100 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu xenial/main Translation-en [28.0 kB]                                                                                        
取得:101 http://ppa.launchpad.net/philip.scott/elementary-tweaks/ubuntu xenial/main amd64 Packages [816 B]                                                                                    
取得:102 http://ppa.launchpad.net/philip.scott/elementary-tweaks/ubuntu xenial/main i386 Packages [820 B]                                                                                     
取得:103 http://ppa.launchpad.net/philip.scott/elementary-tweaks/ubuntu xenial/main Translation-en [304 B]                                                                                    
取得:104 http://ppa.launchpad.net/ubuntuhandbook1/audacity/ubuntu xenial/main amd64 Packages [988 B]                                                                                          
取得:105 http://ppa.launchpad.net/ubuntuhandbook1/audacity/ubuntu xenial/main i386 Packages [992 B]                                                                                           
取得:106 http://ppa.launchpad.net/ubuntuhandbook1/audacity/ubuntu xenial/main Translation-en [492 B]                                                                                          
取得:107 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main amd64 Packages [1,556 B]                                                                                                
取得:108 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main i386 Packages [1,556 B]                                                                                                 
取得:109 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main Translation-en [928 B]                                                                                                  
無視:110 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 Packages                                                                                                         
無視:111 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main i386 Packages                                                                                                          
無視:112 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main all Packages                                                                                                           
無視:113 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja_JP                                                                                                      
無視:114 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja                                                                                                         
無視:115 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-en                                                                                                         
無視:116 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 DEP-11 Metadata                                                                                                  
無視:117 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main DEP-11 64x64 Icons                                                                                                     
無視:110 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 Packages                                                                                                         
無視:111 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main i386 Packages                                                                                                          
無視:112 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main all Packages                                                                                                           
無視:113 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja_JP                                                                                                      
無視:114 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja                                                                                                         
無視:115 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-en                                                                                                         
無視:116 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 DEP-11 Metadata                                                                                                  
無視:117 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main DEP-11 64x64 Icons                                                                                                     
無視:110 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 Packages                                                                                                         
無視:111 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main i386 Packages                                                                                                          
無視:112 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main all Packages                                                                                                           
無視:113 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja_JP                                                                                                      
無視:114 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja
無視:115 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-en
無視:116 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 DEP-11 Metadata
無視:117 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main DEP-11 64x64 Icons
無視:110 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 Packages
無視:111 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main i386 Packages
無視:112 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main all Packages
無視:113 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja_JP
無視:114 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja
無視:115 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-en
無視:116 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 DEP-11 Metadata
無視:117 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main DEP-11 64x64 Icons
無視:110 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 Packages
無視:111 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main i386 Packages
無視:112 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main all Packages
無視:113 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja_JP
無視:114 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja
無視:115 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-en
無視:116 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 DEP-11 Metadata
無視:117 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main DEP-11 64x64 Icons
エラー:110 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 Packages
  404  Not Found
無視:111 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main i386 Packages
無視:112 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main all Packages
無視:113 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja_JP
無視:114 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-ja
無視:115 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main Translation-en
無視:116 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main amd64 DEP-11 Metadata
無視:117 http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial/main DEP-11 64x64 Icons
34.3 MB を 45秒 で取得しました (750 kB/s)
パッケージリストを読み込んでいます... 完了
W: リポジトリ http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu xenial Release には Release ファイルがありません。
N: このようなリポジトリから取得したデータは認証できないので、データの使用は潜在的に危険です。
N: リポジトリの作成とユーザ設定の詳細は、apt-secure(8) man ページを参照してください。
E: http://ppa.launchpad.net/hunter-kaller/ppa/ubuntu/dists/xenial/main/binary-amd64/Packages の取得に失敗しました  404  Not Found
E: いくつかのインデックスファイルのダウンロードに失敗しました。これらは無視されるか、古いものが代わりに使われます。

$ heroku --version
heroku: コマンドが見つかりません

heroku: command not found

つらい。

だめだった対処法

まず、herokuがあるかどうか確認。

$ sudo updatedb

$ sudo locate heroku
/var/lib/apt/lists/cli-assets.heroku.com_apt_._InRelease
/var/lib/apt/lists/cli-assets.heroku.com_apt_._Packages

wgetで取ったはずなのにない。

次にaptのパッケージupdateミスのせいかと思い、いろいろ試した。

以下の記事を参考にした。

qiita.com

これでもapt updateがうまく行かず、ダメだった。

最終的な対処法

npmをつかってheroku cliを入れました。

npm install -g heroku-cliはもう使われてないそうなので、npm install -g herokuを入れる。

$ sudo npm install -g heroku
/usr/local/bin/heroku -> /usr/local/lib/node_modules/heroku/bin/run
+ heroku@7.16.6
added 375 packages from 264 contributors in 11.284s

$ heroku --version
heroku/7.16.6 linux-x64 node-v10.2.1

やっと解決。

終わりに

デプロイコストがないとはいいましたが、heroku環境作るのに一日も費やしてしまいました。

反省してます。