Trying out Drush, getting the error above on certain copies of sites. Googled but could not find reference to this error. Hoping someone might be able to give me some insights here. Probably something simple that I don't yet understand about the utility. Thanks!

CommentFileSizeAuthor
#19 drush-missing-user-0-help.patch1.04 KBwebchick

Comments

sittard’s picture

Got the same error message as well! I've blocked anonymous user access to my site. Using the command drush -u 1 status works for me. The -u option specifies a user id to log in with.

moshe weitzman’s picture

Status: Active » Closed (works as designed)
shrop’s picture

This tip also worked for me on a site where I was receiving the same message. I am cool if it is by design, but am curious as to what permissions trigger Drush to not be able to login as the anonymous user. Most of my sites are multisites so I am also using --uri=http://www.example.com in my Drush command strings.

sheldon rampton’s picture

I'm also getting this error message when I run drush to install modules using drush.php dl admin_menu. The download seems to work, despite the error message. When I add the -u 1 option, the "Could not login" error message disappears, and instead I get "Notice: Trying to get property of non-object in /mysitepath/includes/common.inc on line 1797."

I guess this isn't stopping me from getting work done, but it's confusing, and when I get an error message like this, I'd like to know what it means.

okokokok’s picture

I'm trying to work with a profile from themesnap (www.themesnap.com/premium-drupal-themes/magazine-plus.html - it's a darn shame the CSS is not GPL).

Now I'm trying to use Drush on a site I've set up with this theme, but I'm getting:

$ drush --verbose=2 info
Initialized Drupal 6.14 root directory at /var/www/example.org/htdocs/                                                                            [notice]
Initialized Drupal site default at sites/default                                                                                                       [notice]
Could not login with user ID #<em>0</em>.                                                                                                           [error]
Command info needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal environment to run this command.      [error]
The command 'drush.php info' could not be executed.                                                                                                 [error]


$ drush -u 1 --verbose=2 info
Initialized Drupal 6.14 root directory at /var/www/example.org/htdocs                                                                            [notice]
Initialized Drupal site default at sites/default                                                                                                       [notice]
Including version specific file : /opt/drush/commands/pm/update_info/drupal_6.inc                                                                      [notice]
No information available.                                                                                                                           [error]
An error occurred at function : drush_pm_info                                                                                                       [error]
Command dispatch complete                                              

And I'm curious about ways that would allow me to use Drush on this site.

okokokok’s picture

drush -u 1 status is working now, just like most other drush stuff, drush -u 1 info is not.

It could be nice to have the user ID in the configuration somewhere.

mrfelton’s picture

drush -u 1 status does get me the status, but I also get the following error at the end:
An error occurred at function : drush_core_status

fenstrat’s picture

Just a note for anyone else who comes across this based on the anon user error, i.e. Could not login with user ID #0.

It means exactly what it says so check the user table and ensure there is a user with uid 0.

In my case there was no uid 0 due to a restored faulty backup (where the first entry in the user table, i.e. the anon user, was allocated a uid which was not 0).

rsvelko’s picture

Thanks to #8 I did export import of the missing row and voala:

(The SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; ensures that the uid will be = 0 and not the last_uid + 1).

Correct the PREFIX before executing.

This stopped the drush errors.

-- phpMyAdmin SQL Dump
-- version 3.2.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 30, 2010 at 06:55 PM
-- Server version: 5.1.41
-- PHP Version: 5.2.11-2

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `dr_akh_cons_at`
--

-- --------------------------------------------------------

--
-- Dumping data for table `dr6_umed_users`
--

INSERT INTO `PREFIX_users` (`uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `created`, `access`, `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`, `signature_format`) VALUES
(0, '', '', '', 0, 0, 0, '', '', 0, 0, 0, 0, NULL, '', '', '', NULL, 1);

citronica’s picture

Thanks for this. Oddly enough, I had this problem on a fresh install in which I'd never monkeyed with the database at all. For no obvious reason, there was no uid 0 -- the anonymous user was uid 3 (?). I just changed it in the database to 0 and the drush error is now gone.

sutharsan’s picture

I get this error because the site I work on uses a settings.php in /sites/example.com and has no settings.php in /sites/default. Using -l http://localhost/example.com does not help either. Only the -u 1 gets me through without errors.

jwilson3’s picture

This will happen if you reload a site from a dumpfile created by drush sql-dump; the uid of UserZero (the anonymous user) can get set to 1+number of users.

Assuming you're using drush you can do the following to fix it (YMMV):

 echo "update users set uid=0 where name='' and pass='' and data is NULL" | `drush sql-connect`

NOTE: your mileage may vary, update the stuff in between the back-ticks if you need to specify something else (eg --uri=example.com) to get to the correct mysql connection string.

protoplasm’s picture

My 1+number of users occurred without the sql-dump on migrating the database. But the same concept in #12 worked for me. I just edited the UID of that entry directly to 0 and everything was normal again. You have to give drush props for the clue to the problem via the error message.

jghyde’s picture

Combo of #9 first & then #12 worked for me. Excellent!

Joe
http://www.hydeinteractive.com/

roball’s picture

Version: All-Versions-2.0 » All-versions-3.3

Adding

$options['u'] = '1';

to "drushrc.php" residing in drush's install dir solves all these weird problems.

sivaji_ganesh_jojodae’s picture

In recent version drushrc.php is no longer available instead you need to change includes/environment.inc line 902

$drush_user = drush_set_context('DRUSH_USER', drush_get_option(array('u', 'user'), 0));

to

$drush_user = drush_set_context('DRUSH_USER', drush_get_option(array('u', 'user'), 1));

roball’s picture

The shipped file is called "example.drushrc.php" and it *is* there in both versions 3.3 (v 1.8 2010/06/05) and 4.0-rc1 (v 1.13 2010/12/05). Why should it have been removed?

pog21’s picture

Thanks #8 for a clear explanation. I had this problem upon installing with fantastico. Used phpmyadmin to look at users table, which showed an entry right before user 1 with blank fields, but id of 3. Manually changed this to 0 and now it's working.

webchick’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new1.04 KB

This patch might help reduce duplicate support requests about this. I was stranded and had no idea what was causing this until I googled.

Feel free to mark it back to "by design," though. Not sure how much special casing you really want to put into Drush for a 6.x-era bug caused by faulty database dumping tools.

webchick’s picture

Version: All-versions-3.3 »
moshe weitzman’s picture

Status: Needs review » Fixed

comitted. thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

chx’s picture

Category: support » task
Status: Closed (fixed) » Active

This is a weak solution. Ask the user "Do you want to fix this?". Here's how: name and mail both are unique and so if there is a user whose name and mail are empty that's the anon user, run UPDATE uid = uid - uid WHERE name = '' AND mail = '' and hope for the best

roball’s picture

Why not just defaulting $options['u'] to '1'?

moshe weitzman’s picture

Status: Active » Closed (fixed)

I'm fine leaving it as docs only.

wizonesolutions’s picture

Thanks #8! Worked for me.

EvanDonovan’s picture

Version: » All-versions-4.x-dev
Issue summary: View changes

Here is the insert SQL that you want for 7.x:

INSERT INTO `users` (`uid`, `name`, `pass`, `mail`, `theme`, `signature`, `signature_format`, `created`, `access`, `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`) VALUES
(0, '', '', '', '', '', NULL, 0, 0, 0, 1, NULL, '', 0, '', NULL)
hectorplus’s picture

#27, work for me, running Drupal 7.x

Thanks