OS: Mac OSX Lion
Core: D7.8

After a fresh install, (no contributed modules installed), I tested drush, all commands works perfectly.
However after I installed and enabled Views module.
Any PM commands ( dl, en, pml, etc) suddenly failed. I am getting the errors:

Fatal error: Cannot redeclare _views_theme_functions() (previously declared in /xxx/xxx/sites/all/modules/views/theme/theme.inc:20) in /xxx/xxx/sites/all/modules/views/theme/theme.inc on line 35
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Cannot redeclare _views_theme_functions() (previously declared
in
/xxx/xxx/sites/all/modules/views/theme/theme.inc:20)
in
/xxx/xxx/sites/all/modules/views/theme/theme.inc,
line 35

Any ideas? Thanks.

Comments

gilzero’s picture

Just an update of this issue: not only pm commands, also other core commands stop working, generated same errors.

perandre’s picture

Component: PM (dl, en, up ...) » Core Commands

My collegue is having the same issue; I'll report back when fixed.

henrikakselsen’s picture

I'm getting a host of different errors regarding this error. Sorry for the long error messages.

Drush command terminated abnormally due to an unrecoverable error.                             [error]
Error: Cannot redeclare _views_theme_functions() (previously declared in
/Users/henrikakselsen/sites/smb/sites/all/modules/contrib/views/theme/theme.inc:20) in
/Users/henrikakselsen/Sites/smb/sites/all/modules/contrib/views/theme/theme.inc, line 35

I tried to disable views (via drush), and during that attempt I get

Drush command terminated abnormally due to an unrecoverable error.                             [error]
Error: Cannot redeclare class backup_migrate_destination_db in
/Users/henrikakselsen/sites/smb/sites/all/modules/contrib/backup_migrate/includes/destinations.db.inc,
line 294

