Protect what matters – even after you're gone. Make a plan for your digital legacy today.
Forum Discussion
tjchambers
2 months agoNew Contributor
.env file comments preventing use of .env
I really want to like the local .env handling.
However the header inserted in the .env file as a "warning comment" is interfering with my usage.
If I regenerate the .env file from 1Password after loading my original, it inserts a "header".
```
# This file was generated by 1Password. Any manual edits will be lost.
# For more information, visit: https://developer.1password.com/docs/environments/local-env-file
```
if I try to use this file locally it immediately files to export the env vars:
[13:47:14] (base) ➜ xxx git:(development) export $(< .env)
export: not an identifier: 1Password.
If I remove the 2 header lines (I do not need to be warned) then it works perfectly.
Hey tjchambers,
Thanks for trying out the local .env feature and sharing your feedback!
You can get this working without removing the header by using a slightly different command:
set -a source .env set +aor
export $(grep -vE '^(#|$)' .env | xargs)Those should properly ignores comments in the file and load only the actual key-value pairs.
The issue you’re seeing happens because `export $(< .env)` assumes there are no comments or extra lines in the file, so it tries to export "1Password." as a variable name and errors out.
Does that help?
2 Replies
- tjchambersNew Contributor
I can make that work. Thank you much for the suggestion.
- sid
1Password Team
Hey tjchambers,
Thanks for trying out the local .env feature and sharing your feedback!
You can get this working without removing the header by using a slightly different command:
set -a source .env set +aor
export $(grep -vE '^(#|$)' .env | xargs)Those should properly ignores comments in the file and load only the actual key-value pairs.
The issue you’re seeing happens because `export $(< .env)` assumes there are no comments or extra lines in the file, so it tries to export "1Password." as a variable name and errors out.
Does that help?