ingydotnet / git-subrepo

MIT License
3.27k stars 270 forks source link

Unable to run 'git subrepo upgrade' despite having git-subrepo/lib in PATH #210

Open Innovative-Ideas opened 8 years ago

Innovative-Ideas commented 8 years ago

Hi. I am using Windows 10 and the 64 bit version of git bash downloaded from: https://git-scm.com/downloads

I added the git-subrepo/.rc file to my ~/.bashrc file. I can use git subrepo commands.

However, I then tried using: git subrepo upgrade

and the following error was displayed:

$ git subrepo upgrade Sorry. Your installation can't use the 'git subrepo upgrade' command. The command only works if you installed git subrepo by adding '/path/to/git-subrepo' to your PATH.

If you used 'make install' to install git-subrepo, then just do this:

cd /path/to/git-subrepo
git pull
make install

However, when I type echo $PATH

I see that I do have the correct directory included.

$ echo $PATH /c/Users//Documents/repo/misc/git-subrepo/lib: ...

I can type the entire contents of my PATH variable if necessary. However the very first entry is the directory of git-subrepo

If I'm doing something wrong, I'd appreciate a suggestion. Thanks in advance!

AndrewSmart commented 8 years ago

Ingy doesn't use MS Windows. I don't think grimmySwe does either and he's taking a long break anyway.

Sorry I don't have MS Windows either, and I'd be using Cygwin if I were (because you get all the other nifty unix stuff, up-to-date things, and e.g. X11 to run things like gitk).

Your PATH sounds valid as you have access to the git subrepo commands fine.

My impression is that the check it fails as it expects a '/' at the start ^ of the string, and yours is '~' instead of '/' as you mentioned in the #209 issue. In full, I believe local path="$0" results in path='~/Documents/repo/misc/git-subrepo/lib/git-subrepo'. Try printing that variable by e.g. making:

local path="$0"
say "path to git-subrepo is '$path'."

The variable path in the context above does not refer to the environmental variable PATH, but $0 which is the first executable argument. This is the executable name/path (sorry if my terminology is wrong here, it is late I don't want to look it up) as resolved via searching PATH for what you typed on the CLI. Typing which git-subrepo on the CLI should print out the same thing as $0 resolves to in the above context I think.

I'm not sure why that '/' sanity check is there, as I suppose relative paths should be allowed. I guess ingydotnet is to blame :-) He may have rationale for that.

In the meantime as a workaround for you, either use an absolute path in ~/.bashrc or remove that sanity check in line 387 of git-subrepo. If choose to go with the absolute path, I'm assuming that git-bash thing willl be like Cygwin or even a fork of it, so try ls / and navigate around for the C drive or look up the docs online (sorry I don't know what it is you're using and that download page says nothing helpful so I've called it git-bash).