Giter VIP home page Giter VIP logo

Comments (1)

khan-zia avatar khan-zia commented on May 27, 2024

I figured this out later. The problem is indeed not with permissions but rather the config file not existing at all for the root user when running the app in the background. Basically, this package conf by default uses user's home directory to create and store configuration file. If the user changes, obviously the home directory changes, hence the unexpected loss of config for your app that might need to run in the background by another user.

The simplest fix for this is that when instantiating conf, you can pass the cwd option to the constructor which will then use your specified location for storing configuration. If your app has a use case like mine, where the config might be created when the app is set up by a human/another user and then your app has to run as a daemon most likely by user root or another special user, your best bet is to specify a system wide config directory that's available to all users via the cwd option. In linux, a standard system-wide config location is the /etc folder.

Remember that your app running as a root means you will have to deal with the sudo shenanigans. If you specify a location at /etc for the cwd option, then all users will either need to be sudoers or have to use sudo on each operation of your app in which conf writes to the configuration file. Otherwise, conf will fail with permission denied error.

P.S
@sindresorhus Perhaps this should be mentioned in the Readme? Or at least some more details about the default location of the config file used by conf.

from conf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.