Code Monkey home page Code Monkey logo

dotenv-hs's Introduction

Build StatusHackage

All Contributors

Dotenv files for Haskell

In most applications, configuration should be separated from code. While it usually works well to keep configuration in the environment, there are cases where you may want to store configuration in a file outside of version control.

"Dotenv" files have become popular for storing configuration, especially in development and test environments. In Ruby, Python and Javascript there are libraries to facilitate loading of configuration options from configuration files. This library loads configuration to environment variables for programs written in Haskell.

Install

In most cases you will just add dotenv to your cabal file. You can also install the library and executable by invoking stack install dotenv or you can download the dotenv binaries from our releases page.

Usage

Set configuration variables in a file following the format below:

S3_BUCKET=YOURS3BUCKET
SECRET_KEY=YOURSECRETKEYGOESHERE

Then, calling Dotenv.load from your Haskell program reads the above settings into the environment:

import Configuration.Dotenv (loadFile, defaultConfig)
loadFile defaultConfig

After calling Dotenv.load, you are able to read the values set in your environment using standard functions from System.Environment or System.Environment.Blank (base >= 4.11.0.0), such as getEnv.

If your version of base is < 4.11.0.0, then setting an environment variable value to a blank string will remove the variable from the environment entirely.

Variable substitution

In order to use compound env vars use the following syntax within your env vars ${your_env_var}. For instance:

DATABASE=postgres://${USER}@localhost/database

Running it on the CLI:

$ dotenv "echo $DATABASE"
postgres://myusername@localhost/database

Command substitution

In order to use the standard output of a command in your env vars use the following syntax $(your_command). For instance:

DATABASE=postgres://$(whoami)@localhost/database

Running it on the CLI:

$ dotenv "echo $DATABASE"
postgres://myusername@localhost/database

Surrond with quotes

