2

I can't seem to do any sym links on Homestead.

On the docs https://laravel.com/docs/5.6/homestead#provider-specific-settings it says that

If symbolic links are not working properly on your Windows machine, you may need to add the following block to your Vagrantfile:

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

This is what I did so now my Vagrant file looks like this:

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

Yet when I do any symbolic links like so:

touch a
ln -s a b

I get the following error:

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

How can I solve this problem? Did I place the code in the wrong place?

Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231
  • For me, running as administrator was not enough, and I still got "Protocol error" when trying to create symlinks. Here was what worked: https://stackoverflow.com/a/60741351/470749 – Ryan Mar 18 '20 at 14:18

2 Answers2

0

Could you try:

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

Notice /home/vagrant/code

I believe the last part must be the path. Is that working for you?

Ametad
  • 402
  • 2
  • 10
0

While on local machine, (not ssh'd into homestead), go to your root directory and run the following command using git bash:

ln -sr a b
gchristo234
  • 158
  • 3
  • 11