Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative root paths no longer seem to work #2909

Closed
jhedstrom opened this issue Aug 28, 2017 · 12 comments
Closed

Relative root paths no longer seem to work #2909

jhedstrom opened this issue Aug 28, 2017 · 12 comments
Labels
Milestone

Comments

@jhedstrom
Copy link
Member

jhedstrom commented Aug 28, 2017

When switching from Drush 8 to Drush 9, I noticed that relative --root paths don't seem to work for providing the core location.

Here's output for a build that exists in build/html:

With relative --root

$> vendor/bin/drush -r build/html status
 PHP binary    : /usr/local/Cellar/php70/7.0.12_5/bin/php
 PHP config    : /usr/local/etc/php/7.0/php.ini
 PHP OS        : Darwin
 Drush script  : /.../vendor/bin/drush
 Drush version : 9.0-dev-g65c2383
 Drush temp    : /tmp
 Drush configs :
 Drush aliases : /.../.drush/aliases.drushrc.php
                 /.../.drush/drupalEight.aliases.drushrc.php

With no --root (behaves the same as with absolute path for root arg)

$> vendor/bin/drush status

 Drupal version : 8.4.0-beta1
 Site URI       : http://default
 PHP binary     : /usr/local/Cellar/php70/7.0.12_5/bin/php
 PHP config     : /usr/local/etc/php/7.0/php.ini
 PHP OS         : Darwin
 Drush script   : /.../vendor/bin/drush
 Drush version  : 9.0-dev-g65c2383
 Drush temp     : /tmp
 Drush configs  :
 Drush aliases  : /.../.drush/aliases.drushrc.php
                  /.../.drush/drupalEight.aliases.drushrc.php
 Drupal root    : /.../build/html
 Site path      : sites/default
@greg-1-anderson
Copy link
Member

We're rewriting the bootstrap / preflight at the moment. See #2843. Let's make sure it works there.

@weitzman
Copy link
Member

Looks fixed to me.

@pingers
Copy link

pingers commented Sep 28, 2017

Relative paths working here too - thanks!

@pjcdawkins
Copy link

I've found a relative --root path does not work in Drush 9.5.2. I suppose there was a regression?

@greg-1-anderson
Copy link
Member

How about in 9.6.0-rc3?

@greg-1-anderson
Copy link
Member

Hm, yes, broken in HEAD of master too.

@pjcdawkins
Copy link

pjcdawkins commented Feb 15, 2019

Hi @greg-1-anderson I did some digging and opened webflo/drupal-finder#40

(relative paths work in some circumstances in Drush 9. DrupalFinder needs to be able to search upwards from the path, and calling dirname() recursively on a relative path wasn't sufficient, so that PR does realpath() before dirname())

@greg-1-anderson greg-1-anderson added this to the drush9 milestone Mar 3, 2019
@greg-1-anderson
Copy link
Member

Seems to be working for me now in today's HEAD of the master branch. Maybe some of our recent bootstrapping improvements accidentally fixed this.

@pjcdawkins / other interested parties: could you please test and confirm?

@greg-1-anderson
Copy link
Member

We'll re-open if this crops up again

@JTubex
Copy link
Contributor

JTubex commented Mar 26, 2019

@greg-1-anderson, I'm still having this issue.

Running drush cr -vvv gives the following output:

[preflight] Redispatch to site-local Drush: /var/www/..../htdocs/vendor/drush/drush/drush.
[preflight] Redispatch to site-local Drush: /var/www/..../htdocs/vendor/drush/drush/drush.
[preflight] Redispatch to site-local Drush: /var/www/..../htdocs/vendor/drush/drush/drush.

Probably not the best fix, but adding $root = realpath($root); in Drush\Preflight\RedispatchToSiteLocal::findSiteLocalDrush() did the trick for me:

     * Find a site-local Drush, if there is one in the selected site's
     * vendor directory.
     *
     * @param string $root The selected site root
     */
    protected static function findSiteLocalDrush($root)
    {
      $root = realpath($root);
        $candidates = [
            "$root/vendor/drush/drush/drush",
            dirname($root) . '/vendor/drush/drush/drush',
        ];
        foreach ($candidates as $candidate) {
            if (file_exists($candidate)) {
                return $candidate;
            }
        }
    }```

@greg-1-anderson
Copy link
Member

Maybe Path::canonicalize would also work here? A PR would be welcome.

@JTubex
Copy link
Contributor

JTubex commented Mar 27, 2019

I Created PR: #4019

weitzman pushed a commit that referenced this issue Mar 29, 2019
* Return the realpath instead of symlinked path

* #4109: Convert symlinked originalCwd to the realpath

* Fix AppVeyor tests

* Fix failing test EnvironmentTest::testExportConfigData()

* Canonicalize originalCwd after it is converted to the realpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants