首页 / 帖子
drush 只能用drush dl 、cc all 二条命令,其它的都报同一个错误

[root@AY1403072133429290dbZ www.penghuajun.com]# drush en views -y
Command pm-enable needs a higher bootstrap level to run - you    [error]
will need to invoke drush from a more functional Drupal
environment to run this command.
The drush command 'en views' could not be executed.              [error]
Drush was not able to start (bootstrap) the Drupal database.     [error]
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have
a configured database. In this case you can select another site
with a working database setup by specifying the URI to use with
the --uri parameter on the command line. See `drush topic
docs-aliases` for details.
 * connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell.
See http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
 Drupal version         :  7.32                                 
 Site URI               :  http://default                       
 Database driver        :  mysql                                
 Database username      :  root                                 
 Database name          :  drupal7                              
 Default theme          :  garland                              
 Administration theme   :  garland                              
 PHP executable         :  /usr/bin/php                         
 PHP configuration      :  /etc/php.ini                         
 PHP OS                 :  Linux                                
 Drush version          :  6.2.0                                
 Drush configuration    :                                       
 Drush alias files      :  /usr/share/pear/drush/includes/../al
                           iases.drushrc.php                    
 Drupal root            :  /data/wwwroot/www.penghuajun.com     
 Site path              :  sites/default                        
 File directory path    :  sites/default/files

4个答案
AnnyO
发布于:2014-10-30 22:56

错误原因是执行drush命令必须在drupal的安装目录下,安装目录的意思是drupal网站已经安装,包括数据库,不仅仅是drupal代码。

YOYO
发布于:2014-10-31 05:36

我是用pear安装的drush 我在pear里找到了drush目录,但是执行命令却和安装目录不在同一个位置,下面是我分别在 安装目录下执行命令报错如下:

[root@AY1403072133429290dbZ pear]# cd drush/
[root@AY1403072133429290dbZ drush]# drush dis views
Command pm-disable needs a higher bootstrap level to run - you   [error]
will need to invoke drush from a more functional Drupal
environment to run this command.
The drush command 'dis views' could not be executed.             [error]
A Drupal installation directory could not be found               [error]


命令所在目录下执行命令报错如下:

[root@AY1403072133429290dbZ drush]# which drush
/usr/bin/drush
[root@AY1403072133429290dbZ drush]# cd /usr/bin
[root@AY1403072133429290dbZ bin]# drush dis views
Command pm-disable needs a higher bootstrap level to run - you   [error]
will need to invoke drush from a more functional Drupal
environment to run this command.
The drush command 'dis views' could not be executed.             [error]
A Drupal installation directory could not be found               [error]


网站根目录下执行报错,在第一楼


pear 所在目录:

[root@AY1403072133429290dbZ bin]# whereis pear
pear: /usr/bin/pear /etc/pear /etc/pear.conf /usr/share/pear

drush 安装目录在pear目录里


drush可执行文件在bin里

[root@AY1403072133429290dbZ bin]# whereis drush
drush: /usr/bin/drush.bat /usr/bin/drush

刘伯彪
发布于:2014-10-31 22:51

你应该在Drupal的目录下执行Drush,而不是在Drush的目录下执行。

陈蹊
发布于:2014-11-03 16:19

还有一个原因就是drush版本有问题,或者安装方式有问题。
你可以直接下载drush安装一下试试!

或者通过apt或者yum方式安装一下。