Contrary to what is stated in the documentation of dotenv, you actually need to use the export keyword within the .env file in order to make the parameters available to the environment, e.g.
export FOO=foo
The only exception would be, if the parameter was already an environment variable. For example if it had been exported in ~/.zshrc or if it was already part of the environment zsh got when it started (e.g. PATH or HOME).
All dotenv does is automatically sourcing any .env file when changing into a directory. There is no additional "magic". That means .env needs to be a valid zsh script and its content is run in the context of the current shell session (essentially as if you typed it manually).
It also means that the usual rules apply. That is, just settings parameters makes them available to the current shell context only. In order to make them available as environment variables they need to be exported (either before, during or after being set). So unless a parameter has already been exported before, export is not really "optional" in .env.
require 'dotenv/load'? - whodini9dotenvgem (just the oh-my-zsh plugin) as I was under the impression that the shell plugin would export the vars automatically. - doremiexport FOO=testand then irb:ENV['FOO']? That works here in iTerm2 on Mac OS. - Frederik Spangenvcannot see. But I'm not sure how to fix that. - doremi.envis in the working directory, it will work. Seems strange to rely on zsh functionality within your ruby program. You can easily exclude your.envfile from a repo - whodini9