UbuntuにVagrantにインストールした

RubyやRailsの開発環境をVagrantを使って構築したくて初めてみました。

まずは、Ubuntu16.04にVagrant1.8.5を入れてみました。インストール時の注意点がいくつかあったので纏めておきます。

RubyGemで提供されているvagrantは削除する

Vagrant本家のインストール方法の説明には、

Looking for the gem install? Vagrant 1.0.x had the option to be installed as a RubyGem. This installation method is no longer supported. If you have an old version of Vagrant installed via Rubygems, please remove it prior to installing newer versions of Vagrant.

の記載があります。かつてのバージョンは、RubyGemとしてインストールするオプションがあったけど、もうなくなったからRubyGems経由でインストールしたvagrantは削除して新しいバージョンをインストールした方が良さそう。

システムのパッケージマネージャがインストールするvagrantには用心する

上述のVagrant本家のインストール方法の説明には、

Beware of system package managers! Some operating system distributions include a vagrant package in their upstream package repos. Please do not install Vagrant in this manner. Typically these packages are missing dependencies or include very outdated versions of Vagrant. If you install via your system's package manager, it is very likely that you will experience issues. Please use the official installers on the downloads page.

の記載もあります。システムのパッケージマネージャがインストールするvagrantは古かったり、依存関係が解決できなかったりするので、この方法でインストールしてくれるな、と。

結局何をインストーするすればいいのか

Please use the official installers on the downloads page.

とあるので、ダウンロードページから公式インストーラをダウンロードしてインストールすればよい。

Ubunutu16.04にVagrant1.8.5をインストールする

Vagrantのダウンロードページで、DEBIANの64bit向けをダウンロードする。執筆時点では、vagrant_1.8.5_x86_64.debがダウンロードできた。

次のコマンドで、debパッケージをインストールする。

sudo dpkg -i vagrant_1.8.5_x86_64.deb

これでインストール完了。

% which vagrant
/usr/bin/vagrant
% vagrant --version
Vagrant 1.8.5
% vagrant help
Usage: vagrant [options] <command> [<args>]

    -v, --version                    Print the version and exit.
    -h, --help                       Print this help.

Common commands:
     box             manages boxes: installation, removal, etc.
     connect         connect to a remotely shared Vagrant environment
     destroy         stops and deletes all traces of the vagrant machine
     global-status   outputs status Vagrant environments for this user
     halt            stops the vagrant machine
     help            shows the help for a subcommand
     init            initializes a new Vagrant environment by creating a Vagrantfile
     login           log in to HashiCorp's Atlas
     package         packages a running vagrant environment into a box
     plugin          manages plugins: install, uninstall, update, etc.
     port            displays information about guest port mappings
     powershell      connects to machine via powershell remoting
     provision       provisions the vagrant machine
     push            deploys code in this environment to a configured destination
     rdp             connects to machine via RDP
     reload          restarts vagrant machine, loads new Vagrantfile configuration
     resume          resume a suspended vagrant machine
     share           share your Vagrant environment with anyone in the world
     snapshot        manages snapshots: saving, restoring, etc.
     ssh             connects to machine via SSH
     ssh-config      outputs OpenSSH valid configuration to connect to the machine
     status          outputs status of the vagrant machine
     suspend         suspends the machine
     up              starts and provisions the vagrant environment
     version         prints current and latest Vagrant version

For help on any individual command run `vagrant COMMAND -h`

Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.

つまり、Vagrantをインストールするには、本家ダウンロードサイトからダウンロードしてインストールしよう、ということですね。