Upgrading to 1.0
adotenv, adotenv-process and adotenv-cli 1.0.0 are the first stable
releases. From 1.0, the library API, the CLI commands, exit codes and JSON
output follow semantic versioning. adotenv-config and adotenv-figment keep
their own 0.x versions; 0.12 requires adotenv 1.
Update the dependency:
[dependencies]adotenv = "1"Parsed values and Portable item boundaries are the same as in 0.10. The full list of changes is in the changelog.
Within 1.x
Section titled “Within 1.x”Releases within 1.x keep the API. These fixes change results:
- 1.0.1: with a custom dialect that uses
Duplicates::First,Document::resolveandDocument::resolve_with_commandsbind a repeated key to its first visible declaration, the oneDocument::getreturns. 1.0.0 bound it to the last one. The presets useDuplicates::Lastand are unaffected. - 1.1.0:
Document::uncommentandEdit::Uncommentfail withEditError::Duplicatewhen the restored key is still declared, unless the same batch removes, comments out or renames away the other declaration. - 1.1.0:
Document::formatandDocument::sortreturn the verified output where they used to fail, leaving out only the changes that would read differently. A quote style no longer changes values that contain$. - 1.1.0: the messages of
ResolveError::Required,dotenv.tight-hash,dotenv.lone-cr,EditError::InvalidTargetandEditError::WouldChangeMeaningchanged. Match on the error or diagnostic code, not on its text. - 1.1.1:
LoadedEnvironment::resolve_contextualkeeps a value that ends with a carriage return in an LF-only dialect and a key that begins with a byte-order mark. It now returns aLoadedResolveErrornaming the key when a loaded key or value cannot be reproduced exactly, instead of resolving a changed one. - 1.1.1: reference scanning ends a
${...}operand at the first}outside a nested form, as Compose and dotenv-expand do. Quotes and backslashes inside a default, message or alternative are ordinary text.${VAR:?can't continue}now raisesResolveError::Requiredinstead of staying literal, and a backslash before a nested$in an operand no longer marks it as escaped. - 1.1.1:
fmt --writeandsetleave a file untouched when the result is unchanged. The file keeps its inode, hard links, modification time, permissions and extended attributes. - 1.1.1:
diffhuman output starts each candidate with abaseline -> fileheader and prints(no differences)when it matches, including when there is exactly one candidate. Before, one candidate printed neither. - 1.1.1: recursive
checkandfmtcontinue after a missing, unreadable or refused path.check --format jsonreports it as afilesentry withok:false, GitHub output adds an annotation, and the command exits2. Differing spellings that resolve to the same file are reported once. - 1.1.1:
Document::formatwithFinalNewline::Removeand trailing-whitespace trimming removes a final lone CR and the trailing whitespace in one pass. When several trailing CRs would leave another line ending behind, the file is left unchanged. - 1.1.1:
encode_value_withrepresents a Node literal-fallback value that needs an escaped terminal control character at the line cap, instead of returningEncodeError::Unrepresentable. - 1.1.2:
encode_value_withrepresents a Node value whose only legal token needs a repeated backtick run to survive quote recovery, instead of returningEncodeError::Unrepresentable. - 1.2.0: resolution scans at most 65,536 reference candidates per value by
default and fails with
ResolveError::TooManyReferencesbeyond that.ExpandOptions::with_max_referenceschanges the limit. Delimiter matching is bounded bymax_depth, so deeply nested forms also stop instead of retaining a record per level. - 1.2.0:
parsereturns at most 10,000 ordinary diagnostics, plus the first error after the budget. A truncated list ends withDiagnosticCode::TooManyDiagnostics; the retained error can make the total 10,002 entries.parse_strictandparse_valuesstill return the first error directly. - 1.2.0: value masking is opt-in with
Masked/maskandDeserializeError::masked; normalDebugoutput is unchanged.diffgains--mask. - 1.2.0:
Document::lookup_indexsizes its table from participating keys, so dialects that ignore many declarations use less memory. - 1.2.0:
Document::examplekeeps a leading BOM under everyBomPolicy, includingKeepandError. - 1.2.0: native encoding no longer strips a U+FEFF key at the start of an
edit or format fragment, so
setand quote formatting work for such keys. - 1.2.0: cascade mode
localremoves the duplicate.env.localpath, so report views no longer show the file overriding itself. - 1.2.0: a custom
QuotedTail::Appendvalue normalizes CR line endings and reports Portable tight-hash/backtick warnings in the appended tail. - 1.2.0: on Windows,
validate/applyandadotenv-cli runreject keys that differ only by case and values over 32,767 UTF-16 code units. Recursive discovery also recognizes uppercase.ENVnames, and cascade paths are canonicalized before mode deduplication. - 1.2.0: CLI
--dialect=<value>is accepted, repeated--dialectis a usage error, unknown--options are rejected, and temporary names are bounded. - 1.2.0:
exec::Shellcaps standard output and standard error and stops commands after a timeout by default. The builders change the limits. - 1.2.0:
fmt --writeandsetresolve the write target once and check its device, inode, size and modification time before replacing it on Unix. A swapped symlink or in-place rewrite can no longer silently redirect the write; a target that changes after the read fails. This is best effort, not a lock against every concurrent writer. - 1.2.0:
Document::setwith an empty value is idempotent when an inline comment is attached, andDocument::formatis idempotent for byte-capped dialects when spacing or trimming shortens the line. - 1.2.0: temporary write and backup names use
.adotenv-*, named input paths must be regular files, andload/runreject-/--stdinas a directory. - 1.2.0: a dangling
.env.*symlink is a load error rather than an absent optional file, andresolve_decodedkeeps a leading U+FEFF key containing an apostrophe. - 1.2.0:
Maskalso covers loaded entries, portability reports and their nested types. - 1.2.0:
encode_value_withtries a quoted body with an appended tail, including an empty or short quoted prefix, for customQuotedTail::Appenddialects, avoiding falseEncodeError::Unrepresentableresults at a line cap. - 1.3.0:
adotenv-cli checkhuman and GitHub columns on line 1 no longer count a leading byte-order mark, and--sourcehides it. UseLineIndex::without_bomfor the same columns in the library; the 1.x default still counts the mark. - 1.3.0:
ParseOptionsand the_with_optionsparse functions add opt-in limits for input bytes, items and diagnostics. A limit failure is adotenv.limit-exceededdiagnostic withDiagnostic::limit()data.LoadOptions::with_limitsapplies the same limits to loading and bounds the read itself;LoadError::Limitreports it. No limit is enabled by default. - 1.4.0:
Document::rename_with_referencesadds verified reference-aware key renaming (bracing unbraced references when needed). - 1.5.0:
CompactValues,parse_values_compact*, andload_*_values_compact*add single-buffer read-only storage for effective values with lower retained heap and allocation counts thanBTreeMap. - 1.5.4:
adotenv-cli diff --format jsonpublishes a versioned JSON Schema (diff-report.v1.json) alongside the check-report schema. - 1.6.0:
ParseOptions::max_lines/LimitKind::Linesbound physical lines,BomPolicy::StripAllstrips repeated leading UTF-8 BOMs,LookupIndex::uniqueprovides indexed uniqueness lookup,EditOptions/Document::*_with_optionsbound verified edit outputs, andCompactEntriespreserves winning bare declarations in single-buffer storage. - 1.6.1:
adotenv-cliadds global--max-input-bytes/--max-linesandset --max-output-bytes/--max-output-linesflags. - 1.7.0:
Document::rename_with_references_with_optionsbounds reference-aware renames withEditOptions,CompactValuesimplementsPartialEqandEq, andadotenv-processaddsvalidate_compactandapply_compact. Serde key-conversion errors now report the offending key name (Some(key)) instead ofSome(""); delimiter-nesting depth overflows during resolution reportResolveError::DepthExceededrather thanResolveError::TooManyReferences;Document::rename_with_referencesbraces digit-leading keys, rejects escape/quote-breaking keys and shell-quote breaks inside$(...)commands, and verifies reference structure; Windowsexec::Shellruns commands viacmd /S /Cwith raw argument quoting and rejects embedded line breaks; andadotenv-cliabortsfmt/examplebefore output when--max-input-bytes/--max-lineslimits trigger. - 1.7.1:
Document::rename_with_referencesverifies exact mapped spans across every reference field (span,command,operator_span,argumentandname), rejects shell-quote changes on renamed references nested inside$(...)command substitutions, and fixes empty-key Compose renames around unclosed${andQuotedTail::Appendboundaries. - 1.7.2:
Document::rename_with_referencesenforces a strict allowlist (ASCII alphanumeric,_and.) on renamed keys (old_keyandnew_key) nested inside$(...)command substitutions, rejecting shell metacharacters, parameter-expansion assignments, indirect expansions, array subscripts, globs and non-ASCII whitespace;encode_value_withalso maps normalized LF to CR inQuotedTail::Appendinverse tail search underLineBreaks::Lf. - 1.7.3:
Document::rename_with_referencestightens the command-context allowlist to require an ASCII letter or_first byte with no trailing.or..(rejecting POSIX positional parameters like0/1and invalid${1HOST}/..substitutions) and enforces it for any matching reference inside or following a$(command substitution in the same entry;encode_value_withandDocument::setalso account for the mandatory trailing CR-padding byte underLineBreaks::Lfandline_byte_limitinQuotedTail::Appendinverse search. - 1.8.0: adds
CompactEntriesdisk loaders (load_cascade_entries_compact*andload_entries_compact*),adotenv-process::{validate_compact_entries, apply_compact_entries}, boundedDocument::{comment,uncomment,set_export, format,sort}_with_optionswithEditOptions::max_references/LimitKind::References, andLineIndex::with_bom_policy;adotenv-cliadds global--max-items/--max-diagnosticsand boundedfmtflags (--max-output-bytes,--max-output-lines,--max-references), wiresget/load/runtoCompactValues, usesLineIndex::with_bom_policyincheck(snappingInsideCrLfdiagnostic offsets to line end), alignsfmt --sorton partially invalid files withfmtwithout--sort, and rejects duplicateset --max-output-bytes/--max-output-linesflags;Document::deserializeandLoadedEnvironment::deserializeparse non-string scalar map keys (such asBTreeMap<u16, String>andBTreeMap<bool, String>) with the same rules as values;Document::exampleemits bare text following a Compose closing quote on the same physical line (A="x"tail\n) as a#comment (A=""\n#\n) to prevent accidental secret tails from leaking while keeping explicit second assigned declarations (A="x" B=2\n->A=""\n B=\n); andDocument::formatstays idempotent underLineBreaks::Lf(including customline_byte_limit) when quote normalization combines with trailing-whitespace trimming orFinalNewline::Remove. - 1.8.1:
Document::exampleinserts a separating space after a""placeholder before#underInlineComments::AnyHashwithquoted_comments: false, emits a""placeholder for Node cross-linespace_after_eqbefore quoted values and before next-line quoted keys underSyntax::Node(scanning fromitem.content_span().end), preserves#separation when non-dialect trailing whitespace precedes an inline comment underSyntax::Compose, and keeps Node\u{2028}/\u{2029}trailing whitespace intact;Document::formatandDocument::format_with_optionspreserve a trailing carriage return underLineBreaks::Lfwhentrim_trailing_whitespaceruns withoutFinalNewline::Removeor onraw_valuesdialects.
From 0.11
Section titled “From 0.11”One change needs attention:
Edit::RenameandDocument::renamefollow the collision rule ofEdit::Insert. The new key must name exactly one declaration of the output. Removing, commenting out or renaming away its existing declarations in the same batch frees it, so a batch can swap two keys. Two renames to the same key fail withEditError::Duplicateinstead ofEditError::WouldChangeMeaning.
From 0.10
Section titled “From 0.10”Check these points as well as the rename change above.
Library
Section titled “Library”insertof a key that the document already declares fails withEditError::Duplicate. UseEdit::Setto change the existing declaration, or remove or rename it in the same batch.sortkeeps two keys connected by a one-way reference in their source order, so its output can differ where one key references another in the same group. Re-run formatting checks that compare against stored output.- Code that walks
Document::itemssees each blank line of a Node or Python file as a separateBlankitem. In Compose files, a quoted entry’s item now includes the rest of its line, so its trailing comment is its inline comment. LoadedEnvironment::resolve_contextualrequiresExpandScope::WholeFile, likeresolve_decoded.Reference::containersandReferenceContainerare gone. Walk upReference::parentthrough the list thatEntry::referencesreturned.- A resolution whose output exceeds 64 MiB fails with
ResolveError::OutputTooLarge. Raise the limit withExpandOptions::with_max_output_byteswhere large outputs are expected.
Command-line tool
Section titled “Command-line tool”- A read or write failure exits with
2in every command, includingcheckandfmt. Multi-filecheckandfmtexit with the highest code across files. runreports a child killed by signalNas128 + N, and a status outside0to255as255.loadprints Portable assignments, quoted where needed, instead of rawKEY=valuelines. It exits with2before printing anything when a key or value has no Portable spelling.
See exit codes for the full contract.
Adapters
Section titled “Adapters”- Depend on
adotenv-configandadotenv-figmentby their own versions. They no longer follow the core version. adotenv-configusesconfig0.15 and requires Rust 1.88.config0.15 keys are case-sensitive: readA.Bwith the case it has in the file.