You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to ensure some links are fully qualified URLs with scheme, host, etc.
This works when deploying to a small number of known locations by hardcoding build_url in each environment inside nanoc.yaml. However, we deploy PRs to dynamic environments that have generated hostnames via Netlify's build preview feature.
Suggestions
Some solutions that come to mind:
Allow some targeted configuration values to be defined as environment variables, such as BUILD_URL
Parse nanoc.yaml as ERB before consuming, so we can build_url: <%= ENV["BUILD_URL"] %>
If this is already possible somehow, please let me know.
Attempted solution
I tried a hack of including this snippet at the top of Rules:
@config[:base_url]=ENV["BUILD_URL"]
This works a charm for nanoc compile, but fails with frozen errors on nanoc check:
Captain! We’ve been hit!
FrozenError: can't modify frozen Hash
You attempted to modify immutable data. Some data cannot be modified once compilation has started. Such data includes content and attributes of items and layouts, and fil
nts.
0. /usr/local/bundle/gems/nanoc-core-4.11.14/lib/nanoc/core/configuration.rb:119:in `[]='
1. /app/Rules:3:in `parse'
2. /usr/local/bundle/gems/nanoc-4.11.14/lib/nanoc/rule_dsl/rules_loader.rb:26:in `instance_eval'
3. /usr/local/bundle/gems/nanoc-4.11.14/lib/nanoc/rule_dsl/rules_loader.rb:26:in `parse'
4. /usr/local/bundle/gems/nanoc-4.11.14/lib/nanoc/rule_dsl/rules_loader.rb:15:in `load'
5. /usr/local/bundle/gems/nanoc-4.11.14/lib/nanoc/rule_dsl/action_provider.rb:20:in `for'
6. /usr/local/bundle/gems/nanoc-core-4.11.14/lib/nanoc/core/compiler_loader.rb:18:in `load'
7. /usr/local/bundle/gems/nanoc-core-4.11.14/lib/nanoc/core/compiler.rb:31:in `new_for'
8. /usr/local/bundle/gems/nanoc-4.11.14/lib/nanoc/checking/check.rb:35:in `create'
9. /usr/local/bundle/gems/nanoc-4.11.14/lib/nanoc/checking/runner.rb:101:in `block in run_checks'
... 22 lines omitted (see crash.log for details)
A detailed crash log has been written to ./crash.log.
The text was updated successfully, but these errors were encountered:
Thanks, @ddfreyne, that sure seems to have done the trick! I guess check calls @config.freeze after the preprocessing has happened? Do you think this is something we should add to the docs in some way?
tammersaleh
changed the title
Allow for dynamic build_url (and maybe other env settings)
Allow for dynamic build_url (and maybe other @config settings)
Mar 9, 2021
Problem
We need to ensure some links are fully qualified URLs with scheme, host, etc.
This works when deploying to a small number of known locations by hardcoding
build_url
in eachenvironment
insidenanoc.yaml
. However, we deploy PRs to dynamic environments that have generated hostnames via Netlify's build preview feature.Suggestions
Some solutions that come to mind:
BUILD_URL
nanoc.yaml
as ERB before consuming, so we canbuild_url: <%= ENV["BUILD_URL"] %>
--config
flag to thenanoc
CLI --config option on commandline #676If this is already possible somehow, please let me know.
Attempted solution
I tried a hack of including this snippet at the top of
Rules
:This works a charm for
nanoc compile
, but fails with frozen errors onnanoc check
:The text was updated successfully, but these errors were encountered: