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

[for discussion] move default localStorage location under $HOME #122

Open
mvayngrib opened this issue Mar 1, 2016 · 11 comments
Open

[for discussion] move default localStorage location under $HOME #122

mvayngrib opened this issue Mar 1, 2016 · 11 comments

Comments

@mvayngrib
Copy link
Contributor

i ran into a problem when trying out your cash project. With my nodejs/npm setup, global installs require sudo: sudo npm i -g cash

however, because of that, cash doesn't have permissions to write to its own localstorage directory:

$ cash
fs.js:794
  return binding.mkdir(pathModule._makeLong(path),
                 ^

Error: EACCES: permission denied, mkdir '/Users/tenaciousmv/npm/lib/node_modules/cash/node_modules/vorpal/dist/.local_storage'

obviously i don't want to run cash with sudo :)

isn't it more typical to put this kind of storage in ~/.vorpal or ~/.cash or somewhere else under $HOME?

@GranularDetective
Copy link

It depends what you're trying to achieve? If you're trying to input a long path into a short directory then you're going to see an error, if you'll forgive my use of non-standard coding jargon regarding this particular instance which is actually the best way to describe it at the moment.

@mvayngrib
Copy link
Contributor Author

@GranularDetective not sure what you mean...i'm just talking about access privileges

@Shakyamuni177te
Copy link

Oh. Why do you want to sudo again? I suppose true root is much more
enjoyable but in an actual coding sense what do you mean exactly?

On 1 March 2016 at 10:58, Mark Vayngrib notifications@github.com wrote:

@GranularDetective https://github.com/GranularDetective not sure what
you mean...i'm just talking about access privileges


Reply to this email directly or view it on GitHub
#122 (comment).

@Shakyamuni177te
Copy link

Why don't you want to sudo again, rather. Muh bad.

On 1 March 2016 at 11:10, Peter Carter peter.carter.mail@gmail.com wrote:

Oh. Why do you want to sudo again? I suppose true root is much more
enjoyable but in an actual coding sense what do you mean exactly?

On 1 March 2016 at 10:58, Mark Vayngrib notifications@github.com wrote:

@GranularDetective https://github.com/GranularDetective not sure what
you mean...i'm just talking about access privileges


Reply to this email directly or view it on GitHub
#122 (comment).

@dthree
Copy link
Owner

dthree commented Mar 1, 2016

@mvayngrib agreed. We just need a cross-platform temp dir. I think I implemented this in wat anyways, before I added localstorage to Vorpal.

Should be a pretty easy fix.

@mvayngrib
Copy link
Contributor Author

@dthree if you don't end up separating it out of wat, there's user-home and home-or-tmp

@Shakyamuni177te
Copy link

You added local storage to Vorpal? To wat purpose?
On 1 Mar 2016 17:16, "dc" notifications@github.com wrote:

@mvayngrib https://github.com/mvayngrib agreed. We just need a
cross-platform temp dir. I think I implemented this in wat
https://github.com/dthree/wat anyways, before I added localstorage to
Vorpal.

Should be a pretty easy fix.


Reply to this email directly or view it on GitHub
#122 (comment).

@dthree
Copy link
Owner

dthree commented Mar 1, 2016

Okay thanks.

@dthree dthree closed this as completed in dad91ef Mar 2, 2016
@dthree
Copy link
Owner

dthree commented Mar 2, 2016

os.tmpdir() works fine.

Fixed in v1.10.7.

@goodevilgenius
Copy link

I know this is an old issue, but I just found it, while trying to figure out where this was stored.

I think using os.tmpdir() isn't a good idea, as, on some OSs (like Linux), this may default to a volatile directory. These files may not persist after a reboot.

I think the original suggestion of it being somewhere in the home directory is better. There's frequently a .cache directory in $HOME. That's where, e.g., yarn stores its module cache.

@dthree dthree reopened this Mar 2, 2017
@goodevilgenius
Copy link

For reference, this is how yarn does it:

function getDirectory(category: string): string {
  // use %LOCALAPPDATA%/Yarn on Windows
  if (process.platform === 'win32' && process.env.LOCALAPPDATA) {
    return path.join(process.env.LOCALAPPDATA, 'Yarn', category);
  }

  // otherwise use ~/.{category}/yarn
  return path.join(userHome, `.${category}`, 'yarn');
}

function getCacheDirectory(): string {
  if (process.platform === 'darwin') {
    return path.join(userHome, 'Library', 'Caches', 'Yarn');
  }

  return getDirectory('cache');
}

So, getCacheDirectory() returns $HOME/.cache/yarn on Linux, %LOCALAPPDATA%\Yarn\cache on Windows, and $HOME/Libarary/Caches/Yarn on macOS.

I think something like that would be a good option for vorpal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants