Shell Compatibility Issue in Nexus Repository 3.78.2-04 Startup Script - Sonatype Nexus Repository - Sonatype Community
Shell Compatibility Issue in Nexus Repository 3.78.2-04 Startup Script
Environment
- Nexus Repository: 3.78.2-04 (Community Edition)
- OS: Debian 12.10
Issue
During service startup, the following error appears:
/opt/nexus-3.78.2-04/bin/nexus: 155: [[: not found
Root Cause
The startup script (bin/nexus) uses bash-specific syntax with /bin/sh shebang:
#!/bin/sh
# ...
if [[ "$data_dir" != /* ]]; then # Line 155
data_dir="$PARENT/$data_dir"
fi
On systems where /bin/sh links to a POSIX-compliant shell like dash, the [[ syntax is unsupported.
Reproduction
Standard startup via systemd produces the error:
Mar 20 21:33:46 host systemd[1]: Starting nexus.service - nexus service...
Mar 20 21:33:46 host nexus[92263]: /opt/nexus-3.78.2-04/bin/nexus: 155: [[: not found
Mar 20 21:33:46 host nexus[92263]: Starting nexus
Mar 20 21:33:46 host systemd[1]: Started nexus.service - nexus service.
Proposed Solutions
- Change shebang from
#!/bin/shto#!/bin/bash
OR
- Replace bash-specific syntax with POSIX-compliant case statement:
case "$data_dir" in
/*)
;;
*)
data_dir="$PARENT/$data_dir"
;;
esac
Impact
The issue does not prevent service operation but generates unnecessary warnings during startup.
- Startup failure after migrating from 3.73 to 3.78 (alpine custom container)
- Failed to make connection to backend after upgrade to nexus 3.78.2
Further Discussion
Post by WeiterWeiterFertigstellen on Mar 31, 2025
We have the same issue. Will this get fixed someday?
Post by lemonsterfy on Apr 3, 2025
The latest version, nexus-3.84.0-03, has fixed this issue (see NEXUS-46734).
Post by rseddon on Apr 4, 2025
We have opened an issue internally to restore posix compliance to the startup scripts. Since this was just filed I do not have an ETA to provide.