Closed (fixed)
Project:
Drush
Version:
All-versions-3.3
Component:
Core Commands
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Oct 2010 at 19:10 UTC
Updated:
20 Oct 2010 at 16:20 UTC
I'm trying to use the path-aliases feature but they don't seem to be resolving.
drush sa @local
returns:
$aliases['local'] = array (
'root' => '/Users/christian/Sites/site-name',
'uri' => 'default',
'path-aliases' =>
array (
'%files' => 'sites/default/files',
),
);
but when I type
drush dd @local:%files
it returns:
/Users/christian/Sites/site-name/%files
It's literally outputting "%files" rather than sites/default/files
Comments
Comment #1
luchochs commentedYou can omit the 'uri' item (assuming your site isn't part of a multisite instance).
Comment #2
luchochs commentedAnd if your 'files' directory is in the conventional place, you don't need define it explicitly via 'path-aliases'.
If so, this is another command that can help you:
shell> drush @local dd filesComment #3
jh3 commentedI'm also having a similar issue. My files directory is also in the standard place, but doing something like "drush dd @dev:%files" when I have %files set will literally print out "/path/to/drupal/%files".
Also, I have a "%dump" key set and when I do "drush @dev sql-dump > `drush dd @dev:%dump`" i get a file called "/path/to/drupal/%dump" instead of the one I provided in my aliases.drushrc.php file.
What's the reason for this happening?
Comment #4
cschlens commentedActually the real issue I'm having is when trying to rsync files with a remote alias called @dev
I enter:
and it returns:
Even though @dev is a remote alias and I've been able to run other drush commands on it successfully it thinks @dev:%files is on my local machine, specifically wherever I was when I called the drush rsync command.
Comment #5
sharpbites commentedI have the same problem with version 3.3. It only happens (to me) when the aliases file is inside de sites/default folder. If I move it to .drush/ everything works fine, but I would very much prefer to put the file inside the project root so that it can be versioned.
For the record, it also happens with @self:
drush dd @self:%files
/home/username/public_html/projectname/%files
Comment #6
jh3 commented@sharpbites: I was just about to respond with the same problem.
When I have an alias file on my local machine, it works fine in ~/.drush. If I move it to /projects/path/to/drupal/sites/default, it's not recognized.
If I copy the same alias file to the remote server and place it in /path/to/drupal/sites/default, drush recognizes it.
Like sharpbites, I'd like to have separate alias files for each site stored in sites/default working locally.
Comment #7
jh3 commentedOf course I (kind of) figure out why this is happening a few minutes later.
I'm not tracking settings.php in my local repository. When that file is not present, and you have aliases.drushrc.php in sites/default on your local box,
drush site-aliaswill not run. I don't want to track settings.php though because I push the site to different servers that require different DB information. Plus, if I have settings.php on my local machine with remote DB information, I receive annoying warnings from drush:Is there any way around this?
Comment #8
sharpbites commented@ejh3
Copying the aliases file to the remote site (another drupal in the same machine, in my case) didn't work for me.
I didn't really understand the part about having settings.php under source control or not.
I have found one way to make it work with local aliases files. You have to use your sitename when calling drush, like this:
drush default rsync @dev:%files @local:%filesI don't know if this is the expected use, I dind't find it in the docs. I have to use it like that even from inside the site/default folder.
I guess this is to bootstrap it, whatever that means, as per the comments in the example.aliases file:
Comment #9
jh3 commentedHere is an example of one of my aliases:
And here is what I've encountered (locally):
Having the
aliases.drushrc.phpfile in sites/default without asettings.phpfile, drush doesn't recognize any of the following:drush @my_alias statusdrush default @my_alias statusInstead if spits back:
Could not find a Drupal settings.php file at ./sites/default/settings.php. The drush command 'default @my_alias st' could not be found.Having
aliases.drushrc.phpin sites/default with a vanilla settings.php file (no DB information),drush @my_alias statuswill work. Local commands will not work because the DB information is missing fromsettings.php. I can put the database URL in settings.php, but that causes warnings (which I guess really do no harm, but they are just annoying).All of the above is probably supposed to happen and I'm probably just doing something wrong. I would just really like to have the aliases working when in sites/default instead of having to store them in $HOME/.drush.
Also, I found this post not too long ago, but it didn't really solve any of my problems -- http://drupal.org/node/766278
Comment #10
greg.1.anderson commentedThere is a chicken-and-egg problem with storing your aliases in sites/default. The alias defines where drush should look to find your settings.php file. sites/default is not a valid location for alias files until the 'default' site has been bootstrapped.
Should drush look in sites/default even if the site has not yet been bootstrapped? There are a couple of problems with this. For one thing, it is the alias that defines where the Drupal root is; drush can't find sites/default until it has used the alias to find the Drupal root. Oops. The other problem is that aliases in sites/default are intended to be aliases that are only relevant for that one site (e.g. the live site for your dev site, or visa-versa). If drush used aliases for sites that had not yet been bootstrapped, and there were multiple sites to consider, then all of their local aliases would be loaded -- and then those aliases wouldn't be local any more. If you only have one site, then you don't really need aliases; you can just use $options['root'] and $options['uri'] in your drushrc.php file.
There is one instance where drush will load aliases for sites that have not been bootstrapped, as mentioned above. If you rsync or sql-sync to or from a site identified by a global alias (e.g. in .drush/aliases.drushrc.php, etc.), then you may use a local alias of that site for the other target.