Cakephp Cake command returns No such file or directory

后端 未结 5 1046

I have been using the cake command on my linux server for 2 years. but now im trying to move to a new server and some how the cake command gives back the error: No such file or

相关标签:
5条回答
  • 2021-02-10 09:37

    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!

    0 讨论(0)
  • 2021-02-10 09:37

    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.

    0 讨论(0)
  • 2021-02-10 09:42

    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

    0 讨论(0)
  • 2021-02-10 09:43

    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.

    0 讨论(0)
  • 2021-02-10 10:03

    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
    
    0 讨论(0)
提交回复
热议问题