If your value starts with a character that produces a parse error (e.g. {) . Surround your value with quotes. You can also escape the quotes if they're inside your value. For example:

JSON_SQ='{"a":[1,2,3], "b": "\'asdf\'"}'
JSON_DQ="{\"a\":[1,2,3], \"b\": \"'asdf'\"}"

Run it:

$ dotenv "echo $JSON_SQ" | jq .a
[
  1,
  2,
  3
]

Configuration

The first argument to loadFile specifies the configuration. You can use defaultConfig which parses the .env file in your current directory and doesn't override your envs. You can also define your own configuration with the Config type.

False in configOverride means Dotenv will respect already-defined variables, and True means Dotenv will overwrite already-defined variables.

In the configPath you can write a list of all the dotenv files where are envs defined (e.g [".env", ".tokens", ".public_keys"]).

In the configExamplePath you can write a list of all the dotenv example files where you can specify which envs must be defined until running a program (e.g [".env.example", ".tokens.example", ".public_keys.example"]). If you don't need this functionality you can set configExamplePath to an empty list.

A False in the configVerbose means that Dotenv will not print any message when loading the envs. A True means that Dotenv will print a message when a variable is loaded.

When configDryRyn is True, Dotenv will print out the loaded environment variables without executing the program.

A False on allowDuplicates means that Dotenv will not allow duplicate keys, and instead it will throw an error. A True means that Dotenv will allow duplicate keys, and it will use the last one defined in the file (default behavior).

Advanced Dotenv File Syntax

You can add comments to your Dotenv file, on separate lines or after values. Values can be wrapped in single or double quotes. Multi-line values can be specified by wrapping the value in double-quotes, and using the "\n" character to represent newlines.

The spec file is the best place to understand the nuances of Dotenv file parsing.

Command-Line Usage

You can call dotenv from the command line in order to load settings from one or more dotenv file before invoking an executable:

$ dotenv -f mydotenvfile myprogram

The -f flag is optional, by default it looks for the .env file in the current working directory.

$ dotenv myprogram

Additionally, you can pass arguments and flags to the program passed to Dotenv:

$ dotenv -f mydotenvfile myprogram -- --myflag myargument

or:

$ dotenv -f mydotenvfile "myprogram --myflag myargument"

Also, you can use a --example flag to use dotenv-safe functionality so that you can have a list of strict envs that should be defined in the environment or in your dotenv files before the execution of your program. For instance:

$ cat .env.example
DOTENV=
FOO=
BAR=

$ cat .env
DOTENV=123

$ echo $FOO
123

This will fail:

$ dotenv -f .env --example .env.example "myprogram --myflag myargument"
> dotenv: The following variables are present in .env.example, but not set in the current environment, or .env: BAR

This will succeed:

$ export BAR=123 # Or you can do something like: "echo 'BAR=123' >> .env"
$ dotenv -f .env --example .env.example "myprogram --myflag myargument"

Hint: The env program in most Unix-like environments prints out the current environment settings. By invoking the program env in place of myprogram above you can see what the environment will look like after evaluating multiple Dotenv files.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Cristhian Motoche
Cristhian Motoche

💻
Justin S. Leitgeb
Justin S. Leitgeb

💻
Mark Karpov
Mark Karpov

💻
Juan Paucar
Juan Paucar

💻
Juan Pedro Villa Isaza
Juan Pedro Villa Isaza

💻
Daisuke Fujimura
Daisuke Fujimura

💻
William R. Arellano
William R. Arellano

💻
Diego Balseiro
Diego Balseiro

💻
Stefani Castellanos
Stefani Castellanos

💻
Götz
Götz

💻
Oleg Grenrus
Oleg Grenrus

💻
Sebastián Estrella
Sebastián Estrella

💻
Habib Alamin
Habib Alamin

💻
Franz Guzmán
Franz Guzmán

💻
Pat Brisbin
Pat Brisbin

💻
Alexander Goussas
Alexander Goussas

💻
Alexis Crespo
Alexis Crespo

💻
Andres Perez
Andres Perez

💻
Esteban Ibarra
Esteban Ibarra

💻
Fernanda Andrade
Fernanda Andrade

💻
Jorge Guerra Landázuri
Jorge Guerra Landázuri

💻
MATSUBARA Nobutada
MATSUBARA Nobutada

💻
Wojtek Mach
Wojtek Mach

💻
DanRCM
DanRCM

💻
Juan F. Carrillo
Juan F. Carrillo

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT, see the LICENSE file.

Contributing

Do you want to contribute to this project? Please take a look at our contributing guideline to know how you can help us build it.


Stack Builders Check out our libraries | Join our team

dotenv-hs's People

Contributors

alexisbcc avatar allcontributors[bot] avatar aloussase avatar anddriex avatar cptrodolfox avatar cristhianmotoche avatar danrcm avatar davidmazarro avatar dbalseiro avatar fefi95 avatar flandrade avatar franzgb avatar fujimura avatar goetzc avatar habibalamin avatar ibarrae avatar jagl257 avatar jpvillaisaza avatar jsl avatar juanfcarrillo avatar juanpaucar avatar matsubara0507 avatar mrkkrp avatar pbrisbin avatar phadej avatar sestrella avatar tristancacqueray avatar wojtekmach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotenv-hs's Issues

Refactor `dotenv-safe` for "type checking"

Currently, the loadSafeFile from the 0.5.2.0 release has a hard coded parsers.. This is really rigid and not really a type check only a format validation.

I believe we can improve this by injecting a Map String (Text -> Bool) as a parameter for parseEnvAs and then lookup for an specific validator (Text -> Bool) in the Map. Our interface for loadSafeFile would also get a Map String (Text -> Bool) so the users can extend the format validations and add their own.

Also, we have a dotenv-cli which is language agnostic, so the users won't be able to provide the Map String (Text -> Bool). For this case, I propose creating an extra package with common validators (Integers, Text, Email, Filepath, and so on). When the users require a new format validator we would only change that library.

WDYT? Please, let me know your concerns and I'll be working on this huge change.

.envs as Ciphertext

Motivation

Setting things like passwords, key phrases, tokens, and so on is very common in .envs. As well as sharing .envs, specially when someone new enters into a project. Of course, having a security culture won't allow that this kind of things happen. However, we can make sure that they don't happen by adding .envs as cipher text.

Description

Given a .env and a password we can generate a .env.cipher that will have the .env vars as ciphertext.
image

In order to load this .env vars, we could set a flag in the command line. Internally it will load the env vars in the environment.
image

It will be similar to the way ansible vault saves secret files.

@jsl @juanpaucar @sestrella
This is just an idea that came to my mind in a dream (just kidding). I'd like to know what do you think. Is it worth to work on it? Or add it?

dotenv test failure on stackage

We are seeing this failure and have listed the package under expected-test-failures:

Configuration.Dotenv.Parse
  parse
    parses unquoted values
    parses values with spaces around equal signs
    parses double-quoted values
    parses single-quoted values
    parses escaped double quotes
    supports CRLF line breaks
    parses empty values
    parses unquoted interpolated values
    parses double-quoted interpolated values
    parses single-quoted interpolated values as literals
    does not parse if line format is incorrect
    expands newlines in quoted strings
    does not parse variables with hyphens in the name
    parses variables with "_" in the name
    parses variables with digits after the first character
    allows vertical spaces after a quoted variable
    does not parse variable names beginning with a digit
    strips unquoted values
    ignores empty lines
    ignores inline comments after unquoted arguments
    ignores inline comments after quoted arguments
    allows "#" in quoted values
    ignores comment lines
    doesn't allow more configuration options after a quoted value
Configuration.Dotenv.Text
  parseFile
    returns variables from a file without changing the environment
    recognizes unicode characters
Configuration.Dotenv
  load
    loads the given list of configuration options to the environment
    preserves existing settings when overload is false
    overrides existing settings when overload is true
  loadFile
    loads the configuration options to the environment from a file
    respects predefined settings when overload is false
    overrides predefined settings when overload is true
    when the .env.example is present
      when the needed env vars are missing
        should fail with an error call FAILED [1]
      when the needed env vars are not missing
        should succeed when loading all of the needed env vars FAILED [2]
  parseFile
    returns variables from a file without changing the environment
    recognizes unicode characters
    recognises environment variables
    recognises previous variables
  onMissingFile
    when target file is present
      loading works as usual
    when target file is missing
      executes supplied handler instead

Failures:

  spec/Configuration/DotenvSpec.hs:82:
  1) Configuration.Dotenv.loadFile, when the .env.example is present, when the needed env vars are missing, should fail with an error call
       uncaught exception: IOException of type NoSuchThing (spec/fixtures/.dotenv.example: openFile: does not exist (No such file or directory))

  spec/Configuration/DotenvSpec.hs:86:
  2) Configuration.Dotenv.loadFile, when the .env.example is present, when the needed env vars are not missing, should succeed when loading all of the needed env vars
       uncaught exception: IOException of type NoSuchThing (spec/fixtures/.dotenv.example: openFile: does not exist (No such file or directory))

