Symbolic link for local uploads folder not working

Hi there,

Since I’m managing multiple wordpress sites on my MacBook (which has limited space), I moved all my local uploads folders to an external drive and made symbolic links to them in the appropriate web/app folders.
Somehow this is not working with the blade caching, since I’m getting these errors:

Warning: file_put_contents(/srv/www/example.com/current/web/app/uploads/cache/153baca870277de9d74e3e448e87c18c90e0f7ae.php): failed to open stream: No such file or directory in /srv/www/example.com/current/web/app/themes/sage/vendor/illuminate/filesystem/Filesystem.php on line 122
Warning: include(/srv/www/example.com/current/web/app/uploads/cache/153baca870277de9d74e3e448e87c18c90e0f7ae.php): failed to open stream: No such file or directory in /srv/www/example.com/current/web/app/themes/sage/vendor/illuminate/view/Engines/PhpEngine.php on line 43
Warning: include(): Failed opening '/srv/www/example.com/current/web/app/uploads/cache/153baca870277de9d74e3e448e87c18c90e0f7ae.php' for inclusion (include_path='.:/usr/share/php') in /srv/www/example.com/current/web/app/themes/sage/vendor/illuminate/view/Engines/PhpEngine.php on line 43

I checked the folder permissions and they are the same.
I did a vagrant reload but still get the same errors…

Is this possible? And if not, can I set a custom folder path for the blade caching somewhere?
Thanks!

EDIT 1
Sorry, you can set a custom cache location here: https://github.com/roots/sage/blob/8691074b29c4c09dae40f0f0c33dc2b51d9292e2/config/view.php#L32

But it turns out the symbolic link itself is not working within the vagrant box…
Is there an other way I can achieve the same thing?

EDIT 2
Adding this line to the Virtualbox settings in the Vagrantfile:

VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root', '1']

also does not make a difference…

I’ve had trouble with symbolic links that attempt to cross the guest/host VM boundary. I’d recommend just using VirtualBox’s Folder Sync: https://www.vagrantup.com/docs/synced-folders/basic_usage.html

1 Like

Thanks! I’ll give that a try!
Although ideally I would like to have a setup where I could still run my local VM on the road without my external drive connected, but I think that won’t work with an actual synced folder?

I’m not sure that symlinks would perform any better in that situation. I’m not sure what Vagrant will do if it can’t find a synced folder: my guess would be that it boots but just doesn’t sync that folder.

You could also switch to Windows and use junctions instead of symlinks, which work fine w/ VMs. :wink:

:joy:

That could work

When I come to think of it, this wouldn’t work in my case since I would need to hardcode the path to my external drive as synced folder in the Vagrantfile and I’m sharing the code with colleagues…