-
Notifications
You must be signed in to change notification settings - Fork 448
Add symlink resolver so we can figure out paths properly #193
Conversation
This reverts commit cac6b23.
Fixes #192 On non-windows, git and other files might be symlinks, so when we're using them as a base for determining parent directories, we may need to resolve the symlink first. The rules for automatically doing symlink resolution are tricky, so for now just do it manually.
We want the GitExecutablePath to reflect where the binary was found, and the GitInstallPath to reflect where it is installed. When the binary is a symlink (like /usr/local/bin/git -> ../Cellar/git/2.12.2/bin/git), this means GitExecutablePath will have /usr/local/bin/git and GitInstallPath will have /usr/local/Cellar/git/2.12.2/bin
|
|
||
| public bool DirectoryExists(NPath append) | ||
| { | ||
| if (append == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this method was sent null before, what was the result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine doesn't care if it's null so it wouldn't blow up, but it's a waste of resources creating new instances of the same thing over and over again, Combine always creates a new thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I follow now
| if (path == null || DefaultEnvironment.OnWindows || path.IsRelative || !path.FileExists()) | ||
| return path; | ||
|
|
||
| return new NPath(Mono.Unix.UnixPath.GetCompleteRealPath(path.ToString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetCompleteRealPath is a method that will get the real link from a symlink?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, from Mono.Posix
| // osx terminal app doesn't inherit the PATH env var and there's no way to pass it in | ||
| var envVarFile = environment.FileSystem.GetRandomFileName(); | ||
| environment.FileSystem.WriteAllLines(envVarFile, new string[] { "cd $GHU_WORKINGDIR", "PATH=$GHU_FULLPATH:$PATH /bin/bash" }); | ||
| Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

Fixes #192
On non-windows, git and other files might be symlinks, so when we're using them as a base for determining parent directories, we may need to resolve the symlink first. The rules for automatically
doing symlink resolution are tricky, so for now just do it manually.
Still not happy with how we're finding git on the system, but this should at least make the command line work across all systems.
An existing problem right now is that OSX overwrites values set to the PATH env variable when it loadsThis is fixed now by creating a little shell script that in turn invokes bash with a proper environment./etc/profilein preparation to run bash, which is seriously screwed up on their part. That means that the opened command line won't have our path variable value (but it will have all the other env vars). I'm still investigating how to fix that...FYI, we want the GitExecutablePath to reflect where the binary was found, and the GitInstallPath to reflect where it is installed. When the binary is a symlink (like /usr/local/bin/git -> ../Cellar/git/2.12.2/bin/git), this means GitExecutablePath will have /usr/local/bin/git and GitInstallPath will have /usr/local/Cellar/git/2.12.2/bin