SOLVED: No app env file found: '/hab/svc/app-name/config/app_env.sh'


#1

I am trying to use Habitat to configure, package, and deploy a Ruby on Rails application. When I try to run:

hab pkg exec origin/app-name app-name-rake db:setup

I get:

No app env file found: ‘/hab/svc/app-name/config/app_env.sh’
Have you not started this service (origin/app-name) before?

Aborting…

However, when I switch to hab user I can cat /hab/svc/app-name/config/app_env.sh. The file is there and the permissions are correct but for some reason habitat refuses to read it. Also, this is only happening on my Ubuntu server. I can run it locally fine with Docker.

default.toml:

secret_key_base = “long_secret”

rails_env = “production”

[app]
port = 8000

[db]
adapter = “postgresql”
name = “app_production”
user = “admin”
password = “admin”
host = “”
port=5432

plan.sh:

pkg_name=app-name
pkg_origin=origin
pkg_version=“0.1.0”
pkg_scaffolding=“core/scaffolding-ruby”
pkg_binds_optional=( [database]=“port” )

declare -A scaffolding_env
do_setup_environment(){
scaffolding_env[SECRET_KEY_BASE]="{{cfg.secret_key_base}}"
}

set_buildtime_env SECRET_KEY_BASE “{{cfg.secret_key_base}}”

/hab/svc/app-name/config/app_env.sh:

export RACK_ENV=‘development’
export SECRET_KEY_BASE=‘long secret’
export RAILS_SERVE_STATIC_FILES=‘enabled’
export LANG=‘en_US.UTF-8’
export RAILS_ENV=‘development’
export RAILS_LOG_TO_STDOUT=‘enabled’
export PORT=‘8000’
export DATABASE_URL=“aws database url”

Any advice would be much appreciated.


#2

Never mind. I just needed to sudo.