Suggestions for those arriving at this issue based on the error message
- Look for calls to drupal_goto. These calls should be wrapped in a call to drupal_is_cli before doing a drupal_goto.
- Look for calls to 'exit;' in the code path
- Make sure the uri in the drush alias is exactly as it is accessed in browser. If http://example.com redirects to http://www.example.com then you must type www.example.com in the drush alias uri.
- Make a brand new install of Drupal and see if the problem happens again. If not - what is different between the sites?
- Some modules that can cause this problem include require_login, secure_site, mobile_tools, restrict_ip
original report
Linux 2.6.18-194.32.1.el5
PHP 5.2.17 (cli), /etc/php.ini memory_limit = 2G (there's no other php.ini file)
Parallels Plesk Panel 9.5.4
drush fails inside drupal root, but drush status completes outside drupal root. spent an hour in #drupal with no luck. any help?
[root@ drush(outside drupal root)]# drush -v -d status
Bootstrap to phase 0. [0.03 sec, 1.98 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.03 sec, 2.18 MB] [bootstrap]
Found command: core-status (commandfile=core) [0.07 sec, 5.01 MB] [bootstrap]
Initializing drush commandfile: user [0.07 sec, 5.01 MB] [bootstrap]
PHP configuration : /etc/php.ini
Drush version : 4.4
Drush configuration :
Drush alias files :
Command dispatch complete [0.07 sec, 5.01 MB] [notice]
Peak memory usage was 5.06 MB [0.07 sec, 5.01 MB] [memory]
[root@ httpdocs(inside drupal root)]# drush -v -d status
Bootstrap to phase 0. [0.03 sec, 1.98 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.03 sec, 2.18 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.07 sec, 5.01 MB] [bootstrap]
Initialized Drupal 6.20 root directory at /var/www/vhosts/*/httpdocs [0.09 sec, 5.81 MB] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.09 sec, 5.81 MB] [bootstrap]
Initialized Drupal site default at sites/default [0.09 sec, 5.81 MB] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.11 sec, 5.82 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.11 sec, 5.85 MB] [bootstrap]
Successfully connected to the Drupal database. [0.11 sec, 5.86 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.12 sec, 6.2 MB] [bootstrap]
Drush command terminated abnormally due to an unrecoverable error. [0.36 sec, 31.22 MB] [error]
Comments
Comment #1
jptaranto CreditAttribution: jptaranto commentedLooks like I'm having exactly the same problems too - although only on one drupal site.
Tried using a different database to no avail.
Comment #2
sidharth_k CreditAttribution: sidharth_k commentedI'm getting the exact same issue with version 4.4
Frustrating ... spent a long time on this :-)
Comment #3
jonhattanOnly thing I can think of is to comment out ob_start() in includes/environment.inc:968 and see if drupal dumps any error.
Comment #4
sidharth_k CreditAttribution: sidharth_k commentedI am no longer getting this problem.
My setup: my site is available on root url lets say http://www.example.com/
In the drupal root directory (say /var/websites/example) when I do:
It works fine and I don't get unrecoverable error. (Please note you must type the url in drush exactly as it is accessed in browser. If http://example.com redirects to http://www.example.com then you must type www.example.com in drush. It will fail otherwise.)
If i just type
then I get the unrecoverable error
Please note that my site settings are in sites/default
Comment #5
Alex Andrascu CreditAttribution: Alex Andrascu commentedI'm still getting this on a localhost install. Tried the -l http://localhost option mentioned above but it didn't cope.
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedSorry, there is nothing in that debug log that identifies a cause. I suggest trying on a virgin drupal site on the same server and/or on a different server. Could be that a no core module is failing.
Comment #7
AndyZhang CreditAttribution: AndyZhang commentedI encountered the same problem on my site. After some debug I found that it's caused by one of our customized modules. The module implements the hook_init and inside it we redirect the user login process to other site. After I disabled the module drush works correctly. Probably you can have a try to disable some customized modules and see if drush work or not. Good luck.
Comment #8
bkosborneSame for me as above. I had mobile tools enabled.... which normally redirects to a mobile site. Disabled to run drush.
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedSounds like misbehaving modules that assume all requests come via the web
Comment #10
epruett CreditAttribution: epruett commentedSeeing this same error on all Drupal 6 localhost sites.
Drush command terminated abnormally due to an unrecoverable error. - error
Seeing better performance but still some errors on Drupal 7 localhost sites.
Comment #11
js CreditAttribution: js commentedFor me, the problem was a dumb use of "exit" in a script.
It took me a very long time before I looked inside drush.php, and found
// We did not reach the end of the drush_main function,
// this generally means somewhere in the code a call to exit(),
// was made. We catch this, so that we can trigger an error in
// those cases.
as the needed clue. I hope posting this here helps. Perhaps Drush could have an exit message.
Comment #12
tonylegrone CreditAttribution: tonylegrone commentedI have confirmed that using Rerquire Login http://drupal.org/project/require_login crashed drush on one of my sites. Disabling it fix the drush problem.
There's an apparent fix for it here: http://drupal.org/node/828164, but I didn't need to try it.
Comment #13
Countzero CreditAttribution: Countzero commentedI can confirm tha this error was triggered by a drupal_goto call in hook_init in a custom module.
Trying to find some code to test where the request comes from to disable the redirect when drush is the user-agent.
Comment #14
jptaranto CreditAttribution: jptaranto commentedFinally figured out is was caused by the secure_site module being enabled locally. Turned it off via settings.php and drush works great now.
Comment #15
benjamin_dk CreditAttribution: benjamin_dk commented+1 with mobile tools being the culprit. Disabled. Thanks for sharing your experience.
Comment #16
bobfoss CreditAttribution: bobfoss commented@Countzero: Using the $_SERVER['SCRIPT_FILENAME'] you can check if drush.php was run.
Comment #17
Countzero CreditAttribution: Countzero commentedThanks bobfoss. Tried a few variables round there but had to move on to the next activity ... Will give it a try next time.
Comment #18
gambaweb CreditAttribution: gambaweb commenteddrupal_goto (or some other redirect) at hook_boot or hook_init can case that
Comment #19
Elijah LynnThis also happened to me when I ran a non applicable command on a drush alias to a remote server. For instance if the remote site has not been setup yet and you run "drush @alias st" it will throw this error (Drush command terminated abnormally due to an unrecoverable error), on a local machine it will output information such as where the php.ini is, the Drush version and location of config and alias files.
I am not sure if it is possible to output the same information from the remote as it does when you run it locally but just thought I would add this here. At the least the error message could be improved upon. I was using Drush 4.5 on local and remote, if it matters.
Comment #20
Sutharsan CreditAttribution: Sutharsan commentedFor the record, this error also caused by Single Sign On module, version 6.x-1.1.
Comment #21
zilverdistel CreditAttribution: zilverdistel commentedJust wondering, has this been reported in the named modules that cause these problems?
Greetz,
Diederik
Comment #22
Marc Angles CreditAttribution: Marc Angles commentedI lost a lot of time to find that shield-6.1-1 is doing the same thing
Comment #23
zhuzhuojiang CreditAttribution: zhuzhuojiang commentedThanks @gambaweb,
For mark, require_login module causes this issume.
Comment #24
rhibbitts CreditAttribution: rhibbitts commentedJust ran into the same issue. It's caused by drupal_goto() in a custom module. Wrapping the drupal_goto() in:
fixes the issue.
Comment #25
ñull CreditAttribution: ñull commentedWhen you use the module restrict_ip you have to add 127.0.0.1 on your whitelist otherwise you see this same error. See: #1325370: Ignore drush when checking IPs [Patch attached]
Comment #26
ressa CreditAttribution: ressa commented*EDIT*: Nevermind, I am using the Shield module now during testing.
I was using a custom module which prompts for user and password while testing a web site. Disabling it made the error go away, and Drush archive-dump now works again. Does anyone know if the code below can be fixed, so that it works with Drush, while enabled?
Comment #26.0
ressa CreditAttribution: ressa commentedsome day I'll learn how html works
Comment #27
snappermorgan CreditAttribution: snappermorgan commentedYou are a lifesaver! I thought I was resigned to disabling each module until I found the culprit. As soon as I read your comment I added the IP address to the whitelist and BOOM, hours of work avoided.
Consider yourself high-fived.
Comment #28
dman CreditAttribution: dman commentedMe too! Thanks fo this thread - I also found a drupal+goto in a custom modules hook_init.
Had to disable it at the database lever (as drush dis would not co-operate)
but it was up again after that.
Comment #28.0
gregglesx
Comment #28.1
gregglesx
Comment #29
ressa CreditAttribution: ressa commentedThank you @sidharth_k! Adding www in front fixed the error, since I have a redirect from non-www to www in my settings.php:
Comment #30
ressa CreditAttribution: ressa commentedComment #31
babruix CreditAttribution: babruix commentedI had that several times, reason usually is drupal_goto in some hook_boot or hook_init.
Not sure,but maybe it makes sense to add in future this:
inside drupal_goto function ?
Comment #32
Jean-Marc CreditAttribution: Jean-Marc commentedHi,
got this issue,
does anyone has any idea of what to do ?
Working on Vmware ubuntu x64
I got this issue since drush cannot be only installed by git clone
Thanks in advance for your help
Comment #33
asiby CreditAttribution: asiby commentedHi guys
In my case, I was getting this error message dues to a call to the exit() language construct. Although I was using exit(0) to let Linux know that the execution ended normally without errors (as any other Linux executable would), nothing was working. I am starting to think that it is a PHP bug.
I removed the exit() call and now Drush is ending normally with the following message...
Comment #34
grincon CreditAttribution: grincon commentedrestrict_ip was the problem for me. Added 127.0.0.1 to the whitelist and all set.
Thank you
Comment #35
rakesh.gectcr#18 Works for me...
We should not write "drupal_goto (or some other redirect) at hook_boot or hook_init "
Use Rules modules instead of that...
Comment #36
liquidcms CreditAttribution: liquidcms commentedusing Drush 6 (gave up trying to install Drush 7)
i have tried a simple
drush up admin_menu --uri=http://[my-local-site]
on numerous sites
- many work ok
- one states: Drush command terminated abnormally due to an unrecoverable error
- one states: Command pm-update needs the following modules installed/enabled to [error]
run: update. The drush command 'up admin_menu' could not be executed. [error]
the 2 that don't work have none of the modules mentioned above and run properly from browser. They do both user PURL which i thought might be an issue; but they give different error messages; so not sure.
Comment #37
liquidcms CreditAttribution: liquidcms commentedand sure enough, on the site that was causing the "Drush command terminated abnormally due to an unrecoverable error" i disabled PURL and drush up works.. unfortunate that Drush won't work with PURL as it is on a lot of sites we do.
Comment #38
gurukatre CreditAttribution: gurukatre as a volunteer and commentedThe same issue came to me when i used die; in my module.module file.
Comment #39
wuinfo - Bill Wu CreditAttribution: wuinfo - Bill Wu for Wulei Info Technology Solutions commentedSomething to add on to:
https://www.drupal.org/node/1140842#comment-8482899
https://www.drupal.org/node/1140842#comment-4488068
with HTTPS:
I have this problem recently. It turned out to be the 301 redirect script in the settings.php file.
Basically: I redirect all site traffic to https://www.example.com.
drush -l https://www.example.com <name of drush command>
Comment #40
rbilinda CreditAttribution: rbilinda commentedMaking a redirect in your module using like drupal_goto() without a mechanism like
function_exists('drush_main') to detect whether they are being called from Drush or not, will cause Drush to fail, especially if it involves login.
Credit
@babruix
https://www.drupal.org/node/1181308
https://www.drupal.org/node/827478
Comment #41
Ewout GoosmannWhen og_purl and purl were disabled, it was possible to run "drush cc all". After enabling the purl module, it was still possible to run drush cc all. When I enabled the og_purl module again, drush throws the error "Drush command terminated abnormally due to an unrecoverable error.".
When you took a quick look at the code of the og_purl module, it calls
in the og_purl_init function. Probably that's the problem.
The abnormal thing is that it has worked for weeks/months without updating the module. (Last update was 2014-Nov-13).
At the moment I don't have a fix for this problem yet.Here's a patch: https://www.drupal.org/node/2712389
Comment #42
stoickthevast CreditAttribution: stoickthevast as a volunteer commentedAfter 4 hours of debugging on this problem I found out that in my case it is caused by Trigger and Action. My hook_update_N is to create a node from a json file and my "action and trigger" is a redirection after creating a node. Removing the action fixed the problem.
Comment #43
DocDJ-forum CreditAttribution: DocDJ-forum commentedTrying to upgrade for D7.43 to d8.1, starting with a clean Drupal install, and NO DB, I am getting the same error as reported above. Next, I cleared the cache and did a drush migrate-reset-status, which reported "migration does not exist". So I reran the migration, which reported "migration contact_category is busy with another operation: importing". drush continued a bit further, then failed again with "call to undefined function field_read_fields() in registration.module at line 1286.
Any ideas what I'm doing wrong.
Comment #44
ngocketit CreditAttribution: ngocketit commented#18 works. drupal_is_cli() can be used to determine if it's drush request.
Comment #45
DocDJ-forum CreditAttribution: DocDJ-forum commentedI have NO modifications to ANY files, so drupal_is_cli() and discussion of hooks have no meaning for me. I deleted EVERYTHING related to my D8 install, then pulled in all the 8.0.0 files, then the 8.1.2 update files and did the INSTALL.PHP (which is in CORE, not in the root). I then tried drush migrate-upgrade .... and that failed with:
.
Is there a better place to report this problem?
Config: Drupal 8.1.2, PHP 5.6, MySQL 5.6, Apache 2.4, Windows 10 Pro.
Comment #46
jimkeller CreditAttribution: jimkeller commentedRan into this issue on a Drupal 7 site; turns out that manually disabling the shield module does the trick (steps below). This is mentioned above as well, but Shield calls exit() in hook_boot() after sending the http headers for authorization, which basically just kills the PHP script when running as a CLI.
To disable the shield module manually:
1. Login to the database using the mysql console (or phpMyAdmin or whatever) and run the following command:
UPDATE system SET status=0 WHERE name='shield' AND type='module'
2. Exit mySQL and run: drush rr
(if this fails, try: drush dl registry_rebuild and then run drush rr . See: https://www.drupal.org/project/registry_rebuild)
3. drush should now work
Comment #47
sidharthapI came across same issue Drush command terminated abnormally due to an unrecoverable error and builds get failed. After spending couple of hours and debugging code I found drupal_goto written in custom code causes the issue after Drupal up gradation.
I just correct the code not to run in cli ( drupal_is_cli() )mode resolve the issue for me.
Comment #48
ressa CreditAttribution: ressa at Ardea commentedSwitching to HTTPS caused this for me, adding https:// in aliases.drushrc.php fixed it:
Comment #49
bolshii CreditAttribution: bolshii commented#34 works for me.
Thx a lot :)
Comment #50
ioannis.cherouvim CreditAttribution: ioannis.cherouvim commentedI had this problem on Drupal 7 with Drush 8.4.5 and it turns out that the problem was the following in `settings.php`:
Removing it fixed the issue.
Comment #51
salah1In my case the :warning Drush command terminated abnormally
was a result of drush crashing due to memory exhaustion.
See:
https://drupal.stackexchange.com/questions/161966/what-can-we-do-to-reme...