Reputation: 195
I'm developing an app with the Hubot framework, using Heroku.
I have some config vars set on Heroku, and when I deploy my code, my process.env
references work fine.
However, I've had trouble getting my local development system set up with the config vars for testing. I have a .env file and have fetched all the config vars from Heroku. However, the .env file does not seem to be loaded when I start my app at the command line.
I've added hubot-env (as suggested at Hubot - load environmental variables from a file) and can load my .env file manually each time I start my app with the command
hubot env load --filename=[filename]
I'd like to automate this, so this command is automatically executed when I start my bot. Where could I configure this?
Upvotes: 1
Views: 381
Reputation: 522
This is a really old question but I'm working on Hubot now and need to save this for posterity.
This is how I'm doing it now. It works without adding additional files or packages:
"scripts": {
"start": "export $(cat .env | xargs) && ./bin/hubot -a slack"
}
Change your adapter from slack
to whatever you are using.
Upvotes: 1
Reputation: 81
Regarding this issue as I understood Hubot doesn't read .env file. Instead of exporting variables each time my solution was to create bash-script run.sh
file:
#!/bin/bash
export HUBOT_OWM_APIKEY=MY_OWM_API_KEY;
export HUBOT_WEATHER_UNITS=metric;
HUBOT_SLACK_TOKEN=xoxb-xxxx-MY_SLACK_TOKEN ./bin/hubot --adapter slack
then in bash
$ chmod +x run.sh # provides the permissions
$ ./run.sh # starts the bot with necessary variables
Upvotes: 1