cloudflared icon indicating copy to clipboard operation
cloudflared copied to clipboard

RPM update fails with "ln: failed to create symbolic link '/usr/local/bin/cloudflared': File exists"

Open Maciej-Sitarz-IBM opened this issue 3 years ago • 1 comments

Describe the bug During cloudflared RPM package upgrade the process fails with error:

ln: failed to create symbolic link '/usr/local/bin/cloudflared': File exists
warning: %post(cloudflared-2022.3.3-1.x86_64) scriptlet failed, exit status 1

Whole install log from DNF can be found below.

To Reproduce Steps to reproduce the behavior:

  1. Install cloudflared-2022.2.2-1.x86_64
  2. Try to install cloudflared-2022.3.3-1.x86_64
  3. See error

Expected behavior RPM should be properly updated

Environment and versions

  • OS: Red Hat Enterprise Linux release 8.5 (Ootpa
  • Architecture: x86_64
  • Version: 2022.2.2 , 2022.3.3

Logs and errors

# dnf localinstall https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-x86_64.rpm
Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                                                                                                                                                        26 kB/s | 2.4 kB     00:00    
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                                                                                                                                                     34 kB/s | 2.8 kB     00:00    
cloudflared-linux-x86_64.rpm                                                                                                                                                                                 12 MB/s |  14 MB     00:01    
Dependencies resolved.
============================================================================================================================================================================================================================================
 Package                                                   Architecture                                         Version                                                    Repository                                                  Size
============================================================================================================================================================================================================================================
Upgrading:
 cloudflared                                               x86_64                                               2022.3.3-1                                                 @commandline                                                14 M

Transaction Summary
============================================================================================================================================================================================================================================
Upgrade  1 Package

Total size: 14 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                    1/1 
  Upgrading        : cloudflared-2022.3.3-1.x86_64                                                                                                                                                                                      1/2 
  Running scriptlet: cloudflared-2022.3.3-1.x86_64                                                                                                                                                                                      1/2 
ln: failed to create symbolic link '/usr/local/bin/cloudflared': File exists
warning: %post(cloudflared-2022.3.3-1.x86_64) scriptlet failed, exit status 1

Error in POSTIN scriptlet in rpm package cloudflared
  Cleanup          : cloudflared-2022.2.2-1.x86_64                                                                                                                                                                                      2/2 
  Running scriptlet: cloudflared-2022.2.2-1.x86_64                                                                                                                                                                                      2/2 
  Verifying        : cloudflared-2022.3.3-1.x86_64                                                                                                                                                                                      1/2 
  Verifying        : cloudflared-2022.2.2-1.x86_64                                                                                                                                                                                      2/2 
Installed products updated.

Upgraded:
  cloudflared-2022.3.3-1.x86_64                                                                                                                                                                                                             

Complete!
[root@msi-wdp-tunnels-1 ~]# rpm -ql cloudflared
/usr/bin/cloudflared
/usr/share/man/man1/cloudflared.1

Additional context After the upgrade the cloudflared was not working. As a fix and workaround for update I removed the package and reinstalled.

Maciej-Sitarz-IBM avatar Mar 24 '22 12:03 Maciej-Sitarz-IBM

Currently postuninstall script removes the link and the postinstall script creates the link. This code seems to assume that postinstall runs after postuninstall, but it actually runs in the reverse order, so the /usr/local/bin/cloudflared link ends up being deleted. This postinstall/postuninstall scripts need to be improved.

shinera avatar Mar 19 '24 01:03 shinera