studio
studio copied to clipboard
Plugins and themes can't be symlinked
What
I would love to be able to symlink plugins and themes.
Why
As a plugin developer, I often spin up new sites to reproduce specific scenarios, discover edge cases, etc and I would like to be able to symlink plugin(s) into my studio managed sites so that I can use a canonical version of the plugin(s) on my machine across different studio sites.
How
I would like to be able to :
-
navigate to the plugins directory of my studio site:
cd ~/Studio/site-name/wp-content/plugins -
symlink a plugin I have on my machine into the site:
ln -s ~/path/to/my/plugin -
Activate the symlinked plugin in my studio site
Currently, I can symlink a plugin into the plugins directory and it shows properly symlinked on my machine, but the WP admin does not show the symlinked plugin as an available plugin to activate.
If there is support for symlinks was also one of my first thoughts when I installed Studio. Unfortunately, symlinks do not (yet) work. This would be a big plus for Studio.
Upvote!
Really need this working. With out it myself and team can't use the app which is a great shame. Any idea on how to get this working or when it will be fixed. Thanks
@AndrewBrightbulb We are in planning phases for this now, in fact! We'll ping on this issue when we have a build for you to test out.
Heads up that this was solved on macOS in https://github.com/Automattic/studio/pull/510. Stay tuned as it will be released in version 1.1.3 🎊 .
cc @jeroenpf
Heads up that this was solved on macOS in #510. Stay tuned as it will be released in version
1.1.3🎊 .cc @jeroenpf
That is amazing :) We will be using it once it is released.
Hi, I have downloaded the latest version 1.1.3 and unfortunately the symlink still isn't working for me
Hi, I have downloaded the latest version 1.1.3 and unfortunately the symlink still isn't working for me
Hey @AndrewBrightbulb, I've tested version 1.1.3 and I confirmed that symlinks are working on my side. I wonder if you could share your case so we can take a look and try to debug it. Thanks 🙇 !
As an example, I symlinked the Gutenberg plugin for development:
- Select a site.
- Click on Terminal.
- Run the command
ln -s <PATH_TO_GUTENGERG_REPO> ./wp-content/plugins/gutenberg(replace the path to Gutenberg with an actual path). - Navigate to WP-Admin -> Plugins.
- Observe that the plugin is listed.
I can confirm this is working for me in version 1.1.3 on macOS. Thank you!
Hmm, it seems if a symlinked theme is activated and the site is stopped in Studio, when the site is restarted it goes back to the default theme. This does not happen if using a theme that is not symlinked.
I was able to symlink plugins and themes. But it's true that the symlinked themes is replaced by the default one when restarting the site server.
I've also experienced the same issue when just changing the window focus to Studio. It seems that the logic that captures the home screenshot resets the theme to the default one.
https://github.com/user-attachments/assets/3f6e6aa8-ba30-4aa6-8546-3922e407bf75
I've identified where the error comes from, but I don't have a solution.
It seems that when we run a PHP code or WP-CLI command by spawning a new child process in src/lib/site-server-process-child.ts, it starts a new server and that seems to reset the theme to default, probably because it's removing the symlink temporarly.
Commenting these two focus hooks, I can see the selected theme persists. Although stopping and starting seems to reset it some times.
https://github.com/Automattic/studio/blob/587292a9a0e64bbee0b4c223cb228e10a47dab6a/src/hooks/use-chat-context.tsx#L133-L142
https://github.com/Automattic/studio/blob/587292a9a0e64bbee0b4c223cb228e10a47dab6a/src/hooks/use-theme-details.tsx#L75-L81
First of all, thanks for getting the initial Symlinking working :) I did do some testing with WooCommerce and noticed that when I symlink WooCommerce a lot of the REST requests fail, not all of them though, around 90%. But when I install WooCommerce as a plugin all the REST requests work fine.
Just noting that on Studio version 1.3.0, symlinked plugins on macOS randomly stop working, after having worked for hours. This results in deactivated plugins when it happens. Sometimes the plugins will show up after a couple refreshes in admin, and sometimes I have to restart the site. In any case, the plugin must be reactivated afterwards. It's unclear to me why this would happen, since it's all on the same file system.
The root cause of this issue is that WP-cli executions don't mount symlinked folders, so during a WP-cli run, WordPress can't find the symlinked themes and plugins.
Mount symlinks when executing WP-cli commands #809 addresses this by mounting the project path before executing WP-cli commands.