yeoman / configstore

Easily load and persist config without having to think about where and how
BSD 2-Clause "Simplified" License
868 stars 56 forks source link

Fallback if $HOME isn't set #5

Closed sindresorhus closed 11 years ago

sindresorhus commented 11 years ago

everything that can go wrong will go wrong

There are of course environments where $HOME is not set: https://github.com/bower/bower/issues/558

Is there any way we can gracefully fallback to something else? Maybe a hidden local folder? (it needs to be persistent, so can't use /tmp).

@satazor @passy @stephenplusplus

passy commented 11 years ago

I could not find any program that relies on configuration options stored in the user directory and does not complain about HOME being unset:

$ git config --global --list
fatal: $HOME not set

$ tig
tig: Failed to load user config.

I think configstore should just pretend that no config is available. Saving is tricky, though. I don't think it should fail silently.

Interesting side note: You cannot unset or modify HOME in fish. <3

sindresorhus commented 11 years ago

Interesting side note: You cannot unset or modify HOME in fish. <3

The best solutions are those that prevent you from doing stupid things <3

davidmaxwaterman commented 11 years ago

I'm curious if there is any plan to address this issue, one way or the other. Can someone set expectations appropriately? Thanks.

sindresorhus commented 11 years ago

Yes, I'm working on a fix.

satazor commented 11 years ago

I think that any user that uses configstore can't really trust that the value will be persistent forever, since the user can just delete the .config/configstore folder. Code must adapt to that fact.

Having this said, I think that using tmp is a viable option since the value will be persistent but by an undetermined duration. I've implemented #7 with this strategy.

Related: https://github.com/bower/bower/issues/525#issuecomment-21808076

satazor commented 11 years ago

@sindresorhus Needs to be improved. I think we must append the username to the tmp folder, so that multiple users do not use the same folder (causing EACCESS/EPERM issues).

We can use osenv module from isaacs to get the username.