Randomized with seed 500499175

Add support for GHC 9.x

GHC 9.0.1 was released a few months ago and, as the convention is to support the last 3 major releases, the library should support the latest version.

Allow empty .env file

Is there any particular reason that the .env file must not be empty? It fails to parse because it currently requires at least one variable be set.

Failed to read fileParseError {
errorPos = SourcePos {
    sourceName = ".env",
    sourceLine = Pos 2,
    sourceColumn = Pos 1
} :| [],
errorUnexpected = fromList [EndOfInput],
errorExpected = fromList [Label ('v' :| "ariable name")],
errorCustom = fromList []
}

Ambigious occurrence 'many'

I'm trying to compile dotenv-0.5.2.1 (a dependency of Opaleye). I get the error

src/Configuration/Dotenv/Parse.hs:45:39: error:
    Ambiguous occurrence ‘many’
    It could refer to either ‘Control.Applicative.many’,
                             imported from ‘Control.Applicative’ at src/Configuration/Dotenv/Parse.hs:21:1-36
                             (and originally defined in ‘GHC.Base’)
                          or ‘Text.Megaparsec.many’,
                             imported from ‘Text.Megaparsec’ at src/Configuration/Dotenv/Parse.hs:24:1-32
                             (and originally defined in ‘parser-combinators-0.4.0:Control.Monad.Combinators’)

