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

PowerShell Core on Linux support #302

Closed
3 of 5 tasks
theaquamarine opened this issue Aug 21, 2016 · 14 comments
Closed
3 of 5 tasks

PowerShell Core on Linux support #302

theaquamarine opened this issue Aug 21, 2016 · 14 comments

Comments

@theaquamarine
Copy link
Collaborator

theaquamarine commented Aug 21, 2016

Issues I've found running posh-git on OS X:

  • Path separators are a known issue in PowerShell on Linux: only forward slashes are supported (https://github.com/PowerShell/PowerShell/blob/master/docs/KNOWNISSUES.md#directly). profile.example.ps1 uses .\posh-git rather than Join-Path . posh-git. Failing that, swapping to forward slash would work as they are supported everywhere.
  • Administrator check in GitPrompt.ps1:98 doesn't work as [Security.Principal.WindowsIdentity]::GetCurrent() is unsupported.
  • GitUtils.ps1:226 doesn't work for setting env variables, as [EnvironmentVariableTarget] is unavailable. We use Process, which is the default, so could skip this.
  • The prompt shows up twice. This isn't actually our fault, there's an issue with using Write-Host in the prompt on OS X/Linux. Tracked upstream at Powershell Prompt Double Execution PowerShell/PowerShell#1897
  • Actual ssh-agent support could probably be better. ssh-agent always runs OS X 10.5+ and uses Keychain as storage so I'm not sure how much posh-git actually needs to manage agent/keys on OS X.
@jonathankarsh
Copy link

Can confirm similar issues exist on Ubuntu 14.04.

@andyleejordan
Copy link
Contributor

Path separators actually shouldn't be an issue. PowerShell on Linux translates backslashes to forward slashes to be "slash agnostic"; what this prevents is a backslash as a literal character in a path name due to the inability to escape it. But your use of \ as a / should be just fine.

Anything using Security.Principal.WindowsIdentity is just (expectedly) not going to work on Linux.

You honestly may just want to wait for EnvironmentVariableTarget. It's been added back to CoreFX. However, if you note the date, that was July 5th, and the stable release that PowerShell is using was published June 27th. So when .NET Core drops their next big release and PowerShell picks it up, this problem just goes away. (And then GetCurrent can turn into [Environment]::UserName probably.)

Double prompting is a strange bug; I believe @ealexjordan is working on it.

@dahlbyk
Copy link
Owner

dahlbyk commented Sep 19, 2016

Thanks, @andschwa!

Double prompting is a strange bug; I believe @ealexjordan is working on it.

Don't spend too much time there, at least for our benefit: as of #304 we won't need to Write-Host in prompt.

@rkeithhill
Copy link
Collaborator

Issues 2 and 3 have been addressed. Issue 1 "shouldn't" be an issue for PowerShell commands but anytime a path is passed to an external application, the path sep char probably needs to be correct for the platform. Regarding issue 4, that is a known PSReadLine issue. Issue 5 needs further investigation.

And as @dahlbyk mentions, there is an issue with the use of Write-Host in Write-Prompt. On Window 10 AU and Linux/macOS, folks are going to want to start using ANSI esc sequences to colorize their prompt text. There should be a way to allow that while still maintaining the old way for back compat (or for hosts that don't support ANSI escape seqs).

@dahlbyk
Copy link
Owner

dahlbyk commented Dec 29, 2016

Issues 2 and 3 have been addressed.

By #312 and #318, respectively.

Are there any specific spots that Issue 1 (path separators) were an issue? #325 did make a minor change along these lines.

Issue 4 should be resolved by #304.

Issue 5 is related to #295. Are there any environment variables set by ssh-agent on macOS (e.g. SSH_AGENT_PID)?

@rkeithhill rkeithhill added this to the v1.0 milestone Dec 31, 2016
@dahlbyk dahlbyk mentioned this issue Feb 17, 2017
13 tasks
@dahlbyk dahlbyk changed the title PowerShell on Linux support PowerShell Core on Linux support Feb 17, 2017
@dahlbyk
Copy link
Owner

dahlbyk commented Mar 5, 2017

Finally got around to testing this out myself (on develop branch). Only error so far seems to be unreported (Add-Member).

bash_2017-03-05_00-08-03

image

@rkeithhill
Copy link
Collaborator

You can fix this with -Force - in GitUtils.ps1 starting at line 298:

            Add-Member -PassThru -Force NoteProperty Added    $indexAdded.ToArray() |
            Add-Member -PassThru -Force NoteProperty Modified $indexModified.ToArray() |
            Add-Member -PassThru -Force NoteProperty Deleted  $indexDeleted.ToArray() |
            Add-Member -PassThru -Force NoteProperty Unmerged $indexUnmerged.ToArray()

        $working = (,$workingPaths) |
            Add-Member -PassThru -Force NoteProperty Added    $filesAdded |
            Add-Member -PassThru -Force NoteProperty Modified $filesModified.ToArray() |
            Add-Member -PassThru -Force NoteProperty Deleted  $filesDeleted.ToArray() |
            Add-Member -PassThru -Force NoteProperty Unmerged $filesUnmerged.ToArray()

@rkeithhill
Copy link
Collaborator

rkeithhill commented Dec 31, 2017

Fixed the Add-Member errors via PR #514

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 10, 2018

@rkeithhill is Pester able to run on PS Core on Travis? Would be great to have non-Windows CI to have some confidence that we're not completely broken.

Path separators are a known issue in PowerShell on Linux

This doesn't seem to be completely resolved yet.

Actual ssh-agent support could probably be better.

Let's assume this will be resolved by #338.

@rkeithhill
Copy link
Collaborator

Pester is running cross-plat on PS Core. Would be good to test on Linux/macOS.

@dahlbyk
Copy link
Owner

dahlbyk commented Jan 11, 2018

I've enabled Travis CI for this repo, if anyone cares to add a .travis.yml and get the build working.

https://github.com/pester/Pester/blob/0f5aff9fc34323659f9d68c29b3265a7f0d6bf6a/.travis.yml

@dahlbyk
Copy link
Owner

dahlbyk commented May 18, 2018

Other than deciding what to do about ssh-agent, are there any lingering issues with posh-git on Linux as of beta2?

@rkeithhill
Copy link
Collaborator

None that I can think of that are in our control. The only issue I see is that we are dependent on a beta of PSReadLine to be really usable on Linux. I'm hoping PS Core 6.1 will ship with PSReadLine 2.0.0.

@rkeithhill
Copy link
Collaborator

I believe with the removal of SSH functionality to the posh-sshell module there is nothing left to do for this issue. I have been using posh-git on Ubuntu 18.04 for months now without issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants