Cocos installation: command not found

Hi friends,

I am trying to start with cocos2d-x. I have done all steps from video tutorials and readMe file of cocos.

Here is my my steps. All is done well. But command line ‘cocos’ does not work.
-bash: cocos: command not found

1 Like

These are not official Cocos2d-x tutorials.

http://cocos2d-x.org/docs/static-pages/installation.html

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/setup.py” 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
/Users/IzzyMachado/Desktop/AndroidGameDev/apache-ant-1.10.1/bin

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

BP

Your $COCOS_X_ROOT is wrong

export COCOS_X_ROOT=~/cocos2d-x
export PATH=$COCOS_X_ROOT:$PATH

export COCOS_CONSOLE_ROOT=~/cocos2d-x/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH

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 GitHub - KAMIKAZEUA/SpriteBuilderX: SpriteBuilderX for Cocos2D-X

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.