Homestead:符号链接无法在Windows上运行

时间:2018-03-17 18:16:15

标签: vagrant symlink homestead

我似乎无法在Homestead上做任何sym链接。

在文档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

我该如何解决这个问题? 我是否将代码放在了错误的位置?

2 个答案:

答案 0 :(得分:0)

你可以尝试一下:

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

注意 /home/vagrant/code

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

答案 1 :(得分:0)

在本地计算机上(而不是ssh'd进入homestead)时,请转到您的根目录并使用git bash运行以下命令:

$template abc-zscaler-web,"/var/rsyslog/zscaler-web/%FROMHOST%/abc-%$year%-%$month%-%$day%.log"
$template def-zscaler-web,"/var/rsyslog/zscaler-web/%FROMHOST%/def-%$year%-%$month%-%$day%.log"
$template ghi-zscaler-web,"/var/rsyslog/zscaler-web/%FROMHOST%/ghi-%$year%-%$month%-%$day%.log"
$RuleSet Remote1522
$RuleSet CreateMainQueue on
if $msg contains 'location=ABC ' then -?abc-zscaler-web
if $msg contains 'location=ABC ' then stop
if $msg contains 'location=DEF ' then -?def-zscaler-web
if $msg contains 'location=DEF ' then stop
if $msg contains 'location=GHI ' then -?ghi-zscaler-web
if $msg contains 'location=GHI ' then stop
*.*  -?abc-zscaler-web
$InputTCPServerBindRuleset Remote1522
$InputTCPServerRun 1522