posh-git icon indicating copy to clipboard operation
posh-git copied to clipboard

Fails When My Documents in OneDrive

Open Pharylon opened this issue 4 years ago • 7 comments

System Details

  • posh-git version/path: 1.0
  • PowerShell version: 5/7
  • Git version: 2.26
  • Operating system name and version: Win10

Issue Description

tl;dr I couldn't get posh-git to work when letting OneDrive backup my documents.

I recently completely reinstalled Windows 10. While doing so, I saw the option to "back up your Documents to OneDrive" or something to that effect, and thought, hey, that sounds good. So I left that option checked.

What I didn't realize was that I'd end up with "My Doucments" pointing to C:\Users\username\OneDrive\Documents instead of the normal path.

After installing most of my normal software, I installed Posh-Git from the Powershell gallery, but it didn't work. No error, it just didn't show anything at the command prompt. I uninstalled it, reinstalled, tried to manually install it by cloning the repo, etc. Nothing worked. It would just silently fail. Typing "Import-Module posh-git" wouldn't give me any errors, but it'd never alter the command prompt to show the familiar branch name and status icons.

At this point, I decided to try the new PSCore since I saw posh-git was compatible with it, and figured maybe that would work. After installing posh-git from the gallery, it actually worked (hallelujah!). But then later that day, I noticed it had gone back to not working. Again, no error message, but it failed to alter the PowerShell prompt. I think I rebooted in between those two times, as I was installing a lot of software, but I'm not 100% sure.

Eventually, I just gave up and turned off the OneDrive backup, reverting My Documents to C:\Users\username\Documents

After I did that, posh-git worked just fine :)

Pharylon avatar Apr 14 '20 12:04 Pharylon

I wonder if PowerShell gets confused about where to load modules from if the OneDrive backup is enabled? If you wouldn't mind helping troubleshooting, I would be interested to know what $PROFILE | Format-List and $Env:PSModulePath show when you have it enabled.

Surprised this hasn't come up as an issue before.

dahlbyk avatar Apr 14 '20 14:04 dahlbyk

Hey guys, same issue here, here's the result:

C:\Users\rafak> PowerShellGet\Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force
Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9709
Line |
9709 |  … talledPackages = PackageManagement\Install-Package @PSBoundParameters
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

C:\Users\rafak>

thanks

rafakwolf avatar May 21 '20 01:05 rafakwolf

I wonder if PowerShell gets confused about where to load modules from if the OneDrive backup is enabled? If you wouldn't mind helping troubleshooting, I would be interested to know what $PROFILE | Format-List and $Env:PSModulePath show when you have it enabled.

Surprised this hasn't come up as an issue before.

Same error here!

PS C:\Windows\system32> $PROFILE | Format-List C:\Users\fabio\OneDrive\Documentos\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 PS C:\Windows\system32> $Env:PSModulePath C:\Users\fabio\OneDrive\Documentos\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\ PS C:\Windows\system32>

fabiomen10 avatar Aug 08 '20 11:08 fabiomen10

@rafakwolf You're hitting an issue with PowerShellGet - see https://github.com/PowerShell/PowerShellGet/issues/66. Execute gmo posh-git -listavailable, close all PS consoles and remove every listed version of posh-git (or move to a location outside a Modules folder). Then fire up PS and try to install posh-git.

@FabioMen10 Exactly which error are you getting? The one @rafakwolf ran into with install-module or what @Pharylon saw with posh-git not modifying the prompt inside a Git repo?

rkeithhill avatar Aug 08 '20 18:08 rkeithhill

@rkeithhill Sorry for the delay. I continue to have a problem with this error in the picture below. posh-git_error

fabiomen10 avatar Sep 02 '20 03:09 fabiomen10

You need to set the machine's execution policy so that it doesn't require your profile to be digitally signed. Execute the following from an elevated (admin) PowerShell console:

Set-ExecutionPolicy RemoteSigned

rkeithhill avatar Sep 02 '20 03:09 rkeithhill

Thanks @rkeithhill !!! This solves my problem with this message all time I open the PowerShell.

fabiomen10 avatar Sep 02 '20 16:09 fabiomen10