Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Can't use environment variable with some path value on Windows #3607

Closed
Fiery-Fenix opened this issue Dec 20, 2017 · 0 comments · Fixed by #3637
Closed

[Bug] Can't use environment variable with some path value on Windows #3607

Fiery-Fenix opened this issue Dec 20, 2017 · 0 comments · Fixed by #3637
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@Fiery-Fenix
Copy link
Contributor

Fiery-Fenix commented Dec 20, 2017

Bug report

Relevant telegraf.conf:

[agent]
  interval = "10s"
  flush_interval = "10s"
  round_interval = false
  flush_jitter = "1s"
  collection_jitter = "1s"
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  debug = false
  quiet = false
  logfile = "$TEMP\\telegraf.log"

System info:

Telegraf v1.5.0 (git: release-1.5 a1668bb)
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.16299 N/A Build 16299
TEMP Environment variable value: TEMP=C:\Temp

Steps to reproduce:

Use provided config file and try to run telegraf:

telegraf.exe --config telegraf.conf --test

Expected behavior:

Telegraf runs and log file created in path C:\Temp\telegraf.log

Actual behavior:

2017/12/20 17:36:46 E! Error parsing telegraf.conf, toml: line 11: parse error

Additional info:

This is because environment variable (including system variables) contains only one slash in path, but for accessing such path from some system commands (open/read/write/etc.) you need to double slashes.
Current schema:

  1. Read config file
  2. Replace environment variables with their values
  3. Parse TOML

Proposed schema:

  1. Read config file
  2. If OS==Windows and environment variable value contains single slash - replace it with double slash, other variables replace as usual
  3. Parse TOML
@danielnelson danielnelson added the bug unexpected problem or unintended behavior label Dec 22, 2017
@danielnelson danielnelson added this to the 1.5.1 milestone Dec 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants