Common klayoutrc file

@Matthias Hello!
We have been using your klayout tool in our company for many years.
Long time ago (at version 0.23) I created common place for technology data and common tuned klayoutrc file in order for everyone to have the same settings, and technology definitions. And we run it like "klayout -c $KLAYOUT_BASE_PATH/klayoutrc".
This common place was read only for all files inside for all users.
Recently I have updated klayout up to 0.27.2 version.
After running klayout in same manner (with common and read only klayoutrc file), I'm getting the following warning on exit:
"Warning: Could not create backup file: unable to rename original file '/klayoutrc' to backup file"
But amaizing issue is that klayout changes this read only klayoutrc file!
For example, it writes paths to recently used files and technology in it.
I have no root privileges! How can this happen?!


  • @stolbikov The magic of Unix :)

    Well the explanation is that Klayout keeps backups now - which was requested by some users who lost their work due to network issues while saving.

    So what KLayout does is: when you save something, the existing file is first renamed and then the new data is written. KLayout keeps a specified number of backups, so you can disable backups entirely if you set this count to 0 like here:

    Back to the original question: as KLayout renames the original file but does not touch it, it can do so even if the file is not writeable. In fact the file isn't changed - it's moved. To prevent that you can simple take away write permissions on the directory you keep the configurations in. That will prevent KLayout from renaming the file or creating new ones.

    Kind regards,


  • @Matthias, thank you for reply!

    klayoutrc file is not moved! KLayout is not enable to rename it and it returns the corresponding warning:
    "Warning: Could not create backup file: unable to rename original file '/klayoutrc' to backup file"

    And KLayout namely somehow touch klayoutrc file and overwrites (or maybe re-creates) it.
    And there are no write permissions of the directory where klayoutrc file is located an all files in it:

    dr-xr-xr-x 5 stolbikov memcom_tools 7 Aug 9 14:33 KLayout/

    KLayout/$ ls -l
    total 118
    dr-xr-xr-x 2 stolbikov memcom_tools 2 Oct 2 2015 drc/
    dr-xr-xr-x 9 stolbikov memcom_tools 10 Apr 29 17:12 klayout_lypgen/
    -r--r--r-- 1 stolbikov memcom_tools 133044 Aug 17 16:22 klayoutrc
    -r--r--r-- 1 stolbikov memcom_tools 132859 Aug 13 17:50 klayoutrc_initial
    dr-xr-xr-x 11 stolbikov memcom_tools 11 Aug 9 11:29 tech/

  • edited August 2021

    @stolbikov Why is the path in the error message starting with a slash ("/klayoutrc")? You say you're calling with "klayout -c $KLAYOUT_BASE_PATH/klayoutrc" ... so maybe "$KLAYOUT_PATH_PATH" isn't set?

    Basically no user-space tool can change a read-only directory. So the explanation must be something else.

  • @Matthias
    There is really full path to klayoutrc in the warning:
    "Warning: Could not create backup file: unable to rename original file '/proj/memcom/memcom_tools/KLayout/klayoutrc' to backup file"

    And KLAYOUT_BASE_PATH variable set correctly. Otherwise the klayoutrc file would not have been found, implemented and overwritten.

    klayout binary is installed in /bin/klayout by root.

  • @stolbikov I have only one explanation left: maybe /bin/klayout has the SUID bit set (for an explanation see here:

    If that's the case, this would explain why KLayout can modify a read-only directory, but the bit should be removed immediately. That would be a security hole the size of a barn door.


Sign In or Register to comment.