命令 'vagrant' 未找到

Command 'vagrant' not found

我在本地计算机上重新安装 vagrant 失败。最初,我 vagrant 下载、安装并 运行 宁好,但决定卸载它。我的卸载如下:

$ rm -rf /opt/vagrant
$ rm -f /usr/bin/vagrant

正在 运行ning $ which vagrant 检查 vagrant,我找不到它意味着它已成功卸载。

要重新安装它,我执行了以下步骤,但我不断收到消息 Command 'vagrant' not found, but can be installed with: sudo apt install vagrant:

正在安装虚拟机

我先安装virtualbox再安装vagrant:

$ sudo apt install virtualbox
$ which virtualbox

安装 Vagrant:选项 1

$ sudo apt install vagrant

这是我得到的结果:

Reading package lists... Done Building dependency tree
Reading state information... Done vagrant is already the newest version (1:2.2.10).

The following packages were automatically installed and are no longer required:

augeas-lenses bsdtar cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux fonts-lato hfsplus ibverbs-providers icoutils ipxe-qemu ipxe-qemu-256k-compat-efi-roms ldmtool libafflib0v5 libarchive-tools libaugeas0 libbfio1 libcacard0 libconfig9 libdate-manip-perl libdevmapper-event1.02.1 libewf2 libfdt1 libguestfs-hfsplus libguestfs-perl libguestfs-reiserfs libguestfs-tools libguestfs-xfs libguestfs0 libhfsp0 libhivex0 libibverbs1 libintl-perl libintl-xs-perl libiscsi7 libldm-1.0-0 liblvm2app2.2 liblvm2cmd2.02 libnl-route-3-200 librados2 librbd1 librdmacm1 libruby2.5 libsodium-dev libspice-server1 libstring-shellquote-perl libsys-virt-perl libsystemd0:i386 libtsk13 libudev1:i386 libusbredirparser1 libvirt0 libwin-hivex-perl libxen-4.9 libxenstore3.0 lsscsi lvm2 msr-tools nfs-kernel-server osinfo-db pkg-config qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils rake ruby ruby-bcrypt-pbkdf ruby-blankslate ruby-builder ruby-childprocess ruby-did-you-mean ruby-domain-name ruby-erubis ruby-excon ruby-ffi ruby-fog-core ruby-fog-json ruby-fog-libvirt ruby-fog-xml ruby-formatador ruby-http-cookie ruby-i18n ruby-json ruby-libvirt ruby-listen ruby-log4r ruby-mime-types ruby-mime-types-data ruby-minitest ruby-multi-json ruby-net-scp ruby-net-sftp ruby-net-ssh ruby-net-telnet ruby-netrc ruby-nokogiri ruby-oj ruby-pkg-config ruby-power-assert ruby-rb-inotify ruby-rbnacl ruby-rest-client ruby-sqlite3 ruby-test-unit ruby-unf ruby-unf-ext ruby2.5 rubygems-integration scrub seabios sgabios sleuthkit supermin vagrant-libvirt zerofree

Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 105 not upgraded.

检查是否安装了vagrant,我运行:

$ vagrant --version

结果是:

Command 'vagrant' not found, but can be installed with:
sudo apt install vagrant

安装 Vagrant:选项 2:

我首先在 vagrants downloads page 上检查了 vagrant 的最新版本,然后通过以下命令 运行 下载并安装了它:

$ sudo apt update
$ curl -O https://releases.hashicorp.com/vagrant/2.2.10/vagrant_2.2.10_x86_64.deb
$ sudo apt install ./vagrant_2.2.10_x86_64.deb

我得到的结果和上面的选项1一样。我已经在线检查了类似问题及其可能的解决方案,例如 this example,大多数建议都指向 PATH。然而,什么也没有。

我已经查看了 documentation among other articles on how to properly install vagrant such as this,但 Command 'vagrant' not found 仍然存在。可能是什么问题?在这一点上,使用 vagrant 的前进完全停滞了。

当我 运行:

时,我可以看出 vagrant 没有安装
$ which vagrant

由于您只是删除了文件而不是使用 apt-getdpkg 来卸载包,包管理并不知道您的手动删除,因此 apt-getdpkg 仍然认为已经安装了最新版本,所以什么都不做。

apt-get --reinstall install vagrant

应该可以解决这个问题。