我正在尝试在Mac OS X平台上设置Ubuntu服务器,以启用旧版Ruby on Rails应用程序的安装。问题出在与映射到虚拟机的同步文件有关。
环境描述:
在Mac OS X环境中,有一个源目录,下面有两个本地存储库;
因此,在配置时,我想挂载可从Ubuntu机器访问的myproject应用程序源。在VagrantFile示例之后,我按照以下步骤设置了共享文件夹:
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "../myproject", "/home/vagrant/myproject"
基本上,我假设相对于保存VagrantFile的文件夹,我要上一层楼。这是整个工作的基础,其中包含一个用于存放Vagrant信息的文件夹和一个用于源代码的文件夹。
问题
现在,当我执行vagrant up
命令时,Ubuntu计算机被旋转了,我发现以下内容:
VagrantFile
所在文件夹中的信息位于Ubuntu计算机上的 / vagrant 我期望应用程序源代码文件夹将在 / vagrant 的安装点下与Ubuntu计算机共享。关于同步文件夹(documentation)的Vagrant文档指出:
The first parameter is a path to a directory on the host machine. If
the path is relative, it is relative to the project root
例如
Vagrant.configure("2") do |config|
# other config here
config.vm.synced_folder "src/", "/srv/website"
end
因此,由于我已将同步文件夹指定为config.vm.synced_folder "../myproject", "/home/vagrant/myproject"
,因此它将被附加到流浪用户主目录下的服务器上,而不是文件系统的根目录下。
有什么建议吗?