About web_module
thelastinuit opened this issue ยท 6 comments
This not necessary a bug but it certainly happened to me.
In shopifex/plug/payment_guard.ex:
@router_helpers Module.concat([
Application.compile_env(:shopifex, :web_module, ShopifexWeb),
Router,
Helpers
])
...
show_plans_url =
@router_helpers.payment_path(conn, :show_plans, %{
guard_identifier: guard_identifier,
redirect_after: redirect_after,
token: Shopifex.Plug.session_token(conn)
})
The default value is ShopifexWeb
which make the follow non-existent ShopifexWeb.Router.Helpers
. That's totally fine since in the README.md
, you have:
config :shopifex,
app_name: "MyApp",
shop_schema: MyApp.Shop,
web_module: MyAppWeb, # <-- HERE
repo: MyApp.Repo,
redirect_uri: "https://myapp.ngrok.io/auth/install",
reinstall_uri: "https://myapp.ngrok.io/auth/update",
webhook_uri: "https://myapp.ngrok.io/webhook",
scopes: "read_inventory,write_inventory,read_products,write_products,read_orders",
api_key: "shopifyapikey123",
secret: "shopifyapisecret456",
webhook_topics: ["app/uninstalled"] # These are automatically subscribed on a store upon install
The issue is compile_env
because when you try to run the app, you get the following message:
ERROR! the application :shopifex has a different value set for key :web_module during runtime compared to compile time. Since this application environment entry was marked as compile time, this difference can lead to different behaviour than expected:
* Compile time value was not set
* Runtime value was set to: SuturWeb
To fix this error, you might:
* Make the runtime value match the compile time one
* Recompile your project. If the misconfigured application is a dependency, you may need to run "mix deps.compile shopifex --force"
* Alternatively, you can disable this check. If you are using releases, you can set :validate_compile_env to false in your release configuration. If you are using Mix to start your system, you can pass the --no-validate-compile-env flag
That force you to compile your Shopifex deps as follows:
$ mix deps.compile shopifex --no-validate-compile-env --force
==> shopifex
Compiling 47 files (.ex)
warning: MyAppWeb.Router.Helpers.payment_path/3 is undefined (module MyAppWeb.Router.Helpers is not available or is yet to be defined)
lib/shopifex/plug/payment_guard.ex:52: Shopifex.Plug.PaymentGuard.call/2
Generated shopifex app
which makes the app works. Perhaps, the way to go is like in ib/shopifex_web.ex:
web_module = Application.get_env(:shopifex, :web_module)
Thank you for the analysis! Let's turn it into a runtime function rather than compile time thing.
I think your suggestion makes sense. Want to open a PR?
Thank you for the analysis! Let's turn it into a runtime function rather than compile time thing.
I think your suggestion makes sense. Want to open a PR?
I have no idea what's the right solution. If you have something in mind, I can for sure do the PR.
Can you tell me what you have in mind? Share as much detail as possible ๐
thanks!
Thank you for helping improve this lib :)
Thank you for helping improve this lib :)
oh no, thanks to ya! makes my life easier! happy to help :)