41

when i try to run git-all-secrets i got Dockerfile: command not found and this is the command include correct information

here is an example of the issue

root@momo22:/home/momo/git-all-secrets# docker run -it abhartiya/tools_gitallsecrets -token=9a8b60a10cf683f238e05 -org=bugcrwod
Command 'docker' is available in '/snap/bin/docker'
The command could not be located because '/snap/bin' is not included in the PATH environment variable.
docker: command not found
root@momo22:/home/momo/git-all-secrets# 
mchawre
  • 10,744
  • 4
  • 35
  • 57
ELMO
  • 581
  • 2
  • 5
  • 7
  • what os? and what are the results of: "whereis docker"? – Michael Hobbs Jul 20 '19 at 22:40
  • I have the same error when running docker on ubuntu 18.04 . I have chosen the docker to be installed during the installation of the server – TudorIftimie Aug 04 '19 at 20:50
  • I can confirm that even on Ubuntu 20.04 the case is consistent with the user above, docker gets installed into `/snap/bin` and not added to $PATH, see answers below on how to do it. – CvRChameleon Jul 08 '20 at 13:16

6 Answers6

85

Temporary solution:

Run the command export PATH=$PATH:/snap/bin

Permanent solution:

Edit /etc/environment and add /snap/bin in the list then restart your system.

Links

answer for similar error with same fix
More info on /etc/enviroment

Jonathan Beaudoin
  • 2,158
  • 4
  • 27
  • 63
Harry S
  • 985
  • 5
  • 6
  • 12
    No need to restart the system. Just use `source /etc/environment` – C.J. Jul 02 '20 at 15:48
  • This /snap/bin already in /etc/environment list, I am trying to open project which stored on my external harddisk. If i open new terminal, and changing path to the directory, code . command working fine – MUHAMMAD SHAHID RAFI C P Oct 20 '21 at 18:29
  • 1
    Strange this has so many upvotes, as written this is incomplete and doesn't work especially if the environment file is empty. See Jay Harry's solution. – Gisto Mar 29 '22 at 21:05
24

you can add the path into .bashrc file

$ echo 'export PATH=$PATH:/snap/bin' >> ~/.bashrc

open new terminal or execute this command

$ source ~/.bashrc

Jika
  • 365
  • 3
  • 10
17

To fix this issue do the following:

  1. Open the file /etc/environment.
  2. Add /snap/bin to the end of the PATH Variable and concatenate using the : character.

    Example lets assume we had the PATH variable in the file was: Path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"

    After your update this will look like: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/snap/bin

  3. Finally to update your shell and have the PATH variable ready to use, run source /etc/environment
  4. Done
Jay Harry
  • 191
  • 1
  • 4
0

If you come here and are just on Ubuntu rather than docker and you have just installed snapd without logging out/in again, log out then in again - you don't need to modify any files.

AntonOfTheWoods
  • 809
  • 13
  • 17
0
  1. Open the ~/.bashrc with nano or vim => vim ~/.bashrc
  2. add export PATH=$PATH:/snap/bin at the end of the file
  3. log out from your user and log in again or reboot

if ~/.bashrc doesn't exist:

  1. create ~/.bashrc file and open it => touch ~/.bashrc && vim ~/.bashrc
  2. add PATH=$PATH:/snap/bin
  3. logout from your user and login again or reboot

if you don't want to logout or reboot run these commands:

  1. sudo su ${USER}
  2. bash
Masoud Aghaei
  • 775
  • 7
  • 20
0
  • open ~/.bash_profile
  • add export PATH=$PATH:/snap/bin and save the changes
  • run source ~/.bash_profile

you can open ~/.bash_profile with vi or gedit