Cocos installation: command not found

What you have to do is exit out of the cocos2d-x directory when you type in the command.
instead of it being “Mac-mini-Alexander: cocos2d-x alexander$ cocos new …”

it should be “Mac-mini-Alexander: ~ alexander$ cocos new …” with out the cocos2d-x part.

this is what works for me

Dont work :confused:

Mac-mini-Alexander:~ alexander$ source /Users/alexander/.bash_profile
Mac-mini-Alexander:~ alexander$ cocos new MyGame -p com.your_company.mygame -l cpp -d /Users/alexander/Desktop/TestGame
-bash: cocos: command not found
Mac-mini-Alexander:~ alexander$

You should try setting it up again but this time when you open the terminal don’t CD into the cocos2dx directory instead just open the terminal and type “/Users/alexander/Desktop/SDK/cocos2d-x/” and let me know what happens ? Similar to what I did here

1 Like

Done, but nothing changed.

thats weird not sure why that could be happening are you using cocos2d-x v3.16 ? Maybe try restarting your computer.

Now the version is 3.13.1 but I tried diferent versions including 3.16

can you try typing “echo $PATH” in your terminal and post what it shows, to see if everything is set up properly I think thats where the problem might be.

Also when i start build through cocos creator i get this log:

FAILURE: Build failed with an exception.

  • What went wrong:
    Gradle 3.3 requires Java 7 or later to run. You are currently using Java 6.

Can it be the issue?

1 Like

The only thing I see so far that does not seem correct is the path you set for your ANT_ROOT you have “/Users/alexander/Desktop/SDK/ANT” there should be a file in ant that looks similar to this. This is what I have

the ANT_ROOT needs the “/bin” at the end of it. After you correct it let me know what happens when you re-install cocos2d-x and then run the cocos command

if you need help changing the environment variable to add “/bin” let me know and I will help.

Nothing new…

can you post your .bash_profile, please


Your $COCOS_X_ROOT is wrong

export COCOS_X_ROOT=~/cocos2d-x

export COCOS_CONSOLE_ROOT=~/cocos2d-x/tools/cocos2d-console/bin

Thanks a lot guys! All OK now!

1 Like

That’s weird I wonder why my “cocos_x_root” worked fine pointing just to the folder cocos2dx was saved in and not the actual cocos2dx folder, and yours didn’t ? @slackmoehrle any idea why that is ?

Not any idea.

1 Like

Sorry friends, it was our mistake, after trying again to find the bug i found that we used not official mode of cocos2dx, it had the same name and version… it confused us and you :confused:

@yoman This problem is not connected at all with SBX. So you should post here. In SBX topic ask anything about SBX, but not setup of cocos.

Your problem is configuration of cocos2d-x. As simple option I’m suggesting you just replace official cocos2d-x with cocos2d-x for SBX. Then just create a project with it.

Actually you need more carefully read instructions from

So it’s whatever using which cocos you will create a project.
Moreover, I’m strongly suggesting you to use pre-built libs as you are on a Mac.

As it part of SBX, i asked in in the right (SBX) theme.

Of course i used

As i wrote the problem in newnon/cocos2d-x, just because in official version - everything works fine.

Ok, i will try to load official version of cocos2dx and upgrade it by newnons

Modified source code of some classed in cocos2d-x for SBX in not related to installation process at all.

Thats kind of logic, but problem actually simple - you did something wrong during installation, check check and again check.