Cannot modify files installed by `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.
Related videos on Youtube
Miladiouss
Updated on September 18, 2022Comments
-
Miladiouss over 1 year
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
?-
Apologician about 6 yearsI see you recently changed your question. However, my answer and comments still apply to the new question. App development really should be done in your own personal space, or a shared development area. The files that you think should be modified should be addressed on the development level and places according to how you want the user to have access to them. If the program is creating the files you are trying to manually modify, make that change in the app so that it will create the file correctly. Root shouldn't be used until you are in the process of making a system-wide installation.
-
Miladiouss about 6 yearsThank you James, I was trying to integrate math with Slack, I was not developing a package. See this for more examples: github.com/fsavje/math-with-slack
-
Apologician about 6 yearsI understand that from your original question about the read/only characteristic when you still couldn't do it from a elevated
sudo
command. My suggestion was then, with is consistent, is that you really shouldn't have to work on the program and development fromsudo
. The/snap/my_app/my_file.js
appeared to be a project that you were working on. Your recent comment still appears to suggest the same. Even if it's slightly different, it would be best to work on the your integration project in your personal space by a non-elevated user account and (develope
), work on it that way. -
Apologician about 6 years...(continued) working and developing it in
/snap
isn't the best and most secure method. Making the system-wide change, while you're working and debugging it could cause a undesirable integrity effect of yoursnap
installation ( or your overall system's integrity). You can easily make the changes to the data files if you bring your project into your personal space. Once you get it working the way you want it, you can then apply your changes and patches necessary to the/snap
(which is system-wide) environment.
-
-
Miladiouss about 6 yearsThat sounds about right. Thanks. Can you direct me to a starting point please. Never done this before.