cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Init Script Failing

semsim
Contributor

I am getting an error when I try to run the cluster scoped init script. The script itself is as follows:

#!/bin/bash

sudo apt update && sudo apt upgrade -y

sudo apt install libreoffice-common libreoffice-java-common libreoffice-writer openjdk-8-jre-headless -y

below you can find the error message:

Init script failure:
Cluster scoped init script <path to .sh file> failed: Script exit status is non-zero

I've tried uploading the .sh via databricks CLI. I have also read about enabling logging which would be nice to get some help with.

Thanks for your help and time. 

1 ACCEPTED SOLUTION

Accepted Solutions

semsim
Contributor

The following code solved my problem: 

sudo rm -r /var/lib/apt/lists/* 
sudo apt clean && sudo apt update --fix-missing -y
*add apt statement for library you're trying to install*

This allowed me to successfully spin up the cluster every time using init scripts.

View solution in original post

8 REPLIES 8

SashankKotta
New Contributor III
New Contributor III

It is failing with exit status non-zero, which means the issue is in the init script file; please ensure there are no control-m chars in your init script sh file. you can run 

dos2unix <init_scrip_shell_file>

 or manually remove control-m chars in vi editor and upload. It should work.

Ideally, It is recommended to use custom compute cluster policies for any library installation instead of init scripts.

Sashank Kotta

jacovangelder
Contributor III

Most likely your init script has windows line endings.
Open it in VSCode and change the line endings to Unix (LF) line endings. 

semsim
Contributor

@jacovangelder @SashankKotta ,

Is that all it could be? I've double checked the line endings and it is LF with no ^M chars. I took the file directly from WSL and uploaded it to DBFS.and it is still failing with a non-zero exit status.

jacovangelder
Contributor III

Did some debugging for you. It works for me using this

#!/bin/bash

sudo apt update && sudo apt upgrade -y
sudo apt-get install libreoffice-common libreoffice-java-common libreoffice-writer openjdk-8-jre-headless -y

Not sure why apt get works and apt install doesn't
Btw, Init scripts on DBFS are being deprecated any moment now. Best update to Workspace files or a UC volume. 

@jacovangelder  That does not seem to do it for me either. I have updated the location of the init script to be a workspace location rather than DBFS.

You're right, it doesn't work. Not sure why my cluster was showing up as running last night, most likely something caching related. I'll try to jump into it at some later point if I have some time. Very strange!

Could you elaborate on the caching idea?

Thanks

semsim
Contributor

The following code solved my problem: 

sudo rm -r /var/lib/apt/lists/* 
sudo apt clean && sudo apt update --fix-missing -y
*add apt statement for library you're trying to install*

This allowed me to successfully spin up the cluster every time using init scripts.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!