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

macOS: Error: ENOENT: no such file or directory, lstat '/private/tmp/ ... #100

Open
unphased opened this issue Jul 20, 2020 · 1 comment

Comments

@unphased
Copy link

unphased commented Jul 20, 2020

Based on the readme:

realpath: Resolve symlinks using realpath, defaults to true (note that if true, the file must exist previously)

This explains that the setting is true by default, and because /tmp is symlinked to /private/tmp on macOS, it produces this ENOENT problem whenever we try to use a lockfile in /tmp.

What is the official workaround for this? Disabling realpath works for me in testing. But I am unclear on what are the drawbacks of specifying realpath: false and why exactly this fails. Is realpath intended as a security measure or a convenience measure that has lower security?

I was beginning to think that manually creating the lockfile is what I'm supposed to do, but on second thought that seems to go against the notion of the lockfile itself...

@LiamTrioTech
Copy link

LiamTrioTech commented Aug 7, 2020

Error on Windows as well.
How to use this library?
Want my.lock file so process only runs once at a time...

Something like this? But it does not make the locking directory inside the folder..

var myLock = lockfile.lock('./', { lockFilePath: './my.lock' })
.then((release) => {
    // Do something while the file is locked
 
    // Call the provided release function when you're done,
    // which will also return a promise
	 mainprocedure().then( result => {
		console.log('Finished', result)
		console.timeEnd('Running main import.')
		return release()
	}).catch(error => {
		console.error(error)
		console.timeEnd('Running main import.')
		return release()
	})
})
.catch((e) => {
    // either lock could not be acquired
    // or releasing it failed
    console.error(e)
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants