【问题标题】:Homestead : Symbolic links not working on WindowsHomestead:符号链接在 Windows 上不起作用
【发布时间】:2018-03-17 18:16:15
【问题描述】:

我似乎无法在 Homestead 上创建任何符号链接。

在文档https://laravel.com/docs/5.6/homestead#provider-specific-settings 上说

如果符号链接在您的 Windows 机器上无法正常工作,您可能需要将以下代码块添加到您的 Vagrantfile:

config.vm.provider "virtualbox" do |v|
    v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end

这就是我所做的,现在我的 Vagrant 文件看起来像这样:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exist? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
        config.vm.provision "shell" do |s|
            s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases"
        end
    end

    if File.exist? homesteadYamlPath then
        settings = YAML::load(File.read(homesteadYamlPath))
    elsif File.exist? homesteadJsonPath then
        settings = JSON::parse(File.read(homesteadJsonPath))
    else
        abort "Homestead settings file not found in #{confDir}"
    end

    Homestead.configure(config, settings)

    if File.exist? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
    end

    if Vagrant.has_plugin?('vagrant-hostsupdater')
        config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-hostmanager')
        config.hostmanager.enabled = true
        config.hostmanager.manage_host = true
        config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
    end

    config.vm.provider "virtualbox" do |v|
        v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
    end
end

然而,当我像这样做任何符号链接时:

touch a
ln -s a b

我收到以下错误:

ln: failed to create symbolic link 'b': Protocol error

我该如何解决这个问题? 我是不是把代码放错地方了?

【问题讨论】:

  • 对我来说,以管理员身份运行是不够的,我在尝试创建符号链接时仍然遇到“协议错误”。这是有效的:stackoverflow.com/a/60741351/470749

标签: vagrant symlink homestead


【解决方案1】:

你可以试试:

v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/home/vagrant/code", "1"]

通知 /home/vagrant/code

我相信最后一部分一定是路径。这对你有用吗?

【讨论】:

  • /home/vagrant/code 路径是来自客户机还是主机操作系统?
【解决方案2】:

在本地机器上(不是 ssh'd 进入宅基地),转到您的根目录并使用 git bash 运行以下命令:

ln -sr a b

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-07
    • 1970-01-01
    • 2017-03-21
    • 1970-01-01
    • 2018-07-16
    • 1970-01-01
    • 2010-11-29
    • 2014-11-22
    相关资源
    最近更新 更多