Cakephp Cake command returns No such file or directory

怎甘沉沦 提交于 2019-12-03 08:35:24

I found the solution: All I had to do is use the program dos2unix the cake file for CakePHP 2.4.2 has wrong endings when you download it with Ubuntu 13.10

I used the following command:

sudo dos2unix /path/to/cake/lib/Cake/Console/cake

The REAL solution to this is to change the End-of-Line (EOL) characters to Unix format, instead of MsDos. So I guess this error will only occur if you worked in Windows.

Anyway, teh mighty SOLUTION:

(1) Open app/Console/cake file using any text editor that allows changing of EOL characters e.g. NotePad++.

(2) In NotePad++ click: Edit -> EOL Conversion -> Convert to Unix format

(3) Save the file and upload it to the server. Now if you navigate to the CakePHP app directory using command like:

cd /usr/share/nginx/html/cakeproject/app

...you should be able to run Console/cake without any problems and see standard output (basically help commands).

Hope this helped you!

I also have this problem on some servers and never figured out why this happened. I suspect the so called "shebang" might not be set correctly for every Linux distribution (e.g. if the cake script stars with #!/usr/bin/env bash, but you don't use bash on your server or your distribution doesn't have the env binary in that path, it might fail on that. This is just a theory though, as I said I never really figured it out, nor did I invest much time in investigating.

Although, what I always use as a fallback is simply calling the cake.php script (from the app folder) instead, like:

php Console/cake.php -app `pwd` bake

That never lets me down. The -app pwd bit is to tell the shell that your current directory is your app directory, so the shell can find all your files.

xiankai

I encountered the same problem as well, but the top answer reminded me of a similar problem I faced before: https://stackoverflow.com/a/5514351/1097483

Basically, instead of using dos2unix or installing it, you can open the file in vim, do

:set fileformat=unix

And save it.

Marcus Monteiro

In some versions it's possible to install cake using sudo apt-get install cakephp-scripts.

After instalation, you coud access bake anywere simple by typing bake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!