-
Notifications
You must be signed in to change notification settings - Fork 465
Rescript v10 building in watch mode fails with permission error #5617
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
Comments
So I've been looking around to see if I can find anything. I noticed that the lock file now has permissions added // We use [~perm:0o664] rather than our usual default perms, [0o666], because
// lock files shouldn't rely on the umask to disallow tampering by other.
(...)
fs.openSync(lockFileName, "wx", 0o664); I created a small js file to try to mimick it to see if windows doesn't like that: const fs = require("fs");
const path = require("path");
const lockFileName = path.resolve(process.cwd(), ".bsb.lock");
fs.openSync(lockFileName, "wx", 0o664); But that had no problem running and creating the file, so not too sure where to look next as I'm not too familiar with filesystem permissions |
Would you post on the forum, see if some other Windows user has ideas. |
I am facing the same issue on windows with the rescript@10 |
I am on Windows 10 and on upgrade to rescript@10 I observed the same issue with |
Would either of you who experience this problem be up for doing some debugging to fix this issue? I'm afraid we're short on contributors using Windows. |
I can help if there's something you'd like me to try |
1 check changes to the "rescript" script since then, see if something rings a bell 2 If that does not work, check recent changes to ninja (https://github.com/rescript-lang/ninja), see if something rings a bell |
@cristianoc Ok so every version of 10x down to alpha does not work. I tried your idea of copying the contents of I added some logging inside the acquireBuild: is_building? false
acquireBuild: fs.openSync C:\Users\sebhe\Code\issue-rescript-permissions\.bsb.lock
BSB check build spec : C:\Users\sebhe\Code\issue-rescript-permissions\node_modules\rescript\win32\rescript.exe
Rebuilding since proj,started
acquireBuild: is_building? false
acquireBuild: fs.openSync C:\Users\sebhe\Code\issue-rescript-permissions\.bsb.lock
acquireBuild: catch error:
Error: EPERM: operation not permitted, open 'C:\Users\sebhe\Code\issue-rescript-permissions\.bsb.lock' |
@hellos3b thank you for digging. So there's an easy "fix", and ideally we'd like a proper fix. @TheSpyder what would a proper fix look like? |
(and after that, we should add a test to catch future regressions) |
@cknitt: |
I can look into that when I have some time. We are already running a (very simple) build test with the finished npm package at the very end of the CI process though: |
If TheSpyder@c32cc34 is the problem it suggests Perhaps it's because the function is already called elsewhere in the file: And previously the code didn't attempt to acquire the lock twice. My suggested fix is to make the function use |
This is because the api |
@Mng12345 Thanks for the tip! Are you able to submit a PR? |
Hi, i'm afraid not. This repository is too big for me to clone it locally due to the network is limitted in China... function acquireBuild() {
if (is_building) {
return false;
} else {
try {
fs.openSync(lockFileName, "wx", 0o664);
is_building = true;
} catch (err) {
if (err.code === "EEXIST") {
console.warn(lockFileName, "already exists, try later");
} else console.log(err);
}
return is_building;
}
} To: function acquireBuild() {
if (is_building) {
return false;
} else {
try {
const fid = fs.openSync(lockFileName, "wx", 0o664);
fs.closeSync(fid);
is_building = true;
} catch (err) {
if (err.code === "EEXIST") {
console.warn(lockFileName, "already exists, try later");
} else console.log(err);
}
return is_building;
}
} |
Thank you! And that still throws the |
That might be an even better place to run build tests. How about creating an issue for now, just as a reminder to revisit that later. |
I tried it out on my local and can confirm that @Mng12345 's suggestion of closing sync after opening works on windows, and ran two process and spam save to see the error come up at least once |
I thought watch mode threw 'lockfile exists' on startup, but I must be remembering back to the What it used to do was write the Might be nice to get closer to the old behaviour eventually - this approach of continuously retry until a build can be started certainly avoids errors, but doesn't seem correct. It should hold the lock the entire time watch mode is running. |
I've upgraded to
rescript@10
and watch mode now fails withError: EPERM: operation not permitted, open 'C:\Users\sebhe\Code\issue-rescript-permissions\.bsb.lock'
Full message:
I am on Windows 11 and have had no issue with previous versions.
Steps I've taken to reproduce:
System Info:
I created an empty project and tried it in there and got the same error message. I've pushed it to github and included the
lib/bs
file in case anything in there is helpfulhttps://github.com/hellos3b/issue-rescript-permissions
Running
npm install rescript
to go back to v9 resolves the issueThe text was updated successfully, but these errors were encountered: