Shell command fails with error: "Exited with code 1"


#1

That message is not helpful. How can I figure out what the real error is?

https://circleci.com/gh/elegantthemes/submodule-builder/2700


#2

I was able to fix this using the following:

      - type: shell
        command: |
          "[[ -d ${HOME}/Divi ]] && mv ${HOME}/Divi /tmp"

Please give it a shot and let us know how it goes.


#3

Hmm…nope. I tried it with and without the shell key set:

https://circleci.com/gh/elegantthemes/submodule-builder/2701
https://circleci.com/gh/elegantthemes/submodule-builder/2702


#4

The conditional says that if the $HOME/Divi directory exists than move it to /tmp. It is not able to find the directory and is failing as it should. The $HOME directory is set to /root as you are running as the root user.

In build 2702, you set the workdir as /root/submodule-builder which is where your git repo will be cloned to. The Divi folder would then be inside /root/submodule-builder/Divi if it is present in your repo.

I would try

- type: shell
        command: |
          "[[ -d /root/submodule-builder/Divi ]] && mv $/root/submodule-builder/Divi /tmp"

#5

I made that change when I noticed that $HOME was set to /root. However its not relevant really. If the directory does not exist (which in this case it doesn’t) then the second part of the command should not be executed.

[[ -d /root/Divi ]] && mv /root/Divi /tmp

#6

Figured it out. Bash wasnt installed. The not found error was referring to bash :doh: Still I had to modify the command to get it to work after fixing the bash issue. Here’s what is working:

"{ [[ -d ${HOME}/workDir/Divi ]] && mv ${HOME}/workDir/Divi /tmp; } || true"

Cheers!


#7

Awesome news! Thank you for providing the solution. I hope it will help someone else out. :grin:


#8