简体   繁体   中英

Fog directory can't be blank, Aws access key can't be blank, Aws secret access key can't be blank

Im using asset_sync gem to upload assets to Amazon S3 bucket. I used dotenv to store my keys and secret keys and deployed using capistrano to Amazon EC2. Everything was fine.

But when I moved the keys to .bash_profile on my server and added an initializer , asset upload failed with this error.

rake aborted!
Fog directory can't be blank, Aws access key can't be blank, Aws secret access key can't be blank

Please help me to figure out why the keys/secrets are not found.

Basically means you've not set the ENV vars for your shell session. I guarantee if you run rake assets:precompile FOG_DIRECTORY=[your_dir] AWS_ACCESS_KEY_ID=[your_access_key] AWS_SECRET_ACCESS_KEY=[secret_access] you'll be able to perform the operation

The best recommendation I can give right now is to look in the /etc/environment file on your VM. If you have this file, you'll be able to set the system-wide variables which will get used each time you load your app

The problem is an issue between the assigning of ENVIRONMENT & SHELL variables - SHELL vars are only available in a specific shell session, whilst ENVIRONMENT vars are available throughout the system

I have not found how to declare shell-specific variables on the fly yet, by putting all the env vars inside /etc/environment it works for us

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM