dotenv icon indicating copy to clipboard operation
dotenv copied to clipboard

Some of the environment variables are not loaded

Open indyarocks opened this issue 9 years ago • 4 comments

Strangely some of the environment variables on my development machine are not being loaded

Gemfile

group :development, :test do
  gem 'dotenv-rails'
end

Gemfile.lock

    dotenv (2.2.0)
    dotenv-rails (2.2.0)
      dotenv (= 2.2.0)
      railties (>= 3.2, < 5.1)

Paste your env using:

$ env | grep SUPERFEEDR_USER

$ 

.env file in Rails root directory

WEBHOOK_TUNNEL_URL="https://chandan.ngrok.io"
SUPERFEEDR_USER="user"
SUPERFEEDR_API_TOKEN='xxxxxxxxxxxxx'

secrets.yml

common: &common
  superfeedr_user: <%= ENV["SUPERFEEDR_USER"] %>
  superfeedr_api_token: <%= ENV["SUPERFEEDR_API_TOKEN"] %>

local: &local
  <<: *common
  redis_url: 'redis://localhost:6379'
  webhook_tunnel_url: <%= ENV["WEBHOOK_TUNNEL_URL"] %>

development:
  <<: *local
  secret_key_base: xxxxxxx

Expected behavior

{
  :superfeedr_user=>"user", 
  :superfeedr_api_token=>"xxxxxxxxxxxxx", 
  :redis_url=>"redis://localhost:6379",
  :webhook_tunnel_url=>"https://chandan.ngrok.io",
  :secret_key_base=>"xxxxxxx"
} 

Actual behavior

  1. Missing webhook_tunnel_url key
  2. superfeedr_user is nil
{
  :superfeedr_user=>nil, 
  :superfeedr_api_token=>"xxxxxxxxxxxxx", 
  :redis_url=>"redis://localhost:6379",
  :secret_key_base=>"xxxxxxx"
}

System configuration

dotenv version: 2.2.0

Rails version: 5.0.1

Ruby version: 2.3.3p222

UPDATE:

After restarting the system, I'm getting expected output. I'm wondering how did it pick up one environment variable and ignore another variable.

indyarocks avatar Jun 05 '17 22:06 indyarocks

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 12 '17 13:08 stale[bot]

I get this same issue quite often.

sn avatar Nov 13 '19 11:11 sn

happened the same to me, annoying. Could this be related to a specific dotenv loading issue? or maybe related to the underlying OS (MacOS 10.15.7 in my case)?

Update: Tried bin/spring stop as suggested here with no success

benoror avatar Nov 17 '20 23:11 benoror

!nostale

longhoangwkm avatar Jul 16 '21 17:07 longhoangwkm