sorry ca_store.ex doesn’t exist cause
here is my application.ex I think CAStore might use in Ecto Im not sure
defmodule Wb.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
children = [
# Start the Telemetry supervisor
WbWeb.Telemetry,
# Start the Ecto repository
# Wb.Repo,
# Start the PubSub system
{Phoenix.PubSub, name: Wb.PubSub},
WbWeb.Presence,
# Start the Endpoint (http/https)
WbWeb.Endpoint,
# Start a worker by calling: Wb.Worker.start_link(arg)
# {Wb.Worker, arg}
Wb.Tracker.TrackerSupervisor,
{
MyXQL,
username: "",
database: "wbdev-db",
hostname: "",
password: "",
ssl: true,
ssl_opts: [
verify: :verify_peer,
cacertfile: CAStore.file_path(),
server_name_indication: String.to_charlist("aws.connect.psdb.cloud"),
customize_hostname_check: [
match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
]
],
}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Wb.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
WbWeb.Endpoint.config_change(changed, removed)
:ok
end
end
Ahh, CAStore.file_path() is from the dependency castore.
Would config files even have access to dependencies? If I recall correctly, config files are read at build time, which is before the application gets compiled and its dependencies loaded.
Configuration files provide a mechanism for us to configure the environment of any application. Elixir provides two configuration entry points:
config/config.exs - this file is read at build time, before we compile our application and before we even load our dependencies. This means we can’t access the code in our application nor in our dependencies. However, it means we can control how they are compiled
config/runtime.exs - this file is read after our application and dependencies are compiled and therefore it can configure how our application works at runtime. If you want to read system environment variables (via System.get_env/1) or any sort of external configuration, this is the appropriate place to do so
Were you able to resolve this? The planetscale connection configuration tool suggests to add the following to your dev.exs which seems to be incorrect. I see that you’ve done the same in your project.
Just a heads up, that planetscale connection example has the configuration/connection code in a mix task where the castore dependency is available. Putting that code in dev.exs which gets called by config.exs during build time results in an error since dependencies are not available then.
To configure and connect during build time, try specifying the file path directly rather than through CAStore.file_path(). To use CAStore.file_path(), try adding the configuration/connection code into runtime.exs which is read after dependencies are available.