question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Environment variables in file path don't work on Linux

See original GitHub issue

I have following config in my JSON file:

"WriteTo": [
  {
    "Name": "Async",
    "Args": {
      "configure": [
        {
          "Name": "File",
          "Args": {
            "path": "%PROGRAMDATA%/TehGM/fsriev/logs/log-.log",
            "rollingInterval": "Day",
            "retainedFileCountLimit": 30,
            "fileSizeLimitBytes": 2097152,
            "rollOnFileSizeLimit": true,
            "buffered": false
          }
        }
      ]
    }
  }
]

This works as expected on Windows 10. However, when the application is ran on Debian, folder of name %PROGRAMDATA% is created instead. I also tried %APPDATA%: obraz

When using special folders feature using in-code configuration, they work perfectly fine.

Library version: 3.1.0.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
diogocpcommented, Apr 6, 2021

I would suggest configuring the defaults in code and leaving the user with the option to override the default by setting the path in the configuration file.

@nblumhardt I haven’t tried it, but according to the documentation % should also work on Linux: https://docs.microsoft.com/en-us/dotnet/api/system.environment.expandenvironmentvariables

0reactions
TehGMcommented, Apr 5, 2021

Ok, that’s something. Non ideal, but something.

Is there anyworkaround that would work on both Windows and Linux? I want to keep a single configuration file for both, Windows and Linux, so it’s within the same download.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment Path Variable Not working properly [duplicate]
So far I've tried( in my .bashrc file):. export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin; exportPATH ...
Read more >
How To View and Update the Linux PATH Environment ...
The PATH variable contains a list of directories the system checks before running a command. Updating the PATH variable will enable you to...
Read more >
shell - $PATH environment variable does not seem to be ...
In a shell command like. PATH=~/bin:/opt/texbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games. the tilde is expanded to your home ...
Read more >
dotenv file is not loading environment variables
How about use require('dotenv').config({path:__dirname+'/./../../.env'}) ? Your problem seems to be the execution path.
Read more >
Adding a Path to the Linux PATH Variable
The PATH variable is an environment variable containing an ordered list of paths that Linux will search for executables when running a command....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found