When I try to disable backup_migrate I get this huge error message:

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array
(
    [:db_insert_placeholder_0] => 0
    [:db_insert_placeholder_1] => menu
    [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file).
    [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:883:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT ml.*, m.load_functions AS load_functions, m.to_arg_functions AS to_arg_functions, m.access_callback AS access_callback, m.access_arguments AS access_arguments, m.page_callback AS page_callback, m.page_arguments AS page_arguments, m.delivery_callback AS delivery_callback, m.tab_parent AS tab_parent, m.tab_root AS tab_root, m.title AS title, m.title_callback AS title_callback, m.title_arguments AS title_arguments, m.theme_callback AS theme_callback, m.theme_arguments AS theme_arguments, m.type AS type, m.description AS description
FROM 
{menu_links} ml
LEFT OUTER JOIN {menu_router} m ON m.path = ml.router_path
WHERE  (ml.menu_name = :db_condition_placeholder_0) 
ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC; Array
(
    [:db_condition_placeholder_0] => navigation
)
";s:9:"%function";s:18:"_menu_build_tree()";s:5:"%file";s:49:"/Users/henrikakselsen/sites/smb/includes/menu.inc";s:5:"%line";i:1372;s:14:"severity_level";i:3;}
    [:db_insert_placeholder_4] => 3
    [:db_insert_placeholder_5] => 
    [:db_insert_placeholder_6] => http://default/index.php
    [:db_insert_placeholder_7] => 
    [:db_insert_placeholder_8] => 127.0.0.1
    [:db_insert_placeholder_9] => 1317649441
)
 in dblog_watchdog() (line 157 of /Users/henrikakselsen/sites/smb/modules/dblog/dblog.module).

The "General error: 2006 MySQL server has gone away" doesn't look very promising, but I've restarted Mysql and Mysql in general seems to be running fine in MAMP so I don't think this is a mysql problem (Other testsites are working as expected). Also the modules get enabled and disabled despite the error messages. (edited for clarification)

gilzero’s picture

So u mean a restart of mysql in MAMP fixed the error?

henrikakselsen’s picture

So u mean a restart of mysql in MAMP fixed the error?

Sorry, that was unclear. No, the site in question still doesn't work after restart. I meant that mysql still works on other mamp sites (at least a test site) so the problem is not that mysql goes down.

Pocketpain’s picture

sub!

himerus’s picture

getting this error on a ton of local installations...

subscribe.

dorianfm’s picture

Similar issue, just loaded in a dump of the mysql database, ran drush pm-refresh.

It looks like themes.inc is being loaded twice, hence why the functions are trying to be redeclared.

This is a stack trace:

Fatal error: Cannot redeclare _views_theme_functions() (previously declared in /Users/dorian/Sites/test/www/sites/all/modules/views/theme/theme.inc:21) in /Users/dorian/sites/test/www/sites/all/modules/views/theme/theme.inc on line 36

Call Stack:
    0.0023     733752   1. {main}() /Users/dorian/Sites/test/drush/drush.php:0
    0.0229    3537904   2. drush_main() /Users/dorian/Sites/test/drush/drush.php:41
    0.5517   44665376   3. drush_dispatch() /Users/dorian/Sites/test/drush/drush.php:101
    0.5518   44668856   4. call_user_func_array() /Users/dorian/Sites/test/drush/includes/command.inc:214
    0.5518   44669104   5. drush_command() /Users/dorian/Sites/test/drush/includes/command.inc:214
    0.5521   44673272   6. _drush_invoke_args() /Users/dorian/Sites/test/drush/includes/command.inc:806
    0.5528   44700640   7. call_user_func_array() /Users/dorian/Sites/test/drush/includes/command.inc:134
    0.5528   44700888   8. drush_pm_refresh() /Users/dorian/Sites/test/drush/includes/command.inc:134
    0.5535   44765104   9. _pm_refresh() /Users/dorian/Sites/test/drush/commands/pm/pm.drush.inc:1539
    0.5538   44765136  10. update_refresh() /Users/dorian/Sites/test/drush/commands/pm/update_info/drupal.inc:45
    0.5546   44898688  11. _update_refresh() /Users/dorian/Sites/test/www/modules/update/update.module:447
    0.5570   45096832  12. update_get_projects() /Users/dorian/Sites/test/www/modules/update/update.fetch.inc:201
    0.5573   45097488  13. system_rebuild_module_data() /Users/dorian/Sites/test/www/modules/update/update.compare.inc:38
    0.5573   45097824  14. _system_rebuild_module_data() /Users/dorian/Sites/test/www/modules/system/system.module:2422
    0.7115   45370848  15. drupal_alter() /Users/dorian/Sites/test/www/modules/system/system.module:2394
    0.7115   45370976  16. field_system_info_alter() /Users/dorian/Sites/test/www/includes/module.inc:1004
    0.7183   46009800  17. l() /Users/dorian/Sites/test/www/modules/field/field.module:405
    0.7183   46010480  18. theme_get_registry() /Users/dorian/Sites/test/www/includes/common.inc:2340
    0.7183   46010528  19. call_user_func_array() /Users/dorian/Sites/test/www/includes/theme.inc:248
    0.7184   46011048  20. _theme_load_registry() /Users/dorian/Sites/test/www/includes/theme.inc:248
    0.7188   46011096  21. _theme_build_registry() /Users/dorian/Sites/test/www/includes/theme.inc:289
    0.9386   57573280  22. _theme_process_registry() /Users/dorian/Sites/test/www/includes/theme.inc:530
    0.9387   57603464  23. views_theme() /Users/dorian/Sites/test/www/includes/theme.inc:384

I'm very new to drupal, but it seems a bit brittle...

dorianfm’s picture

Hmmm, seem to have found a temporary fix.

Open
/sites/all/modules/view/views.module

and at the begining of

function views_theme($existing, $type, $theme, $path) {
  $path = drupal_get_path('module', 'views');
  include_once $path . '/theme/theme.inc';

comment

  include_once $path . '/theme/theme.inc';

by changing it to

//  include_once $path . '/theme/theme.inc';

save the files then run

drush cc all

then remove the comments

include_once $path . '/theme/theme.inc';

save

and all appears to be working again.

Hope this helps someone.

henrikakselsen’s picture

#9 That seems to do the trick for me too. Thanks.

dgautsch’s picture

Unfortunately #9 didn't work for me. Any updates on this?

robcarr’s picture

I'm getting the same problem. Thought I had inadvertently downloaded Views twice, but couldn't find a duplicate folder. #9 didn't work for me either

dgautsch’s picture

Drush command terminated abnormally due to an unrecoverable error.                                                                                                      [error]
Error: Cannot redeclare _views_theme_functions() (previously declared in /Users/dgautsch/sites/dandy/sites/all/modules/views/theme/theme.inc:20) in
/Users/dgautsch/Sites/dandy/sites/all/modules/views/theme/theme.inc, line 35

That's the error I'm receiving. Has anyone else encountered this?

EDIT: Updated to the current dev version of views with no change.

I'm running MAMP if that makes a difference.

henrikakselsen’s picture

Actually, even though I wrote #9, #9 doesn't really work for me either, as the error keeps coming back later. (And I still got the similar Backup Migrate error I described in #3

nlisgo’s picture

subscribe

mowen3’s picture

Subscribe

henrikakselsen’s picture

Try to use sudo with all your drush commands, this seems to no error messages for me, would be nice if other would test it too.

bachbach’s picture

http://drupal.org/node/1334312
got a similar error with drsuh and all my local sites, sudo works for me.
(sudo is quite annoying …)

moshe weitzman’s picture

Status: Active » Closed (duplicate)

the paths in the error msg in #8 differ by lowercase/uppercase 'Sites'. Seems like a dupe of #644126: drush loads duplicate command files

dgautsch’s picture

I can confirm that running the commands as sudo work just fine.

cborgia’s picture

Sudo worked for me too. (thank you)

dgautsch’s picture

OK update on this. Make sure your folder permissions and groups are set to the proper groups. That's why when you run sudo things work because your'e running as super user.

chgrp is the command.

If you're on a Mac make sure your folders are not in the wheel group but in the staff group.

mrryanjohnston’s picture

Changing group as described in #22 does not solve this issue for me.

sethfisher’s picture

The problem is with MAMP using a different version of PHP than drush (or some such nonsense). I figured it out by reading some older threads related to the issue.

Bottom line, I added export DRUSH_PHP="/Applications/MAMP/bin/php/php5.2.17/bin/php" to ~/.bash_profile and now I'm good to go. If you're running php 5.3 in MAMP, then switch php5.2.17 to php5.3.6 (or whatever version of PHP your current MAMP is running). For the change to take effect, run source ~/.bash_profile or just log out and back into the shell.

This info is in the drush README.txt, but it's not MAMP specific and you'd really have to understand the problem to know that it relates to you. So hopefully this post is of some help to others dealing with this issue.

kclarkson’s picture

I am using the Acquia Dev Desktop and need a little assistance with where to change this code.

Thanks,

klim_’s picture

#19 thanks. Typing Sites instead of sites on Terminal is ths solution for me

kclarkson’s picture

To all using Acquia's Development Desktop:

Switching to the older version of php works and fixes the error.

to change your settings. settings -> config -> PHP 5.2.17

thanks #24

featherbelly’s picture

See:
http://drupalcode.org/project/drush.git/blob/HEAD:/README.txt

ADDITIONAL CONFIGURATIONS FOR MAMP:
-----------------------------------

Users of MAMP will need to manually specify in their PATH which version of php
and MySQL to use in the command line interface. This is independent of the php
version selected in the MAMP application settings. Under OS X, edit (or create
if it does not already exist) a file called .bash_profile in your home folder.

To use php 5.2.x, add this line to .bash_profile:

export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.2/bin:$PATH"

If you want to use php 5.3.x, add this line instead:

export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3/bin:$PATH"

If you have MAMP v.1.84 or lower, this configuration will work for both version
of PHP:

export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5/bin:$PATH"

If you have done this and are still getting a "no such file or directory" error
from PDO::__construct, try this:

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

Additionally, you may need to adjust your php.ini settings before you can use
drush successfully. See CONFIGURING PHP.INI below for more details on how to
proceed.

ADDITIONAL CONFIGURATIONS FOR OTHER AMP STACKS:
-----------------------------------------------

Users of other Apache distributions such as XAMPP, or Acquia's Dev Desktop will
want to ensure that its php can be found by the command line by adding it to
the PATH variable, using the method in 3.b above. Depending on the version and
distribution of your AMP stack, PHP might reside at:

/Applications/acquia-drupal/php/bin Acquia Dev Desktop (Mac)
/Applications/xampp/xamppfiles/bin XAMP (Mac)
/opt/lampp/bin XAMPP (Windows)

Additionally, you may need to adjust your php.ini settings before you can use
drush successfully. See CONFIGURING PHP.INI below for more details on how to
proceed.

featherbelly’s picture

See #28

Ken Ficara’s picture

This isn't entirely due to Drush using the wrong PHP. I was getting this exact error on a MAMP setup but Drush was definitely using the right PHP:

$ echo $PATH
/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.3.6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
$ echo $DRUSH_PHP
/Applications/MAMP/bin/php/php5.3.6/bin/php
$ drush php-eval 'echo phpversion();'
5.3.6

I did have capital letters in my site directory so I changed the directory from SiteName to sitename. Then things got ineresting. I still got the error if I ran drush as myself, but if I used sudo, it worked fine. Look at this:

$ pwd
/Users/name/MAMP/sitename
$ sudo pwd
/Users/name/MAMP/SiteName

I don't get that at all, and it makes me wonder if this is a Drush problem, or something weird about the sorta-case-sensitive-but-not-really MacOS filesystem, which causes headaches in other ways as well (MySQL table names for instance).

kclarkson’s picture

#28 Good looking. Your fix for MAMP was my issue.

If you have updated your MAMP it appears they changed the location of some files.

You need to add (php) right after the BIN:
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.3/bin:$PATH"

kclarkson’s picture

Issue summary: View changes

typo

mikelaroy’s picture

like #30, the letter-case was the issue for me. In my case I had

/Applications/mamp/SiteName....

which produced the error. I changed it back to

/Applications/MAMP/SiteName....

and then no more error. Yet some drush commands still functioned, like enabling modules etc...

nachenko’s picture

For those on Mac using MAMP who found "sudo drush" makes the trick.

The problem in my case was really really annoying, a total WTF:

In the Terminal, it's not the same to write "cd mamp" as "cd MAMP". You'll get to the same place, you'll see the same files, but somehow, it's not the same thing for your computer. My problem is, I used all lowercases. I closed Terminal, opened a new window, got to my site's folder USING PROPER CASES where needed. Afte doing that, no need to use "sudo" anymore for Drush.

A total WTF.

supadits’s picture

Issue summary: View changes

My case is similar and fixed with
https://www.drupal.org/node/2026149#comment-7598337

It's about case sensitivity which OSX is ignoring case but not drush

santac311’s picture

This happened to me after a database restore. I resolved the issue by manually clearing the cache in the database (since I couldn't do it using Drush). You need to login to the database directly. If you don't know the username/password, it is stored in plain text in /sites/default/settings.php. Once you've logged in, run the commands below. Site came right back up.

USE [the-name-of-your-database];
TRUNCATE TABLE cache;
TRUNCATE TABLE cache_block;
TRUNCATE TABLE cache_bootstrap;
TRUNCATE TABLE cache_field;
TRUNCATE TABLE cache_filter;
TRUNCATE TABLE cache_form;
TRUNCATE TABLE cache_image;
TRUNCATE TABLE cache_menu;
TRUNCATE TABLE cache_page;
TRUNCATE TABLE cache_path;
TRUNCATE TABLE cache_token;
TRUNCATE TABLE cache_update;