Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins and themes can't be symlinked #20

Open
jasonbahl opened this issue Apr 24, 2024 · 12 comments
Open

Plugins and themes can't be symlinked #20

jasonbahl opened this issue Apr 24, 2024 · 12 comments
Assignees
Labels
Groundskeeping Worked on by Dotcom Groundskeeping Studio App [Type] Bug Something isn't working

Comments

@jasonbahl
Copy link

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.

@jasonbahl jasonbahl added the [Type] Enhancement Improvement upon an existing feature label Apr 24, 2024
@miczh
Copy link

miczh commented May 22, 2024

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.

@divydovy
Copy link

Upvote!

@wojtekn wojtekn changed the title Feature Request: Allow Symlinking of plugins and themes Plugins and themes can't be symlinked Jul 31, 2024
@wojtekn wojtekn added [Type] Bug Something isn't working Studio App and removed [Type] Enhancement Improvement upon an existing feature labels Jul 31, 2024
@AndrewBrightbulb
Copy link

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

@danielbachhuber
Copy link
Contributor

@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.

@jartes jartes moved this from Needs Triage to Triaged in Automattic Prioritization: The One Board ™ Aug 14, 2024
@fluiddot
Copy link
Contributor

Heads up that this was solved on macOS in #510. Stay tuned as it will be released in version 1.1.3 🎊 .

cc @jeroenpf

@AndrewBrightbulb
Copy link

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.

@AndrewBrightbulb
Copy link

Hi,
I have downloaded the latest version 1.1.3 and unfortunately the symlink still isn't working for me

@fluiddot
Copy link
Contributor

fluiddot commented Oct 2, 2024

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:

  1. Select a site.
  2. Click on Terminal.
  3. Run the command ln -s <PATH_TO_GUTENGERG_REPO> ./wp-content/plugins/gutenberg (replace the path to Gutenberg with an actual path).
  4. Navigate to WP-Admin -> Plugins.
  5. Observe that the plugin is listed.

@mindctrl
Copy link

mindctrl commented Oct 7, 2024

I can confirm this is working for me in version 1.1.3 on macOS. Thank you!

@mindctrl
Copy link

mindctrl commented Oct 7, 2024

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.

@sejas
Copy link
Member

sejas commented Oct 9, 2024

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.

default-theme-symlink-studio.mp4

@sejas sejas self-assigned this Oct 9, 2024
@sejas sejas added the Groundskeeping Worked on by Dotcom Groundskeeping label Oct 9, 2024
@sejas
Copy link
Member

sejas commented Oct 10, 2024

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.

useWindowListener( 'focus', async () => {
// When the window is focused, we need to kick off a request to refetch the theme details, if server is running.
if ( ! selectedSite?.id || selectedSite.running === false || selectedSite?.isAddingSite ) {
return;
}
const plugins = await fetchPluginList( selectedSite.id );
const themes = await fetchThemeList( selectedSite.id );
setPluginsList( ( prev ) => ( { ...prev, [ selectedSite.id ]: plugins } ) );
setThemesList( ( prev ) => ( { ...prev, [ selectedSite.id ]: themes } ) );
} );

useWindowListener( 'focus', async () => {
// When the window is focused, we need to kick off a request to refetch the theme details, if server is running.
if ( ! selectedSite?.id || selectedSite.running === false ) {
return;
}
await getIpcApi()?.getThemeDetails?.( selectedSite.id );
} );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groundskeeping Worked on by Dotcom Groundskeeping Studio App [Type] Bug Something isn't working
Projects
Development

No branches or pull requests

9 participants