Indeed Configuration.Dotenv.Parse imports both Control.Applicative and Text.Megaparsec. Text.Megaparsec rexports Control.Monad.Combinators which indeed defines its own many since 0.4.0. (I don't know why). Thus the name many is ambiguous inside Configuration.Dotenv.Parse.

I'm a bit puzzled since it's hard to understand why I seem to be the first person to notice this.

Verbose option (for CLI and command)

It could be useful to get some insights from dotenv before loading the environment variables. At the moment, it doesn't give any information about the loaded envs:

$ dotenv 'echo $FOO'
foo-bar-baz

I'd like to have an option that enables some kind of logging like this:

$ dotenv 'echo $FOO' --verbose
[INFO]: Load env 'FOO' with value 'foo-bar-baz'
[WARN]: Env 'BAR' is duplicated on the file
[INFO]: Load env 'BAR' with value 'Second value for BAR'
[INFO]: Overriding env 'TAR' with value from environment 'TAR VALUE FROM ENV'
foo-bar-baz

Tests not running on Travis for GHC 7.6.3

We're getting the following error in the build output on Travis. It appears that the program is building successfully, but the test suite is not running. Because of this, I'm not entirely sure if this package works on GHC 7.6. We get the following error in the build log:

cabal: Error: Could not find test program
"dist/build/dotenv-test/dotenv-test". Did you build the package first?

We may remove support for GHC 7.6 entirely in the future, since it's already pretty outdated. Leaving this issue here for the record until such a decision is made.

Make a "safe" wrapper for loading variables

Following the example of dotenv-safe, we can be more helpful when loading environment data. We may be able to define types of variables to import, to specify variables that need to be specified, whether or not they need to have non-null contents, and perhaps other basic types.

One possible implementation that I discussed with @sestrella was that we may be able to allow the user to specify a template, perhaps in dotEnv format. The left hand side would specify variable names that could occur, and the right hand side may point to a type that could contain a parser defined in Megaparsec that is defined internally in dotenv. We should be able to specify whether or not a variable should be mentioned at all in the input file, and if it is mentioned, can it be null? Otherwise, should it be an integer, alphanumeric string, etc.

Don't allow more than one definition in the Scheme for the same env

Currently, the user can define multiple configurations for the same env. However, the system has the following behaviour: it matches the types with the value and then type checks for all the types specified.

For instance,

- name: PORT
  type: integer
  required: true
- name: PORT
  type: bool
  required: true

PORT will be evaluated as a bool and integer, then dotenv will always fail.
Although, it would be better to display an error message.

Allow megaparsec 5.0.0

See commercialhaskell/stackage#1446.

To allow megaparsec 5.0.0, we have to fix the following error:

.../dotenv-hs/spec/Configuration/Dotenv/ParseSpec.hs:93:33:
    Expecting two more arguments to ‘ParseError’
    The first argument of ‘Either’ should have kind ‘*’,
      but ‘ParseError’ has kind ‘* -> * -> *’
    In the type signature for ‘parseConfig’:
      parseConfig :: String -> Either ParseError [(String, String)]

Drop support for GHC 7.6.3

I found interesting that this library has backward compatibility with GHC 7.6.3.

We faced a compilation issue on CI with this GHC 7.6.3. To track down a bug we had to add more machinery, concretely a Docker container to reproduce the problem in isolation. If we drop the support for this version, we can depend only on stack to seamlessly change the GHC version.

I'd like to know if there any reason that justifies supporting GHC 7.6.3?

/cc @sestrella, @jsl, @mrkkrp, @CristhianMotoche

dotenv picks the first instead of the last value

See:

$ cat > my_script.hs
#!/bin/bash
echo $FOO
echo $GOO
^D
$ cat > .env
#!/bin/sh
FOO=first
GOO=second
FOO=third
^D
$ dotenv -f.env ./my_script.hs 
first
second

I would expect for the result to be actually:

third
second

Now, that may be just a personal preference... However I justify it as it is less surprising for dotenv files to behave like shell scripts and have a preference for the last set value:

$ source .env
$ echo $FOO
third
$ echo $GOO
second

There should be a way to ignore non-existing files

It's quite common to ignore env file if it does not exist. For example the current client I'm working for has the following in his projects:

loadEnv :: IO ()
loadEnv = do
    pwd <- getCurrentDirectory
    let envFile = pwd </> "env"
    doesFileExist envFile >>= flip when (Dotenv.loadFile False envFile)

It would be better to address this out-of-box. Note that the right approach here would be to catch IO exceptions and either ignore them or even allow user to run his/her own action (may be useful for printing something like “Could not find env file, skipping…”), because checking if file exists before attempting loading it may be a subject to race conditions.

Expand existing variables

I would like to use a .env file like the following:

FOO=${HOME}/.foo

After loading the file, FOO should be /home/jpvi/.foo or something like that.

@jsl Let me know if this makes sense and I can take a look.

Handle exceptions

I think we are using many time error in the application. However, I don't think that is the correct way to handle some errors. Perhaps, we should start using an specific exception type.

--allow-empty-values option will break Windows compatibility

The documentation for System.Enviroment#setEnv says:

On Windows setting an environment variable to the empty string removes that environment variable from the environment. For the sake of compatibility, we adopt that behavior. In particular

setEnv name ""

has the same effect as

unsetEnv name

It also says that if we want to support empty environment variables, we have to use System.Posix.Env.setEnv. The problem with using this library is that will break the compatibility of dotenv-hs with Windows OS.

Should we care about Windows support?

/cc: @sestrella, @jsl, @mrkkrp, @CristhianMotoche

dotenv-hs failing to build in Nix

This happens because in the Build process the tests are run, but the file .dotenv.safe is not included in the cabal. Therefore, two test fail.

Command parsing is almost unusably strict

👋 Hello there from one dotenv library author to another :)

