re: dev.to open source help/discussion thread (v0) VIEW POST

FULL DISCUSSION
 

I'm getting the following error when running bin/setup:

== Preparing database ==
rails aborted!
The following environment variables should be set: ALGOLIASEARCH_API_KEY, ALGOLIASEARCH_APPLICATION_ID, ALGOLIASEARCH_SEARCH_ONLY_KEY.
/usr/local/lib/ruby/gems/2.5.0/gems/envied-0.9.1/lib/envied.rb:38:in `error_on_missing_variables!'
/usr/local/lib/ruby/gems/2.5.0/gems/envied-0.9.1/lib/envied.rb:19:in `require'
/Users/Stephanie/Documents/Github/dev.to/config/application.rb:12:in `<top (required)>'
/Users/Stephanie/Documents/Github/dev.to/Rakefile:4:in `require'
/Users/Stephanie/Documents/Github/dev.to/Rakefile:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.5.0/gems/railties-5.1.6/lib/rails/commands/rake/rake_command.rb:20:in `block in perform'
/usr/local/lib/ruby/gems/2.5.0/gems/railties-5.1.6/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/usr/local/lib/ruby/gems/2.5.0/gems/railties-5.1.6/lib/rails/command.rb:46:in `invoke'
/usr/local/lib/ruby/gems/2.5.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>'
/Users/Stephanie/Documents/Github/dev.to/bin/rails:9:in `require'
/Users/Stephanie/Documents/Github/dev.to/bin/rails:9:in `<top (required)>'
/usr/local/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/usr/local/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/usr/local/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/usr/local/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/usr/local/lib/ruby/gems/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/usr/local/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/usr/local/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/Users/Stephanie/Documents/Github/dev.to/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)

== Command ["bin/rails db:setup"] failed ==

But I already added the Algolia keys to config/application.yml:

ALGOLIASEARCH_API_KEY: "myKey"
ALGOLIASEARCH_APPLICATION_ID: "myKey"
ALGOLIASEARCH_SEARCH_ONLY_KEY: "myKey"

It seems like the ENV variables aren't being set, despite changing application.yml. I'm not sure what I'm missing.

 

Hm that's strange. Try these two things:

  1. You're probably doing this correctly already, but make sure you're setting the keys in config/application.yml and not sample_application.yml.
  2. You might be running into a spring error, which is a Rails app preloader. If spring is running, it'll run bin commands for you, but sometimes doesn't refresh when you change things like environment variables. Try turning it off with spring stop and then running bin/setup again.
 

Spring wasn't actually running, but I figured out what the issue was.

When I ran git status, it seemed like I accidentally made some changes to config/application.rb. I undid those changes and now bin/setup works.

Thanks for trying to help though!

code of conduct - report abuse