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

Sprockets vs optional config files #2185

Open
gravitystorm opened this issue Mar 20, 2019 · 2 comments
Open

Sprockets vs optional config files #2185

gravitystorm opened this issue Mar 20, 2019 · 2 comments
Labels
dx Developer Experience

Comments

@gravitystorm
Copy link
Collaborator

In app/assets/javascripts/osm.js.erb we need to tell sprockets to recompile the output whenever the settings change. To do this we mark that file as depending on config/settings.yml and config/settings.local.yml.

However, this throws up two problems:

  • settings.local.yml is supposed to be optional, but Sprockets throws an error if the file can't be found.
  • The config gem also supports a bunch of other files, which should also trigger a recompile if they exist and then get changed.

I've checked through the sprockets documentation, but I can't see any obvious guidance for approaches to this situation.

Potential solutions include:

  • Remove the dependency on settings.local.yml. This will make the 'out-of-the-box' situation better for developers, but could lead to problems later on when changes to that file are not reflected in the compiled javascript (without manual asset recompilation).
  • Ask the upstream sprockets developers what they think about depending on optional files, or if they have any suggestions.
  • Create an initializer which outputs the computed settings to a file, and depend on that output file instead.
@gravitystorm
Copy link
Collaborator Author

For anyone who gets ActionView::Template::Error: couldn't find file 'settings.local.yml' or similar when first setting up your environment, then this issue is the root cause. You need to create an empty file in config/settings.local.yml, for example by running:

$ touch config/settings.local.yml

@mmd-osm
Copy link
Contributor

mmd-osm commented Feb 3, 2022

How about:

  • Create an empty settings.local.yml file in config.rb, in case no local settings have been created
  • If that doesn't work, print out an error message and exit, asking the dev to create an empty file settings.local.yml file themselves.

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

No branches or pull requests

2 participants