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

Module produces error if imported more than once (PS v2 only) #69

Closed
ALuckyGuy opened this issue Apr 11, 2016 · 5 comments
Closed

Module produces error if imported more than once (PS v2 only) #69

ALuckyGuy opened this issue Apr 11, 2016 · 5 comments
Assignees
Milestone

Comments

@ALuckyGuy
Copy link

If the module has already been loaded and is then loaded again - for instance, by a script that has the import-module command embedded in it - then the errors shown below are produced.

Update-FormatData : There were errors in loading the format data file:
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSjob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Users\greenwt\Documents\WindowsPowerShell\Modules\PoshRSJob\TypeData\PoshRSJob.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".

Another quick way to reproduce it:

import-module PoshRSJob
import-module PoshRSJob -Force

The errors are produced by the two commands shown below in PoshRSJob.psm1:

#region Format and Type Data
Update-FormatData "$ScriptPath\TypeData\PoshRSJob.Format.ps1xml"
Update-TypeData "$ScriptPath\TypeData\PoshRSJob.Types.ps1xml"
#endregion Format and Type Data
@proxb proxb self-assigned this Apr 11, 2016
@proxb proxb added this to the 1.5.7.2 milestone Apr 11, 2016
@proxb
Copy link
Owner

proxb commented Apr 12, 2016

Yea, V2 seems to make more noise when type formatting already exists. Hopefully a Try/Catch can silence that issue.

@ALuckyGuy
Copy link
Author

For reasons I don't understand, try/catch hasn't worked here. Really no idea why. I did find using -erroraction SilentlyContinue works, but that's not ideal either.

@proxb
Copy link
Owner

proxb commented Apr 12, 2016

I don't really know of a good way to get around this in V2. I suppose -ErrorAction SilentlyContinue might have to be the answer. I need to look at this in DotPeek and see how it works in V3.

@ALuckyGuy
Copy link
Author

Another way to do this is to define a variable after the Update commands and only do the update if the variable isn't defined. Doesn't give you a means to -Force an update of the type files, but then again since I don't think there's a command for uninstalling the type files, I think a PowerShell restart is necessary anyway in that case.

@proxb proxb modified the milestones: 1.5.7.3, 1.5.7.2, 1.5.7.4 Apr 29, 2016
@proxb
Copy link
Owner

proxb commented May 2, 2016

Bumping this to the next version so I can test a little more before pushing out an update.

@proxb proxb modified the milestones: 1.5.7.5, 1.5.7.4 May 16, 2016
@proxb proxb closed this as completed in 5991c56 May 16, 2016
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

2 participants