- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recently installed an update for the above package via apt. I get the following error:
Preparing to unpack .../intel-oneapi-runtime-opencl_2025.1.0-973_amd64.deb ...
dpkg: warning: old intel-oneapi-runtime-opencl package pre-removal script subprocess returned error exit status 2
dpkg: trying script from the new package instead ...
dpkg: error processing archive /var/cache/apt/archives/intel-oneapi-runtime-opencl_2025.1.0-973_amd64.deb (--unpack):
new intel-oneapi-runtime-opencl package pre-removal script subprocess returned error exit status 2
openCL has already registered, skipping update-alternatives ...
update-alternatives: warning: forcing reinstallation of alternative /opt/intel/oneapi/redist because link group opencl-intel-runtime is broken
Errors were encountered while processing:
/var/cache/apt/archives/intel-oneapi-runtime-opencl_2025.1.0-973_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
it seem maybe the package fails to unpack
Now apt is broken and I can't update anything n the system.
My system is running Mint Linux 21.1 (which is based on Ubuntu 22.04)
How do I fix this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For anyone else struggling with this, replace the script mentioned in the previous post with something like the following and you will be able to fix your installation. I also comment out the dangerous "rmdir /etc" to avoid that possibility.
#!/bin/bash
# Copyright Intel Corporation.
#
# This software and the related documents are Intel copyrighted materials,
# and your use of them is governed by the express license under which they
# were provided to you ("License"). Unless the License provides otherwise,
# you may not use, modify, copy, publish, distribute, disclose or transmit
# this software or the related documents without Intel's prior written
# permission.
#
# This software and the related documents are provided as is, with no express
# or implied warranties, other than those that are expressly stated in the
# License.
INSTALL_DIR=/opt/intel/oneapi/redist
#
# If post-install script failed to install alternative, uninstalling package also fails, because
# 'update-alternatives' cannot remove non-existing alternative. Let us check the alternative
# exists before removing it.
#
#remove_alternative() {
# update-alternatives --display "$1" &>/dev/null
# if [ $? = 0 ]; then
# update-alternatives --remove "$1" "$2"
# else
# echo "Alternative for $1 is not found, skipping ..."
# fi
#}
remove_alternative() {
if update-alternatives --display "$1" &>/dev/null; then
update-alternatives --remove "$1" "$2"
else
echo "Alternative for $1 is not found, skipping ..."
fi
}
set -e
LIB_OPENCL_SO=`find "${INSTALL_DIR}" -name "libOpenCL.so"`
if [ "${LIB_OPENCL_SO}" ]; then
remove_alternative opencl-libOpenCL.so "${LIB_OPENCL_SO}"
fi
LIB_INSTALL_DIR="${INSTALL_DIR}"
remove_alternative opencl-intel-runtime "${LIB_INSTALL_DIR}"
if [ -e "/etc/OpenCL/vendors" ] ; then
rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
if [ -z "$(ls -A /etc)" ] ; then
# rmdir "/etc" 2>/dev/null
fi
fi
exit 0
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The root cause of the problem is the pre-removal script which contains a silly error, and some crazy stuff which I hope is removed in the new version.
I mean this script
/var/lib/dpkg/info/intel-oneapi-runtime-opencl.prerm
the script fails because it sets set -e in the body, but also contains the following function at the top
remove_alternative() {
update-alternatives --display "$1" &>/dev/null
if [ $? = 0 ]; then
update-alternatives --remove "$1" "$2"
else
echo "Alternative for $1 is not found, skipping ..."
fi
}
when the following command in this function returns a non-zero exit code the script exits and returns that exit code:
update-alternatives --display "$1" &>/dev/null
Now, as for the crazy stuff, there's also the following snippet:
if [ -e "/etc/OpenCL/vendors" ] ; then
rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
if [ -z "$(ls -A /etc)" ] ; then
rmdir "/etc" 2>/dev/null
fi
fi
So there's some possibility this script will decide to just go delete /etc !!!! WTF?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For anyone else struggling with this, replace the script mentioned in the previous post with something like the following and you will be able to fix your installation. I also comment out the dangerous "rmdir /etc" to avoid that possibility.
#!/bin/bash
# Copyright Intel Corporation.
#
# This software and the related documents are Intel copyrighted materials,
# and your use of them is governed by the express license under which they
# were provided to you ("License"). Unless the License provides otherwise,
# you may not use, modify, copy, publish, distribute, disclose or transmit
# this software or the related documents without Intel's prior written
# permission.
#
# This software and the related documents are provided as is, with no express
# or implied warranties, other than those that are expressly stated in the
# License.
INSTALL_DIR=/opt/intel/oneapi/redist
#
# If post-install script failed to install alternative, uninstalling package also fails, because
# 'update-alternatives' cannot remove non-existing alternative. Let us check the alternative
# exists before removing it.
#
#remove_alternative() {
# update-alternatives --display "$1" &>/dev/null
# if [ $? = 0 ]; then
# update-alternatives --remove "$1" "$2"
# else
# echo "Alternative for $1 is not found, skipping ..."
# fi
#}
remove_alternative() {
if update-alternatives --display "$1" &>/dev/null; then
update-alternatives --remove "$1" "$2"
else
echo "Alternative for $1 is not found, skipping ..."
fi
}
set -e
LIB_OPENCL_SO=`find "${INSTALL_DIR}" -name "libOpenCL.so"`
if [ "${LIB_OPENCL_SO}" ]; then
remove_alternative opencl-libOpenCL.so "${LIB_OPENCL_SO}"
fi
LIB_INSTALL_DIR="${INSTALL_DIR}"
remove_alternative opencl-intel-runtime "${LIB_INSTALL_DIR}"
if [ -e "/etc/OpenCL/vendors" ] ; then
rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
if [ -z "$(ls -A /etc)" ] ; then
# rmdir "/etc" 2>/dev/null
fi
fi
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
consider changing....
if [ -e "/etc/OpenCL/vendors" ] ; then
rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
if [ -z "$(ls -A /etc)" ] ; then
# rmdir "/etc" 2>/dev/null
fi
fi
to...
if [ -e "/etc/OpenCL/vendors" ] ; then
rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
# if [ -z "$(ls -A /etc)" ] ; then
# rmdir "/etc" 2>/dev/null
# fi
fi
just bc some shell's might get cranky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, here's the full updated script for my own reference and others:
#!/bin/bash
# Copyright Intel Corporation.
#
# This software and the related documents are Intel copyrighted materials,
# and your use of them is governed by the express license under which they
# were provided to you ("License"). Unless the License provides otherwise,
# you may not use, modify, copy, publish, distribute, disclose or transmit
# this software or the related documents without Intel's prior written
# permission.
#
# This software and the related documents are provided as is, with no express
# or implied warranties, other than those that are expressly stated in the
# License.
INSTALL_DIR=/opt/intel/oneapi/redist
#
# If post-install script failed to install alternative, uninstalling package also fails, because
# 'update-alternatives' cannot remove non-existing alternative. Let us check the alternative
# exists before removing it.
#
#remove_alternative() {
# update-alternatives --display "$1" &>/dev/null
# if [ $? = 0 ]; then
# update-alternatives --remove "$1" "$2"
# else
# echo "Alternative for $1 is not found, skipping ..."
# fi
#}
remove_alternative() {
if update-alternatives --display "$1" &>/dev/null; then
update-alternatives --remove "$1" "$2"
else
echo "Alternative for $1 is not found, skipping ..."
fi
}
set -e
LIB_OPENCL_SO=`find "${INSTALL_DIR}" -name "libOpenCL.so"`
if [ "${LIB_OPENCL_SO}" ]; then
remove_alternative opencl-libOpenCL.so "${LIB_OPENCL_SO}"
fi
LIB_INSTALL_DIR="${INSTALL_DIR}"
remove_alternative opencl-intel-runtime "${LIB_INSTALL_DIR}"
if [ -e "/etc/OpenCL/vendors" ] ; then
rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
# if [ -z "$(ls -A /etc)" ] ; then
# rmdir "/etc" 2>/dev/null
# fi
fi
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Richard, we hope you are doing great!
Could you kindly confirm whether your issue has been resolved, or if you require further assistance from Intel®? This will enable us to investigate further or direct your request to the higher team for additional assistance.
Have a great day ahead!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The immediate problem is solved for me personally, but the general issue should be escalated to the development team for investigation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Richard, thank you for your response.
We would like to inform you that we are routing your query to the dedicated team for further assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your investigation. We have reported the issue to the related team and will let you know when we have any updates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
New update has been pushed out, and the issue is still present, and broken my package manager again.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page