jdx / mise

dev tools, env vars, task runner
https://mise.jdx.dev
MIT License
9.14k stars 248 forks source link

Mise treats escaped newlines in env files differently than dotenvy #2453

Closed maxhollmann closed 1 month ago

maxhollmann commented 1 month ago

Describe the bug With an .env file containing X='{"bla": "one\ntwo"}', dotenvy -f .env env shows X={"bla": "one\ntwo"}, while loading the same file with mise via _.file = ['.env'], env reports

X={"bla": "one
two"}

To Reproduce

Expected behavior Mise should load the .env file the same way as dotenvy's CLI and set X to {"bla": "one\ntwo"}, without unescaping the \n.

mise doctor output

version: 2024.8.5 linux-x64 (98c44b8 2024-08-03)
activated: yes
shims_on_path: no

build_info: 
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Sat, 3 Aug 2024 22:37:06 +0000
  Rust Version: rustc 1.80.0 (051478957 2024-07-21)
  Profile: release

shell: 
  /bin/zsh
  zsh 5.9 (x86_64-ubuntu-linux-gnu)

dirs: 
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/.cache/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files: 
  ~/.config/mise/config.toml
  ~/metergrid/dev/dotenvy-debug/.mise.toml

backends: 
  cargo
  core
  go
  npm
  pipx
  spm
  ubi

plugins: 
  bun        (core)
  deno       (core)
  direnv     https://github.com/asdf-community/asdf-direnv.git#a2219c2
  erlang     (core)
  go         (core)
  java       (core)
  node       (core)
  pnpm       https://github.com/jonathanmorley/asdf-pnpm.git#305baff
  poetry     https://github.com/mise-plugins/mise-poetry.git#431c335
  python     (core)
  ruby       (core)
  usage      https://github.com/jdx/mise-usage.git#fe3888a
  watchexec  https://github.com/nyrst/asdf-watchexec.git#b667a08
  yarn       https://github.com/mise-plugins/asdf-yarn.git#74ea3b9
  yq         https://github.com/sudermanjr/asdf-yq.git#772992f
  zig        (core)

toolset: 
  python@3.12.3         
  usage@0.3.0           
  cargo:ripgrep@14.1.0  
  cargo:bat@0.24.0      
  yq@4.40.5             
  cargo:dua-cli@2.29.0  

env_vars: 
  MISE_SHELL=zsh

settings: 
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_tools = []
  experimental = true
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  http_timeout = 30
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  libgit2 = true
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_default_packages_file = "~/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = false
  yes = false
  ci = false
  debug = false
  trace = false
  log_level = "info"
  python_venv_auto_create = false

  [status]
  missing_tools = "if_other_versions_installed"
  show_env = false
  show_tools = false

No warnings found
No problems found
roele commented 1 month ago

It seems that the dotenvy crate does not implement non-processing multiline (yet) depending on weak/hard quotation as for example the Swift variant does

roele commented 1 month ago

Further investigation shows that single quotes indeed result in \n as characters \ and n while double quotes resemble a literal \n. Issue seems to lie in how mise sets environment variables for certain shells.

maxhollmann commented 1 month ago

Awesome, thanks for the quick help!