Skip to content

[BUG] Use .env.local and .env.test #23

Open
@fbuys

Description

@fbuys

IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.

Before we start...:

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Expected behavior:

Create a Rails app using this template.
Add ENV to the .env.sample file.
And be able to run the app with foreman or docker.

Actual behavior:

Running a newly created app (based on this template) does not run in docker or foreman.

Steps to reproduce:

  1. I create a rails app using this template.
  2. I add a few ENV entries into the .env.sample file.
  3. Then I run the setup script.
  4. Then I try to run the app in docker or with foreman.
  5. But the app does fails to run.

Context and environment:

From this issue: fastruby/dotenv_validator#46
And this PR: fastruby/dotenv_validator#51

The issue was that foreman and docker-compose would automatically parse any .env files present in the project and populate the environment variables before the Rails app could run, but with no treatment of comments and blank spaces. As a result, when dotenv parsed the file, since the variables would already be populated by docker, it would not change them and, because of this, dotenv_validator validated environment variables that included any blank spaces or comments present in the .env files.

This caused dotenv_validator to fail even for environment variables that should pass.

More details can be found in the changes to the README of dotenv_validator here. After this change we can now successfully run the app in docker and locally with foreman without dotenv_validator failing.

We want to make these changes:
Add this to .gitignore

.env.local
.env.test

Add to bin/setup

unless File.exist?(".env.local")
  cp ".env.sample", ".env.local"
  system! "ln -s .env.local .env.test"
end

I will abide by the [code of conduct] (CODE_OF_CONDUCT.md)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions