I have installed a package using snap
and I need to modify one of the files but when I try to change its ownership or permissions, I always get the following message:
sudo chmod +x ./my_file.js
chmod: changing permissions of '/snap/my_app/my_file.js': Read-only file system
How can I modify files that are installed via snap
?
Snap partitions use SquashFS, which is basically a compressed, read-only disk image format that is usually used to create live CDs/DVDs. SquashFS was simply not designed to be read-write. To edit the contents, even something as simple as changing file permissions, cannot be done through a simple remount.
Your options are:
Rebuild the SquashFS file system. The following resources should be helpful:
Use OverlayFS to save changes separately.
If you would like to become a Snap developer, you might like to start with this tutorial to create your first snap.
Snap's program files are protected against change. This is done by the process of mounting the protected files in their specific space as read only.
The process also has specific space for configuration data which includes the user's specific home space (
/home/user/snap
) for data and configurations and a space for world-wide data (/var/snap
).All the world-wide snap files are readable and accessible via symbolic links to the
/snap
area.You can verify the real location and how the spaces are linked with the following commands.
A command to see examples of snap's protected mounts:
A command to see examples of snap's spaces that are not write protected:
By your error message you are trying to make change on files that have been programmably protected by the programmer. Your question suggests that you are the app's programmer. So you would have to use the features of snap's programming configuration to decide which files will be placed where.
How can I resolve this?
As I suggested in the comments, it would be safer and more common for you to design your program in a development environment as a normal user... normally in your own personal space, then use the snap's development system for installing the new version.
I'm not a snap programmer and can't give exact specifics of how the designing and export for use process works with snap. But I can imagine it might be similar to designing Android, or Java programs, where the developer will use some type of export or publish method to run or to test the new version in an installed configuration.
You could possibly experiment with remounting the protected read-only filesystems to read/write. I wouldn't advise it, because it might be possible to break the integrity of the snap system, or provide unexpected behavior where your application may not behave as intended because of the modification of the snap system itself.