mxst

mxst

How to add a config file to a livebook?

Hello everyone,

I’m trying to add a secret to my livebook. ( I need to have some credentials but I don’t want to save them in the livebook directy)

I tried the following in the ‘Notebook dependencies and setup’

Mix.install([
  {:req, "~> 0.2.1"},
  {:jason, "~> 1.3"},
  {:kino, "~> 0.5.0"}
],
config_path: "<full_path>/config/config.exs"
)

but if I now try to access the config via Application.get_all_env(:apaleo_api) the return is empty.

config.exs:

import Config

config :apaleo_api, :basic_auth,
  username: "username",
  password: "password"

Maybe someone can tell me what I am doing wrong …

Most Liked

mxst

mxst

I think I found a solution with:

Mix.install([
  {:req, "~> 0.2.1"},
  {:jason, "~> 1.3"},
  {:kino, "~> 0.5.0"}
],
config: Config.Reader.read!("#{__DIR__}/config/config.exs")
)
w0rd-driven

w0rd-driven

That’s the preferred approach according to the docs: Mix — Mix v1.14.0. There’s also a :config_path option as of the newest Elixir 1.14 that loads the file for you as well as a paired runtime.exs if it’s in the same directory.

Where Next?

Popular in Questions Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement