MacのComposerでタイムアウトになるのを解決。


Macのcomposerを使おうとしたらタイムアウトのエラーになった。
家のネット環境がwimax2になってからのエラー。

エラー内容

  • composerを使おうとしたら以下のエラーが出た。
% composer require google/apiclient:^2.0

The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out
https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date


  [Composer\Downloader\TransportException]                                                                                                                                                    
  The "https://packagist.org/p/google/apiclient%24cb2b69d70145ea262e3c394dd495e52ba16b27e3c157ac185d1c4777ba34f39b.json" file could not be downloaded: failed to open stream: Operation time  
  d out 
  • composer自身のアップデートしようとしても同様のエラーが出た。

% composer self-update

The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Operation timed out
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info


  [Composer\Downloader\TransportException]                                                                         
  The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Operation timed out  

networksetupコマンドで解決

  • Wi-FiのIPV6をオフにして自動に設定し直す
% networksetup -setv6off Wi-Fi
% networksetup -setv6automatic Wi-Fi    
  • 使えるようになった。

% composer self-update                
Updating to version 1.6.4 (stable channel).
   Downloading (100%)         
Use composer self-update --rollback to return to version 1.6.3

wifiの状態確認コマンド

%  networksetup -getinfo Wi-Fi
DHCP Configuration
IP address: 192.168.●●●.●●●
Subnet mask: 255.255.255.0
Router: 192.168.100.1
Client ID: 
IPv6: Automatic
IPv6 IP address: none
IPv6 Router: none
Wi-Fi ID: ●●:●●:●●:●●:●●:●●