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

Sync Read-only Filesystem Error #322

Open
blhylton opened this issue Jun 28, 2023 · 3 comments
Open

Sync Read-only Filesystem Error #322

blhylton opened this issue Jun 28, 2023 · 3 comments

Comments

@blhylton
Copy link

  • Laravel version: 10.11.0
  • Algolia Scout Extended version: 3.0.0
  • Algolia Client Version: 3.3.2
  • Language Version: PHP 8.2

Description

You cannot run the scout:sync command on Laravel Vapor if the settings on Algolia have been changed independently.

🔎 Analysing settings from: [App\Event]
Downloading remote settings...

In Filesystem.php line 205:

file_put_contents(/var/task/config/scout-prod-events-8827424.php): Failed to open stream: Read-only file system

When attempting to run the command, I get stuck on this model because some things were updated in Algolia, and it's trying to sync the server settings to the file. Vapor does not have writable storage like this.

Steps To Reproduce

  • Set up an Algolia index for an app hosted on Laravel Vapor.
  • Make changes via the Algolia UI.
  • Attempt to sync changes to Vapor.

This is a little guesswork on my part as to "why this model?" but I feel reasonably confident that it is because sync is attempting to write to local storage explicitly instead of just allowing whatever the default is to take over. Laravel Vapor doesn't really have local storage other than a small amount of incidental temporary space.

@DevinCodes
Copy link
Contributor

Hi @blhylton ,

As far as I can tell, this is the expected behaviour for the scout:sync command: if settings have been changed in Algolia, it will synchronise them to the settings file in your config. You should therefore only synchronise on a system where you have write access. You can, for example, run the command locally to ensure it's up to date with Algolia. Then, any changes to the settings that need to be made can be made in the settings file directly and be applied in a read-only environment by syncing from your app to Algolia, and not the other way around.

I hope that helps, let me know if anything is unclear! 🙂

@blhylton
Copy link
Author

Hi @DevinCodes

I understand what you're saying, but the issue is that this stops the command from running entirely. Even if flagged as --keep local, it will still attempt to download the file to the unwritable storage. After some testing, this is also an issue if you have a searchable model that you don't want to be synced to Algolia, so you don't have Algolia indexes set up for it (we have two different Scout engines being used in this particular project for different purposes).

Ideally, I would be able to skip updating server -> local and skip the run of scout:optimize so that I can run this from production without writing to the code and ensure that the production Algolia index is in sync with the production schema.

The issue with running it locally is that I have different indexes for production, staging, local, etc.; swapping them out would be manual and annoyingly error-prone.

@DevinCodes
Copy link
Contributor

Hey @blhylton ,

Thank you for the explanation of your use case, it makes a lot of sense. I definitely see value in adding an option that would skip updating server settings to local to circumvent this issue, and would be open to review a PR that addresses this 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants