dwyl / learn-circleci

:white_check_mark: A quick intro to Circle CI (Continuous Integration) for JavaScript developers.
GNU General Public License v3.0
121 stars 22 forks source link

CircleCI /bin/bash: sudo: command not found #12

Closed nelsonic closed 6 years ago

nelsonic commented 6 years ago

It should be possible to run sudo commands on CircleCI ... see: https://circleci.com/blog/sudo-circleci-make-me-a-sandwich 🤔

However we are getting an error: image

lrwxrwxrwx 1 root root 4 Nov  8  2014 /bin/sh -> dash
/bin/bash: sudo: command not found
Exited with code 127

image

E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Exited with code 100

The super annoying thing is that this works flawlessly on one of our projects: image

🙄 😖

nelsonic commented 6 years ago

solved by including the following lines in the .circleci/config.yml file:

      # Use BASH instead of DASH! see: https://ubuntuforums.org/showthread.php?t=1932504
      - run: apt-get install -y sudo # https://discuss.circleci.com/t/sudo-command-not-found/14208/4
      - run: ls -al /bin/sh && sudo rm /bin/sh && sudo ln -s /bin/bash /bin/sh && ls -al /bin/sh

i.e. we have to install sudo ...!