9

Trying to get the new Force.com CLI to work which was apparently more than my post DF13 brain can handle. On OSX/Mavericks and downloaded the precompiled binary from here: https://github.com/heroku/force

Open up Terminal, type force, and get this error:

-bash: force: command not found

Is there some other pre-requisite I need etc?

  • Did you add it to your path? – Mike Chale Nov 22 '13 at 19:14
10

It hasn't been added to your path yet, so your terminal doesn't know where to find the application.

See their fix, Fix path to source after running go get:

Change line 49 to $ cd $GOPATH/src/github.com/heroku/force

Other options:

  1. Ensure the file's permissions are set to be executable. Run ls -l in the folder to verify.

  2. If you are in your Terminal (or other CLI of choice), you can navigate to the folder where the binary is. You should then be able to invoke it with ./ notation:

    ./force login
    
| improve this answer | |
  • Even if I am just running the pre-compiled version (i.e. just one file)? – BritishBoyinDC Nov 22 '13 at 19:26
  • Yes. The pre-compiled version gives you the binary, but unless you're in that specific folder the command-line won't know where the binary is unless it's added to the path. – Mike Chale Nov 22 '13 at 19:43
  • Thanks - so quick updates - I CAN get it to work in Windows - I download the exe, open cmd, navigate to folder where exe is, type force login, and the oAuth process is invoked (though only if use Chrome) and I can then use the CLI. In OSX, if I am in the actual folder in Terminal where the force binary is, shouldn't it work the same way? Or do I still need to add that directory to my PATH? – BritishBoyinDC Nov 22 '13 at 20:14
  • So you got me there! I tried the .\force login and no joy, but then I moved the file to /usr/bin/ which is in the PATH variable, and it worked first time - thanks! – BritishBoyinDC Nov 22 '13 at 20:50
  • I probably meant to say ./ (I get confused jumping between Windows and *nix). – Mike Chale Nov 22 '13 at 21:01
5

On Unix systems - MacOSX and Ubuntu, etc - you need to make the file you downloaded executable (the file is the pre-compiled Go app for your operating system). In the directory where your downloaded file is, use the command:

chmod a+x force

Alternatively, you can run the command sh ./force without making the file executable, but that gets tiring after a while.

To run the force command anywhere and not just from the directory it lives in, you should add the path of the directory that contains force to your operating system execution path (as mentioned in previous comments).

In windows you can add the full path to the directory containing the force file in the environment variable called PATH (using the Windows control panel).

In Unix systems (MacOSX, Ubuntu, etc), you can add the full path to the directory containing the force file to your .profile - a file located in the root of your home directory eg /home/jr0cket/.profile

For simple apps, I create a bin directory in the root of my home folder, eg /home/jr0cket/bin. I put the force file in this directory and add the following line to my .profile.

export PATH=$PATH:~/bin

This adds any file in my bin folder to my execution path, so I can run them from any directory.

The ~ character is a shortcut for the root of my home directory, /home/jr0cket

Thank you.

John - http://jr0cket.co.uk

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.