I've been looking to covert away from my project to yours because you support the $( ) syntax, and I thought that would be a great way to read secrets from AWS SSM during development.

I tried,

ASANA_API_KEY=$(aws --profile freckle-dev ssm get-parameter \
  --name /dev/asana-api-access-key \
  --query 'Parameter.Value' \
  --output text)

But got,

bugsnag-update: .env:2:20:
  |
2 | ASANA_API_KEY=$(aws --profile freckle-dev ssm get-parameter \
  |                    ^
unexpected space
expecting ')' or alphanumeric character

OK, that's fair. Maybe you don't want to get into shell words parsing. How about I stash this in a local script and call it as a single word:

ASANA_API_KEY=$(bin/get-asana-api-key)
bugsnag-update: .env:2:20:
  |
2 | ASANA_API_KEY=$(bin/get-asana-api-key)
  |                    ^
unexpected '/'
expecting ')' or alphanumeric character

Alright... Maybe you want to avoid some kind exploit by only allowing commands on $PATH?

No worries,

ASANA_API_KEY=$(get-asana-api-key)
PATH=./bin:$PATH stack run
bugsnag-update: .env:2:20:
  |
2 | ASANA_API_KEY=$(get-asana-api-key)
  |                    ^
unexpected '-'
expecting ')' or alphanumeric character

I give up, and here I am :)

So my question: are these limitations intentional (e.g. for security reasons), or would you accept a PR to relax them?

Ideally, I think you'd accept everything until the final (balanced) ), break it up with a library like shellwords, and then exec it. I think this would be safe, provided you always exec a command and arguments, and never involve a shell.

At a minimum, I'd like to see /, -, ., and _ accepted.

Create releases with pre-compiled binaries

dotenv is meant to be used as an executable, therefore, in order to simplify the installation process, we could provide pre-compiled binaries so end-users could just download and copy the binary instead of installing the whole package via stack or cabal.

Documentation

References

Support for GHC 8.6

TODO:

  • Make sure dotenv works with GHC 8.6
  • Add the version 8.6 to the .travis.yml file

Drop support for GHC 7.10.3

GHC 7.10.3 is more than 5 years old so could drop the support for this version, this would remove a CI job, potentially some code via CPP and update some upper bounds for the constraints.

Reorganize components

I noticed that the executable and test suite components listed in the Cabal file are not using the library component: the executable has all library modules as other modules, and the test suite has src in hs-source-dirs and all library modules as other modules.

We can split the library and executable components, and make both the executable and the test suite have the library as a build dependency.

Is depending on 'base-compat' so necessary?

For such a lightweight package, do we really need to depend on base-compat. It looks like minimal to no CPP would make it work just as well. I think CPP is the common practice in Haskell nowadays, while compat packages are not widely used as library dependencies. I would be in favor of removing base-compat dependency. I'll see how much of a change this actually is.

Remove extra dependencies from stack.yaml

There are three extra dependencies in stack.yaml: fail-4.9.0.0, megaparsec-4.4.0, and semigroups-0.18.1. We can remove fail and semigroups from this file. I'm not sure about megaparsec -- it depends on whether the library builds with megaparsec-4.3.0 or not.

Which versions of GHC should we support

Right now the application is tested with GHC 7.4.2, 7.6.3, 7.8.4, and 7.10.1. Should we still worrying about GHC 7.4.2 and 7.6.3? If so, we could continue using cabal in travis, otherwise we could switch to stack, and also we could use hspec-discover instead of one file that calls the other test modules.

This issue should be consider in the other OS projects.

Move from Travis CI to GH actions

We want to move from Travis CI to GH actions due to a change in its policies. The configuration for GH Actions should cover the same that Travis does, that is:

  • Common check on Linux. Build and tests for versions: 8.10, 8.8, 8.6, 8.4, 8.2, 8.0, 7.10
  • Common check on OSX. Build and tests for versions: 8.10
  • Bundle the project and create a release in GH based on a given tag.

Split library features into different projects

Hello everyone!

Currently, our library has a couple of features that I think we should put into different projects that extend the basic dotenv:

  1. configExamplePath in configExamplePath, which gives dotenv the ability to check for another .env file before loading the env variables.
  2. loadSafeFile function, which validates the env value with the "type" in a scheme.yml file to match before loading the env variables.

