shotleybuilder

shotleybuilder

Gigalixir deploy fail: "module Config is not loaded and could not be found" "you appear to have cloned an empty repo"

Hi, I feel like I’m on the final leg of a marathon …

The app is really simple. Does one thing. Talks to Airtable, gets some json and wraps that into a .pdf. No db, no html. Only one thing I have to get right - where to put the Airtable authorisation token.
Production compiled and released and working at localhost:443. Everything for push to gigalixir seems correct, but it fails, so I’ve got something horribly wrong.

Here’s config.exs - I doubt it could be any shorter

config :app, AppWeb.Endpoint,
load_from_system_env: true
config :logger, level: :info
import_config “releases.exs”

I’m not sure about import_config "releases.exs. But I’ve renamed prod.secret.exs and that’s where the Airtable auth token now lives…

config :app,
airtable_api_key: “key”

And endpoint.ex now has the standard init function that seems to be well thumbed.

What piece of the jigsaw do I need to change? And could someone please write a clear tutorial for those like me who has just learned that “setting the port at build” means that I have to manually type and set it in the terminal :slight_smile:

Enumerating objects: 118, done.
Counting objects: 100% (118/118), done.
Delta compression using up to 8 threads
Compressing objects: 100% (110/110), done.
Writing objects: 100% (118/118), 29.48 KiB | 443.00 KiB/s, done.
Total 118 (delta 49), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (49/49), done.
remote: Starting deploy
remote: Preparing cache
remote: Compiling code and generating slug.
remote: Setting environment variables.
remote: * LIBCLUSTER_KUBERNETES_SELECTOR
remote: * LIBCLUSTER_KUBERNETES_NODE_BASENAME
remote: * APP_NAME
remote: * SECRET_KEY_BASE
remote: * PORT
remote: * SOURCE_VERSION
remote: Cloning into ‘studious-harmonious-redpoll’…
remote: warning: You appear to have cloned an empty repository.
remote: done.
remote: latest: Pulling from gigalixir-152404/build-18
remote: Digest: sha256:5fc09e182acefc099d28d2ec2ab75b3787a62d6798f01f001edc1e6e38785a1d
remote: Status: Image is up to date for us.gcr.io/gigalixir-152404/build-18:latest
remote: us.gcr.io/gigalixir-152404/build-18:latest
remote: -----> Detecting assets directory
remote: no package.json found
remote: Elixir+Releases app detected
remote: Detecting assets directory
remote: no package.json found
remote: =====> Downloading Buildpack: GitHub - HashNuke/heroku-buildpack-elixir: Heroku Buildpack for Elixir with nitro boost · GitHub
remote: =====> Detected Framework: Elixir
remote: -----> Will export the following config vars:
remote: APP_NAME
remote: LIBCLUSTER_KUBERNETES_NODE_BASENAME
remote: LIBCLUSTER_KUBERNETES_SELECTOR
remote: PORT
remote: SECRET_KEY_BASE
remote: SOURCE_VERSION
remote: * MIX_ENV=prod
remote: -----> Checking Erlang and Elixir versions
remote: WARNING: elixir_buildpack.config wasn’t found in the app
remote: Using default config from Elixir buildpack
remote: Will use the following versions:
remote: * Stack heroku-18
remote: * Erlang 20.1
remote: * Elixir 1.5.3
remote: -----> Using cached Erlang 20.1
remote: -----> Installing Erlang 20.1
remote:
remote: -----> Using cached Elixir v1.5.3
remote: -----> Installing Elixir v1.5.3
remote: -----> Installing Hex
remote: * creating /app/.mix/archives/hex-0.20.5
remote: -----> Installing rebar
remote: * creating /app/.mix/rebar
remote: * creating /app/.mix/rebar3
remote: -----> Fetching app dependencies with mix
remote: ** (Mix.Config.LoadError) could not load config config/config.exs
remote: ** (CompileError) config/config.exs:8: module Config is not loaded and could not be found
remote: (elixir) lib/code.ex:176: Code.eval_string/3
remote: (mix) lib/mix/config.ex:180: Mix.Config.read!/2
remote: Deploy aborted
To https://git.gigalixir.com/studious-harmonious-redpoll.git/
! [remote rejected] master → master (pre-receive hook declined)
error: failed to push some refs to ‘https://git.gigalixir.com/studious-harmonious-redpoll.git/

Marked As Solved

wojtekmach

wojtekmach

Hex Core Team

You can set environment variables on gigalixir with:

gigalixir config:set TOKEN=value

And then I’d read it in config/releases.exs with System.fetch_env!/1.

Also Liked

wojtekmach

wojtekmach

Hex Core Team

You are using Elixir v1.5 that doesn’t yet have the Config module, add elixir_buildpack.config and use v1.10 there. Also, you shouldn’t import releases.exs from prod.exs, these files have different purposes and are evaluated at different stages of deployment, prod.exs is for compile-time configuration and releases.exs is for runtime.

Finally, on Phoenix master there’s a new gigalixir deployment guide so definitely check it out!

shotleybuilder

shotleybuilder

Thanks again, that fills key missing piece of my understanding - I have to set the variable on the server!

Is that the only place I need to reference the variable in the config / set-up?
I don’t need to alter the init function in endpoint.exs. That’s my intuition and I’ll try that first at least.

Update
Yep, that’s all gone well. Just in case anyone else passes this way and is as confused as I was about set-up and config this is my releases.ex file

import Config
config :app_name, AppWeb.Endpoint,
server: true,
http: [port: {:system, “PORT”}],
secret_key_base: System.fetch_env!(“SECRET_KEY_BASE”),
airtable_key: System.fetch_env!(“AIRTABLE_KEY”)

and in the code

defp token() do
case System.get_env(“AIRTABLE_KEY”) do
nil → Application.fetch_env!(:sgre_hse_plan, :airtable_api_key)
key → key
end

But I think I can dispense with the Application variable defined in dev.secret.exs for dev because it’s a System variable on my laptop too.

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
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
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement