Orignal code, meant for Ubuntu:

./rebar get-deps
./rebar compile

When I try:

sh start.sh
start.sh: line 5: ./rebar: No such file or directory

The fix is simple, just remove ./

But how to make the script running both on Ubuntu and Mac without forcing user to make any changes?

EDIT / UPDATE: rebar is Erlang tool installed via brew install rebar

Here is the original start.sh file: https://github.com/aeternity/testnet/blob/master/start.sh

I think it's difference between Mac and Ubuntu - the script supposedly works on Ubuntu (didn't have a chance to try) - while on Mac I had to remove ./ (I need to check on Ubuntu myself)

  • 1
    I think you need to give us a little more info. Is rebar a script that is in the same directory as start.sh? Or is rebar a program available in your $PATH? Is the "original code" part of that start.sh script? What are the permissions of the respective files? (Can you post a minimal version of the start.sh script?) What you describe doesn't seem to be a problem caused by a difference between macOS and Linux. – slhck Apr 8 '17 at 8:26

./rebar is adressing the file in the present workdirectory, only. Starting rebar forces a look-up in the directories in your PATH environment.

If these are the only two options you may add to your script:

[ -x ./rebar ] && REBAR="./rebar"   # check if rebar is in pwd

$REBAR get-deps
$REBAR compile 

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.