Fixing File Permission Errors
PIXILAB Blocks makes sure that file permissions and naming conventions are maintained properly during normal use. However, when moving files from one computer to another, problems may arise due to permissions or naming conventions being lost along the way. If you run into problems that appear to be permission related after moving either a complete Blocks root or parts of one between computers, these can often be resolved by following the procedure outlined below. The exact steps vary depending on what platform you're using.
- Mac or Windows typically don't require any special setting or permissions since everything here is managed by Blocks directly, under the account of the user running Blocks.So as long as all files have read and write permissions for that user, you should be fine. This is usually the case even after moving files by USB memory stick, a ZIP file or similar.
- When running Blocks using our complete Linux server image, a script is already available to fix file permissions and naming conventions.
- When running Blocks on a server built using our net-blocks script, you need to download and run a program since that's not included in the net-blocks distribution.
Running Blocks on our Linux Server Image
To fix file permissions after copying a complete or partial Root folder to the server, do as follows on that server:
- Log in as the pixi-server user.
- Stop Blocks by clicking the Quit button in the Blocks window.
- Open a terminal window and type the following commands.
cd Utilities ./fix-blocks-root-public.sh
Press Enter to run the script. Any files that needed to be fixed will be listed as the script runs. You can now start Blocks again and verify correct operation.
Blocks Running on a net-blocks Server
To fix file permissions after copying a complete or partial Root folder to the server, do as follows on that server:
- Log into the server as the blocks user. This is typically done over ssh, resulting in a terminal window.
- Run the following commands in that terminal.
systemctl --user stop blocks wget https://pixilab.se/outgoing/blocks/cloud-support/filefixer.jar java -jar filefixer.jar ~/PIXILAB-Blocks-root/public systemctl --user start blocks
The commands above do the following:
- Stop Blocks so it is not running while performing the operation.
- Download the filefixer.jar program. This step assumes you server has internet access. If not, download and transfer the filefixer.jar file by other means.
- Run the filefixer.jar program, targeting the public subdirectory of your Blocks root directory. Adjust the path here if your Blocks root is located elsewhere.
- Start Blocks again, letting you verify proper operation.
Technical Details
This section describes the technical reasons for why there may sometimes be problems transferring files between Blocks servers and what the filefixer.jar program does to remedy such problems. You don't need to read this if you just want to "fix" the problem.
File Permissions
When running Blocks under Linux, it is important that all relevant files are both readable, writable and (for directories) traversable by the relevant users and processes. While this is usually OK for the user under which you run Blocks, it may not be the case when running nginx as a reverse proxy, which is typically the case for Linux based servers. In this case, nginx runs under a separate user (typically www-data). When using nginx in this way, nginx directly serves all files under public in your Blocks root, so those files must be readable and traversable also by that user.
The filefixer.jar program will make sure that all files under the directory to which it is applied are readable by any user, thus letting nginx access those files. Note that nginx doesn't write to those files (this is done by Blocks), so it only needs read access.
File Naming Conventions
All modern operating systems have support for Unicode filenames. Unicode is an international standard that describes how to encode all characters of all languages. Unfortunately, for some characters, there's an ambiguity as to how those can be encoded. This applies to most characters with umlauts or other diacritical marks such as our swedish å, ä and ö, as well as the german ü.
There are two different ways to encode such characters, referred to as NFC ("Normalization Form Canonical Composition") and NFD ("Decomposed Form"). Some operating systems, such as macOS, have standardized how such characters must be encoded on disk (here by enforcing NFD). Windows tends to use NFC, but that's appears not to be enforced by the operating system. Linux is largely "agnostic" and gladly accepts both forms.
Unfortunately, this confusion may result in strange situations – especially when moving files across operating systems or using ZIP files – where you end up with the "wrong" encoding. You can even end up in a situation where there are multiple files with seemingly exactly the same filename in a directory (such as two files both named "Örjan"). Needless to say, this also confuses the programs trying to access those files.
Under Linux, Blocks expects all files to have their names encoded according to the NFC standard. The filefixer.jar program looks for files named in a conflicting way and corrects those files, so they can be found by Blocks and nginx.