Comments (15)
I had a similar issue where my password started with "#", turns out that commented out the password string and I kept on getting "no password supplied"...
from dotenv.
Also, I should note that this is Rails 3.2.11, and I was using dotenv successfully in this application previously, but only in config/initializers/*.rb.
from dotenv.
Disregard, had 0.4.0 locked, and updating to 0.5.0 fixed 😓
from dotenv.
What version of dotenv are you using? I just pushed a new version last week that loads earlier in the bootstrap process, which should fix this issue.
from dotenv.
haha, posted at the same time :P
Glad it's working!
from dotenv.
This doesn't seem to be working with Ruby 2.0.0-p0 and Rails 4.0.0.rc2. Using the same <%= raise ENV.inspect %>
trick, none of my variables in my .env file show up.
from dotenv.
I have the same problem with dotenv 0.9.0 and rails 3.2.14. Is it supposed to work with these versions ?
Thanks !
from dotenv.
I'm quite certain it works for those versions. Can you post more details on what your .env
file looks like and the behavior you're seeing?
from dotenv.
Of course :
.env
:
RAILS_ENV="staging"
MYSQL_HOST="xxxx"
MYSQL_DATABASE="dddd"
MYSQL_USERNAME="uuuuu"
MYSQL_PASSWORD="ppppp"
config/database.yml
:
<%= ENV['RAILS_ENV'] %>:
adapter: mysql2
host: <%= ENV['MYSQL_HOST'] %>
database: <%= ENV['MYSQL_DATABASE'] %>
username: <%= ENV['MYSQL_USERNAME'] %>
password: <%= ENV['MYSQL_PASSWORD'] %>
encoding: utf8
pool: 200
When doing a bundle exec rails console staging
, I get a MySQL error (it cannot connect with default params).
According to the README, as I'm using Rails, I'm not supposed to do that anywhere :
require 'dotenv'
Dotenv.load
Right ?
from dotenv.
Note : it fails in staging but not in development. It's probably a mistake on my side.
from dotenv.
Nevermind, it works perfectly fine. There was a typo in my .env so the staging connection details where not loaded.
from dotenv.
👍
from dotenv.
It does not work for me (Rails 2.3.17 app).
The only way to have .env
loaded in time for the database, is to add at the end of config/preinitializer.rb
:
# ... after Bundler magic
require 'dotenv'
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
Dotenv.load ".env.#{ENV["RAILS_ENV"]}", '.env'
from dotenv.
RAILS_ENV
/RACKE_ENV
must be specified outside of dotenv. It's a chicken and egg problem that is impossible for dotenv to solve.
from dotenv.
Even with RAILS_ENV
already in env, the Railtie version of dotenv is not loading sooner than the database.yml
parsing. The point (sorry for not being clear enough) is, what is the correct step to load the env files in rails 2.3, so database.yml
has enough data?
from dotenv.
Related Issues (20)
- Environment loading change in 2.7.6 is wrong HOT 7
- [dotenv-rails] .env.local should be loaded in test environments HOT 20
- Spring::MissingApplication HOT 1
- [would be great if] dotenv supported "source" from other envs HOT 1
- `Dotenv::Railtie.overload` violates policy about `env` files priority HOT 3
- Refresh ENV during runtime HOT 2
- Only subset of shell functionality is supported HOT 2
- Ask somthing in docs HOT 1
- Could not find dotenv-2.7.6 in any of the sources HOT 1
- Just HOT 1
- Special characters are being escaped from the value of the environment variables HOT 3
- dotenv-rails loads dev environment when running system tests with Rails 7 HOT 5
- `Dotenv.load` call causes Rails app to be loaded twice HOT 2
- Not specifying required ruby version on Gemfile causes my bundler with ruby 2.5.x pull dotenv 2.8.0 HOT 6
- template is not created in working directory HOT 2
- Question on Removal of ### What other .env* files can I use? FAQ HOT 1
- README should explicitly call out the gem needed is `dotenv-rails` HOT 4
- environment specific env not loaded when using require: 'dotenv/load' HOT 1
- Rails < v6.1: LocalJumpError in tagged logging HOT 2
- autorestore: can't modify frozen Hash HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotenv.