Open Temp File filename.mscz.temp Failed: Permission denied
I've been having trouble with the "Save" on Musescore giving me a permission denied error: "Open Temp File filename.mscz.temp Failed: Permission denied"
To provide some debugging information, I opened Musescore 3.6.2-3 (Manjaro package) in strace, (filtered to only some relevant system calls) changed one note in my score, and hit "Save".
$ strace musescore Morenica.mscz 2>&1 | egrep 'Morenica|chdir'
execve("/usr/bin/musescore", ["musescore", "Morenica.mscz"], 0x7ffd5378f1f8 /* 67 vars */) = 0
access("/home/kabloom/sheetmusic/Morenica.mscz", F_OK) = 0
readlink("/home/kabloom/sheetmusic/Morenica.mscz", 0x7ffdcf856670, 1023) = -1 EINVAL (Invalid argument)
openat(AT_FDCWD, "Morenica.mscz", O_RDONLY|O_CLOEXEC) = 41
openat(AT_FDCWD, "Morenica.mscz", O_RDONLY|O_CLOEXEC) = 42
statx(AT_FDCWD, "Morenica.mscz", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW|AT_NO_AUTOMOUNT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=19354, ...}) = 0
access("Morenica.mscz", W_OK) = 0
chdir("/usr/bin") = 0
openat(AT_FDCWD, "Morenica.mscz.temp", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = -1 EACCES (Permission denied)
The chdir
call is occurring as part of Musescore's startup process, so if I open Musescore this way, and close Musescore without trying to save anything, the chdir
call is still a part of the trace.
Comments
When I reset my settings to factory defaults, the
chdir
call didn't happen until after I finished the confguration wizard.Do you have the same error when using the AppImage?
In reply to Do you have the same error… by jeetee
This does happen with the AppImage too, but
strace
doesn't follow forks by default, and if I trystrace --follow-forks
then the AppImage just won't start, so I can't provide you with anstrace
of the AppImage.In reply to This does happen with the… by Ken Bloom
Here's what I do get from the
strace --follow-forks
, however the AppImage terminates before showing the application window when I do that.I think the error is caused by your sheetmusic folder being a symlink instead of a real folder.
During saving MuseScore indeed uses a temporary file, but it is supposed to be saved in the location extracted from the current file, so it can be saved right next to it.
For some reason (I suspect thus the sheetmusic or even the kabloom folders being not real folders) the retrieved file location for your opened file is empty. (
Qt.FileInfo::filePath()
)When then the new filehandle is being constructed it is only provided the retrieved empty path + the temp filename, which is considered a relative path to the current executable directory; hence the chdir you're seeing.
This perhaps might be fixable by using
Qt.FileInfo::canonicalPath()
instead, but I'm not familiar enough with the possible caveats this function then might bring as well.Since no further updated for 3.x are planned, it would be nice if you could verify whether this is resolved in 4.0 once that Alpha has been released.
In reply to I think the error is caused… by jeetee
/home/kabloom/sheetmusic
is not a symlink, and neither is/home/kabloom
.In reply to /home/kabloom/sheetmusic is… by Ken Bloom
Also, the
chdir
seems to happen regardless of whether I pass a filename on the command-line.In reply to /home/kabloom/sheetmusic is… by Ken Bloom
Morenica.mscz
isn't either?In reply to Morenica.mscz isn't either? by Jojo-Schmitz
Nope.. I got thrown off scent by the
readlink
call in that trace; but looking at the man page reveals that the return code indicates that it indeed is not a symlink.So there's another issue at play here as to why the temporary file is being created in the usr/bin folder rather than next to the existing file.
@OP: What is shown in
File → Score Properties
as the file path for your opened file?In reply to Nope.. I got thrown off… by jeetee
It says:
If I run Musescore and pass the absolute path on the command-line, it simply says:
In reply to It says /home/kabloom… by Ken Bloom
That "initially read from" path is what is causing the troubles.
(You can't edit the chdir out of MuseScore because it's not part of MuseScore's own code, but of the Qt libraries that do the cross-platform file handling for us).
So your workarounds seem to be:
A.) launch via commandline, use the full file path.
B.) Use "File > Open" from within MuseScore instead.
In reply to Morenica.mscz isn't either? by Jojo-Schmitz
No part of the path to that file is a symlink.
I tried again, passing the absolute path to Morenica.mscz on the command-line, and the save succeded. So one fix for this issue is to resolve the filename given on the command-line into an absolute path early in the loading process, using
QFileInfo::absoluteFilePath()
. This has to happen before thechdir
.The other solution would be to find and eliminate the
chdir("/usr/bin")
call.In reply to None of it's a symlink. I… by Ken Bloom
And it looks like
MuseScoreApplication::parseCommandLineArguments
callsabsoluteFilePath
here, so I don't know why that's not having the desired effect.In reply to I think the error is caused… by jeetee
You mean something like this?
In reply to You mean something like this… by Jojo-Schmitz
That'd be my guess indeed; assuming the current issue is indeed a symlink issue (which according to OP it might not be)
In reply to That'd be my guess indeed;… by jeetee
Actually
canonicalFilePath()
, I think.See https://doc.qt.io/qt-6/qfileinfo.html#canonicalFilePath
In reply to Actually canonicalFilePath()… by Jojo-Schmitz
Yes, yes; do as I mean, not as I say ;-)
In reply to I think the error is caused… by jeetee
I just verified that this is not an issue in the Feb 22 nightly of the 4.x branch.
In reply to I just verified that this is… by Ken Bloom
Thank you for checking!
See #285735: Open Temp File (file location) failed: Bad File Descriptor