Description: I have developed an snap app that includes both install and remove hooks. The install hook successfully creates a directory during installation, while the remove hook is supposed to remove this directory upon uninstallation. However, I'm encountering a problem where the remove hook fails to remove the directory due to insufficient permissions.
Here is how my working install script looks:
Â
# Copies configuration file 'app.conf' into current 'Active Configuration'
APP_DIR=$SNAP_COMMON/solutions/activeConfiguration/my-app/app
if [ ! -d "$APP_DIR" ]; then
echo "Creating directory at $APP_DIR"
mkdir -p $APP_DIR
fi
cp $SNAP/config/app.conf $APP_DIR/app.conf
chmod 666 $APP_DIR/app.confÂ
Here is my remove script (that doesn't work):
# Remove the active configuration directory APP_DIR=$SNAP_COMMON/solutions/activeConfiguration/my-app if [ -d "$APP_DIR" ]; then echo "Removing active configuration directory from $APP_DIR" if rm -rf "$APP_DIR"; then echo "Directory removed successfully" else echo "Failed to remove directory" exit 1 fi else echo "Active configuration directory does not exist at $APP_DIR" fi
The final output from the remove script is :
snap.d service: /snap/my-app/x1/meta/hooks/remove: 19: Permission denied
Failed to remove directory
Â
Additional info:
- Build environment: Ubuntu 20.04
- Snap base: core20
- CtrlX Core Virtual version: 1.20.9
- CtrlX Works version: 1.20.5
How do I solve this issue this issue, why the $APP_DIR directory cannot be removed?