Particle CLI not working

I used the links on the particle website to create the command line for my particle electron, but I was unable to run anything on the command line. Below is one example of the error that keeps on approaching when I try to run anything with the particle command.

First, see if it installed correctly:

~/bin/particle login

If that doesn’t give a command not found error, then you just need to fix your PATH.

The .profile file in your home directory should have this in it (usually at the end):

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

If not, you should add it. Then reload it.

source ~/.profile

That should fix the problem, unless you are using an alternate shell like zsh.

1 Like

I can't get the CLI to work on Mac OS Mojave. I've installed it using the curl command in the docs, and I got the welcome message. I see the particle executable in ~/bin. Trying to login from that directory, I get
"-bash: particle: command not found"

rics-iMac:bin ricdelmar$ pwd
/Users/ricdelmar/bin
rics-iMac:bin ricdelmar$ ls
particle
rics-iMac:bin ricdelmar$ particle login
-bash: particle: command not found

If you are in the bin directory you probably will need to use ./particle login to use the particle command in the current directory.

Thanks, that worked. I was unaware that you couldn’t run an app from the directory it’s in without that. I fixed my PATH variable using the instructions you wrote above, and now it works from my home directory.

I don’t know why this has to be so difficult. I tried to install it with ā€œnpm install -g particle-cliā€, and all the fixes (some that worked before) in this post, but they all gave me many errors. I’ll probably be back the next time I need to update the CLI to the latest version because that always goes badly. Unless there is a new, better way to update, I assume I’ll run into the same problems next time.

Definitely don’t use the npm update command on the Mac if you’ve use the CLI installer bash command, instead just do:

particle update-cli

All of a sudden I’ve got this error where the ā€˜particle’ command from the terminal on my Mac is suddenly unrecognised. Weird.

booms-MacBook-Pro:parlour dac$ particle compile photon .
-bash: particle: command not found
booms-MacBook-Pro:parlour dac$ sudo ln -s /usr/local/lib/particle-cli/bin/particle.js /usr/local/bin/particle
ln: /usr/local/bin/particle: File exists
booms-MacBook-Pro:parlour dac$ particle update-cli
-bash: particle: command not found
booms-MacBook-Pro:parlour dac$ 
booms-MacBook-Pro:parlour dac$ ~/bin/particle login
-bash: /Users/dac/bin/particle: No such file or directory
booms-MacBook-Pro:parlour dac$

Running ā€œbash <( curl -sL https://particle.io/install-cli )ā€ fixed it.