Drush Version: 8.1.7
git version: 2.10.1

I have a module (that I maintain) that I'd like to use drush rn with. Previously this worked fine but after some updates (its been a few months so there are all sorts of updates, system, drush etc) I'm now seeing this:

drush rn
fatal: Not a git repository (or any of the parent directories): .git is not a valid Git tag.

Or:

drush rn 8.x-2.4
8.x-2.4 is not a valid Git tag.

8.x-2.4 is a valid git tag:

git tag
8.x-2.1
8.x-2.2
8.x-2.3
8.x-2.4

I've tried with both versions of the module 8.x and 7.x versions. Any ideas?

Workaround

Just specify the @none Drush site alias, e.g., drush @none rn.

Comments

tanc created an issue. See original summary.

tanc’s picture

If I clone my module to a location outside of a Drupal project then it works fine.

nickdickinsonwilde’s picture

Just ran into this, and can confirm running outside of a drupal dir works fine. Haven't debugged at all yet but identical results.

benjy’s picture

Also ran into this same issue, moving the repo outside of Drupal worked for me.

meickol’s picture

same here, subscribing

berdir’s picture

This might be a bug in Drush 9, my guess is that you're on that version.

https://github.com/drush-ops/drush/issues/2774

tanc’s picture

Hi Berdir, I'm on drush 8.1.9 now (8.1.7 when initially reported).

berdir’s picture

Hm, ok, maybe 8.1 is also already not working anymore or 8.

If you change

chdir(getcwd()); // Make sure we're in the working directory started.

to

chdir(drush_cwd()); // Make sure we're in the working directory started.

does it still not work? because with drush 9, not even that works and that should according to the documentation.

moshe weitzman’s picture

I haven't researched, but the expected behavior is to change to drupal root when a drupal site is present. I suggest that this script should use drush_shell_cd_and_exec() and specify its working dir so it is control of directory when run.

berdir’s picture

right I saw that helper function that would indeed be cleaner. But the first problem is that I didn't manage to get the correct working dir because drush_cwd() did not work as I think it should.

That's mentioned in https://github.com/drush-ops/drush/issues/1125 for example, but I'm not seeing the ouptut that is mentioned there.

moshe weitzman’s picture

To be honest, that function relies on being called early in preflight and it may not be anymore. This should work for you:

drush_shell_cd_and_exec($cmd, getenv('PWD'));
berdir’s picture

Yeah, something like that was my guess, it not being initialized anymore.

The getenv() doesn't seem to be workig either, though:

.../d8/modules/tmgmt_mygengo(8.x-1.x)$ drush ev "var_dump(getenv('PWD'))"

string(24) ".../d8"

moshe weitzman’s picture

Its working for me. I tried it before suggesting:


~/reps/watchers/web/modules/contrib/flag $ drush eval "print getenv('PWD')"
/Users/moshe.weitzman/reps/watchers/web/modules/contrib/flag

I'm using latest Drush9. I succeeded with both PHP 5.6 and 7.0.

mpp’s picture

It only seems to work properly when calling the local drush binary: drush will always return the webroot vs ../vendor/bin/drush will indeed return the path to the cwd.

traviscarden’s picture

Title: x is not a valid Git tag. » Incorrect "x is not a valid Git tag." error when running Drush command on a repo within a Drupal docroot
Category: Support request » Bug report
Issue summary: View changes

It works for me if I just drush @none rn. Is there a way to force the command to always use @none?