Motivation:

  1. Reduce the cyclomatic complexity added due to additional checks
  2. Keep the required dependencies. Currently, we're using yaml which is kind of heavy for the loadSafeFile functionality.
  3. It generates heavy binary files. Check out the ones here: https://github.com/stackbuilders/dotenv-hs/releases/tag/v0.8.0.4 The dotenv binary file is around 14 MB

Benefits:

  1. Each library will focus on their own features
  2. Users will decide which features from dotenv works best for them

Caveats:

  1. This will be a major change that will break the current dotenv interface, so users will have to look for the libraries they want to add and update their dependencies
  2. We'll have to maintain multiple libraries.

Please, let me know your thoughts on this proposal @sestrella @juanpaucar @jsl

Fix static file generation on CI

I noticed that the last release included the dotenv binary but the file isn't static:

$ tar xf dotenv-linux-x86_64-static.tar.gz
$ file dotenv
dotenv: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=d992f00e7630549de68fd7390d5b4db81aefd25d, with debug_info, not stripped

I suggest to take the hapistrano draft as an example. If the issue can be fixed in a different way, that's okay.

Add --version to the CLI tool

Currently, this is the output of our dotenv CLI:

$ dotenv --help
dotenv - loads options from dotenv files

Usage: dotenv (-f|--dotenv DOTENV) [--example DOTENV_EXAMPLE] [-o|--overload]
              PROGRAM [ARG]
  Runs PROGRAM after loading options from FILE

Available options:
  -h,--help                Show this help text
  -f,--dotenv DOTENV       File to read for environmental variables
  --example DOTENV_EXAMPLE File to read for needed environmental variables
  -o,--overload            Specify this flag to override existing variables

We should add --version flag.

List, Add, Set, Delete env vars from CLI

Motivation

Usually, when a user wants to set/add/list/delete an env var. He/She needs to open the file and then modify it. I think it could possibly be useful to directly from dotenv CLI to set/add/list/delete the env vars in the .env file.
For instance:

$ dotenv list
Envs:
- FOO=bar
- BAR=baz

$ dotenv add "BAZ" "foo"
Envs:
- FOO=bar
- BAR=baz
- BAZ=foo

$ dotenv set "BAZ" "foobar"
Envs:
- FOO=bar
- BAR=baz
- BAZ=foobar

$ dotenv del "BAZ"
Envs:
- FOO=bar
- BAR=baz

Does this make sense? Or do you think it could be useful?
Please, let me know your concerns @jsl @juanpaucar @sestrella

Blank environment variables aren't loaded (even in a POSIX environment)

I think being able to have blank environment variables is useful, and I kind of resent the fact that Windows is acting as a lowest common denominator here (no offence to the team here, I can understand why you made the decision).

Some conversation occurred on #7 and #44.


For those coming to this issue after a lot of conversation, this bug is being tracked upstream, as it's a bug with GHC itself. I'll update this comment to keep track of the status of the bug.

Ambigious occurrence 'many'

I'm trying to compile dotenv-0.5.2.1 (a dependency of Opaleye). I get the error

src/Configuration/Dotenv/Parse.hs:45:39: error:
    Ambiguous occurrence ‘many’
    It could refer to either ‘Control.Applicative.many’,
                             imported from ‘Control.Applicative’ at src/Configuration/Dotenv/Parse.hs:21:1-36
                             (and originally defined in ‘GHC.Base’)
                          or ‘Text.Megaparsec.many’,
                             imported from ‘Text.Megaparsec’ at src/Configuration/Dotenv/Parse.hs:24:1-32
                             (and originally defined in ‘parser-combinators-0.4.0:Control.Monad.Combinators’)

Indeed Configuration.Dotenv.Parse imports Control.Applicative and Text.Megaparsec. Text.Megaparsec rexports [`

Drop "Type Checking Envs" support

yaml is mostly used to parse the schema.yml which is used to type-check environment variables at runtime, however, all functions defined at System.Environment read values as String therefore values stored in environment variables need to be parsed again from a String value which defeats the purpose of declaring a schema file in the first place. On the other hand, yaml is a big dependency, so getting rid of it as a dependency is going to reduce the compilation time.

Most dotenv ports have a single responsibility "read env variables from a file" therefore in most cases libraries like this one don't even have dependencies and just export a single function:

I think we should consider getting rid of "Type checking envs" and try to reduce the number of dependencies in the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.