Unable to write file: Read-only file system
53 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm using the R2021a on MacOS Big Sur. I'm trying to run a script on that needs to write a file using the save command. I keep getting the following error:
Error using save
Unable to write file /Testing: Read-only file system.
The script runs the function:
save([dlocs{ii},filesep,dnames{ii}],'mov','-v7.3');
Where the first parameter are all preassigned variables and 'mov' is a temporary string variable. Testing is the filename of a .tif file.
The attributes of Testing.tif are:
archive: NaN
system: NaN
hidden: NaN
directory: 0
UserRead: 1
UserWrite: 1
UserExecute: 0
GroupRead: 1
GroupWrite: 0
GroupExecute: 0
OtherRead: 1
OtherWrite: 0
OtherExecute: 0
I have admin access to all files on the computer that I am using.
Respuestas (1)
Zinea
el 19 de Feb. de 2024
Editada: Zinea
el 20 de Feb. de 2024
The error message "Unable to write file /Testing: Read-only file system" suggests that the script is trying to save the file to the root directory (/) of your macOS filesystem, which is typically protected and not writable by user-level processes. This could be due to an incorrect path specified in the variables dlocs{ii} and dnames{ii}.
Here are some ways to resolve the issue:
1. Check the Path Variables
The variables "dlocs{ii}" and "dnames{ii}" determine where the “save” function attempts to write the file. You need to ensure that dlocs{ii} points to a directory where you have write access. Here's how you can check and correct the path:
Print the Path: Add a line of code before the save command to print the full path to the console. This will help you verify the path being used.
fullPath = fullfile(dlocs{ii}, dnames{ii});
disp(['Attempting to save to: ', fullPath]);
Validate the Path: If the printed path is not what you expect, or if it's pointing to the root directory /, you need to adjust dlocs{ii} to point to a valid, writable directory.
2. Correct Directory Permissions
Even if the path is correct, the directory might not have the necessary write permissions. Here's how to check and modify permissions:
Using Finder: Navigate to the directory in Finder, right-click on it, and select 'Get Info'. Scroll down to 'Sharing & Permissions' and ensure that your user has 'Read & Write' access. If not, click the lock icon to make changes, and then set the appropriate permissions.
Using Terminal: Open the Terminal and use the "chmod" command to grant write access to your user. For example, to grant write access to the current user for a folder named 'MyFolder', you would use in bash:
chmod u+w /path_to_MyFolder
By following these detailed steps, you should be able to possibly diagnose and fix the issue with the save function in MATLAB. If the problem persists, double-check the values of "dlocs{ii}" and "dnames{ii}" at runtime, and ensure that your script has the necessary permissions to write to the desired location.
0 comentarios
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!