Home > Net >  Rails Rake ENV variable alwaays empty
Rails Rake ENV variable alwaays empty

Time:11-18

I have trouble using ENV variable in the database.yml and with rake.

The config file database.yml

development:
  <<: *default
  url: "mysql://user:pass@<%=ENV['DB_HOST'] %>

Launching the command

 jruby -S bundle exec rake assets:clean

with

URI::InvalidURIError: the scheme mysql does not accept registry part: user:pass@ (or bad hostname?)

Seems that DB_HOST is empty when rake runs, but it's definitively set in the system.

I'm using JRuby 6.3.1. When launching the project in IntelliJ it works perfect.

CodePudding user response:

When not using the key "url" in database.yml it's working for me.

development:
  <<: *default
  database: <%=ENV['DB_NAME'] %>
  host: <%=ENV['DB_HOST'] %>
  • Related