Local and remote environment

Hi!
I create the .env.development.remote file with my RDS configuration.
But when I run JETS_ENV_REMOTE=1 jets console, I access my local setup.
The same for migrations, seeds, etc. It always access my local environment instead of my remote.
Any hint?

Unsure. Here’s a guess in the dark. Wondering if the DATABASE_URL variable is possibly misspelled in the .env.development.remote?

After you start the console with JETS_ENV_REMOTE=1, try seeing what DATABASE_URL is set to. Example:

$ cat .env.development ; echo
# Example .env.development, meant to be updated.
ENV_DEVELOPMENT_KEY=example1
# DATABASE_URL=mysql2://dbuser:dbpass@localhost/demo_development?pool=5
$ cat .env.development.remote ; echo                
DATABASE_URL=mysql2://user:pass@fake.testing.us-west-2.rds.amazonaws.com/dbname?pool=5

$ JETS_ENV_REMOTE=1 jets console
Jets booting up in development mode!
>> puts ENV['DATABASE_URL']
mysql2://user:pass@fake.testing.us-west-2.rds.amazonaws.com/dbname?pool=5
=> nil
>>

Here is my console results:

➜ gamemob git:(master) ✗ cat .env.development ; echo
ENV_DEVELOPMENT_KEY=example1
DATABASE_URL=mysql2://root:admin@localhost/gamemob_development?pool=5

➜ gamemob git:(master) ✗ cat .env.development.remote ; echo
DATABASE_URL=mysql2://gamemob:########@gamemob.czrmacc47cp9.sa-east-1.rds.amazonaws.com/gamemob?pool=5

➜ gamemob git:(master) ✗ JETS_ENV_REMOTE=1 jets console
Jets booting up in development mode!
irb(main):001:0> puts ENV[‘DATABASE_URL’]
mysql2://root:admin@localhost/gamemob_development?pool=5
=> nil

Jets uses the dotenv gem to load .env files. Unsure why it’s not working in your case at the moment.

This might be worth a shot. Here’s a stripped down file to test dotenv loading.

dotenv_test.rb:

require 'dotenv'
Dotenv.load('.env.development', '.env.development.remote')
puts ENV['DATABASE_URL']

Create a file the dotenv_test.rb in the same folder with the env.development and env.development.remote files. Then try testing it:

$ cat .env.development
# Example .env.development, meant to be updated.
ENV_DEVELOPMENT_KEY=example1
# DATABASE_URL=mysql2://dbuser:dbpass@localhost/demo_development?pool=5

$ cat .env.development.remote                                                               
DATABASE_URL=mysql2://user:pass@fake.testing.us-west-2.rds.amazonaws.com/dbname?pool=5
$ cat dotenv_test.rb 
require 'dotenv'
Dotenv.load('.env.development', '.env.development.remote')
puts ENV['DATABASE_URL']
$ ruby dotenv_test.rb 
mysql2://user:pass@fake.testing.us-west-2.rds.amazonaws.com/dbname?pool=5
$ 

Another shot-in-the-dark guess. Wondering if it’s shell related. Can you try on a plain bash shell? Maybe comment out all your ~/.profile, .bash_profile, etc settings. See if that makes a difference. The test script might help.

Oh I see! The ordering of the loading is not right. .env.development takes higher precedence than .env.development.remote. Okay, will dig into this.

Fixed in https://github.com/tongueroo/jets/pull/171 released in v1.6.4

Thanks! Everything seem to be ok ow!