Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read env variables with fireplace #404

Open
himat opened this issue Aug 9, 2022 · 0 comments
Open

How to read env variables with fireplace #404

himat opened this issue Aug 9, 2022 · 0 comments

Comments

@himat
Copy link

himat commented Aug 9, 2022

I have this in a function in my clj file

  (def access-token (env :api-access-token))

When I try to use fireplace to run a function that calls that line, I get this error in the fireplace vim pane

Execution error (ClassCastException) at ....
class mount.core.DerefableState cannot be cast to class clojure.lang.IFn (mount.core.DerefableState is in unnamed module
 of loader clojure.lang.DynamicClassLoader @5d235104; clojure.lang.IFn is in unnamed module of loader 'app')
Clojure: class java.lang.ClassCastException

I assume this is because fireplace hasn't (can't?) load the env file.

Here's the env definition. It just reads a value defined in my dev-config.edn file.

(ns super-browser-tool.config
  (:require
    [cprop.core :refer [load-config]]
    [cprop.source :as source]
    [mount.core :refer [args defstate]]))

(defstate env
  :start
  (load-config
    :merge
    [(args)
     (source/from-system-props)
     (source/from-env)]))

How do people normally deal with this? I can temporarily hardcode the value in the code as (def access-token "some string") but that's messy and I have to remember to undo that when I commit my code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant