-
Notifications
You must be signed in to change notification settings - Fork 9
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
Get-LocalizationData
: Cannot find the Windows PowerShell data file
#108
Comments
I created a new issue, because I think you hitting another issue than were you originally posted it. 🤔 I think your hitting an error on this line.
Can you debug the command and see where it fails? I would just throw in verbose or debug messages through out the command to see where it stops outputting, and see what the path it looks for and why it thinks it doesn't exist 🙂 |
FYI. I have not seen this issue before, and a lot of resources in DSC Community is using |
That's fair, thank you. I will try to debug this the coming weekend. In the meantime, the behaviour I am experiencing matches this issue as well: gaelcolas/Sampler#291 |
You listed the UI cultures to If you have simple repro steps on a clean VM I could help debug this. |
This apparently happen when non-unicode is set to, e.g. @lbrauns still debugging, just posting this here from the chatt in Slack/Discord to document it. |
See comment #37 (comment) for further debugging. |
Okay I am a few steps further and I believe I have found the issue. I also think I have spotted a general issue with localization in DSC. Issue Import-LocalizedData does not find localized string file The datatypes between Get-Culture and Get-UICulture differ in WindowsPowerShell: PS C:\Windows\system32> $psversiontable
Name Value
---- -----
PSVersion 5.1.17763.5328
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.5328
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\Windows\system32> (Get-Culture).GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True CultureInfo System.Object
PS C:\Windows\system32> (Get-UICulture).GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False VistaCultureInfo System.Globalization.CultureInfo
PS C:\Windows\system32> In pwsh they are the same: ~#@❯ $psversiontable
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
~#@❯ (get-uiculture).Gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False CultureInfo System.Object
~#@❯ (get-culture).Gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False CultureInfo System.Object
Potentially impossible localization in DSC resources All DSC resources seem to import localized data by calling If we change the module load to
Then it correctly fails because of the wrong filename: DEBUG: Looking for resolved file with base name: 'DSC_VMNetworkAdapter'.
DEBUG: Adding Basedirectory ScriptRoot:
C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter
DEBUG: PARAM: UICulture = en-US
DEBUG: PARAM: FileName = DSC_VMNetworkAdapter.psm1
DEBUG: PARAM: BaseDirectory = C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter
Import-LocalizedData : Cannot find the Windows PowerShell data file 'DSC_VMNetworkAdapter.psd1' in directory
'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\en-US\', or in any parent
culture directories.
At
C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\Modules\DscResource.Common\0.16.0\DscResource.Common.psm1:2631
char:13
+ Import-LocalizedData @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\lb\Des...orkAdapter.psd1:String) [Import-LocalizedData], PSInv
alidOperationException
+ FullyQualifiedErrorId : ImportLocalizedData,Microsoft.PowerShell.Commands.ImportLocalizedData If DSC gets localization data like it does currently, the configured locale never matters at all, even if DSC resources gets translated at one point. Solution would be to change the import of localized data in all affected DSC modules and change the behavior of |
That impressive debugging there! This helped a lot.
According to this I made some assumptions that I put into a new commit in the PR #109. You can see the proposed code here: https://github.com/dsccommunity/DscResource.Common/blob/bb47104e244d0ebaef475269d8166db59b9693ac/source/Public/Get-LocalizedData.ps1 Can you have a look over and see if this could possible solve your problem? If so, please try the code. You find the code in the artifact |
PR works.
|
@johlju I reviewed the code, this looks very good to me. To summarize what I reviewed: The first culture, for which a language file could be located is passed as an argument to |
I did two further tests, both successfully:
Both cases correctly default to en-US and return localized data. $script:localizedData = Get-LocalizedData -UICulture 'de-DE' VERBOSE: Loading module from path 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\Modules\DscResource.Common\0.16.1\DscResource.Common.psd1'.
VERBOSE: Importing function 'Assert-BoundParameter'.
VERBOSE: Importing function 'Assert-ElevatedUser'.
VERBOSE: Importing function 'Assert-IPAddress'.
VERBOSE: Importing function 'Assert-Module'.
VERBOSE: Importing function 'Compare-DscParameterState'.
VERBOSE: Importing function 'Compare-ResourcePropertyState'.
VERBOSE: Importing function 'ConvertFrom-DscResourceInstance'.
VERBOSE: Importing function 'ConvertTo-CimInstance'.
VERBOSE: Importing function 'ConvertTo-HashTable'.
VERBOSE: Importing function 'Find-Certificate'.
VERBOSE: Importing function 'Get-ComputerName'.
VERBOSE: Importing function 'Get-DscProperty'.
VERBOSE: Importing function 'Get-EnvironmentVariable'.
VERBOSE: Importing function 'Get-LocalizedData'.
VERBOSE: Importing function 'Get-LocalizedDataForInvariantCulture'.
VERBOSE: Importing function 'Get-PSModulePath'.
VERBOSE: Importing function 'Get-TemporaryFolder'.
VERBOSE: Importing function 'New-InvalidArgumentException'.
VERBOSE: Importing function 'New-InvalidDataException'.
VERBOSE: Importing function 'New-InvalidOperationException'.
VERBOSE: Importing function 'New-InvalidResultException'.
VERBOSE: Importing function 'New-NotImplementedException'.
VERBOSE: Importing function 'New-ObjectNotFoundException'.
VERBOSE: Importing function 'Remove-CommonParameter'.
VERBOSE: Importing function 'Set-DscMachineRebootRequired'.
VERBOSE: Importing function 'Set-PSModulePath'.
VERBOSE: Importing function 'Test-AccountRequirePassword'.
VERBOSE: Importing function 'Test-DscParameterState'.
VERBOSE: Importing function 'Test-DscProperty'.
VERBOSE: Importing function 'Test-IsNanoServer'.
VERBOSE: Importing function 'Test-IsNumericType'.
DEBUG: Looking for resolved file with base name: 'DSC_VMNetworkAdapter'.
DEBUG: Using specified culture:
LCID Name DisplayName
---- ---- -----------
1031 de-DE German (Germany)
DEBUG: Looking for Localized data file using the current culture 'de-DE'.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\de-DE\DSC_VMNetworkAdapter.psd1' not found.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\de-DE\DSC_VMNetworkAdapter.strings.psd1' not found.
DEBUG: Did not find matching file for current culture, testing parent culture:
LCID Name DisplayName
---- ---- -----------
7 de German
DEBUG: Looking for Localized data file using the current culture 'de'.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\de\DSC_VMNetworkAdapter.psd1' not found.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\de\DSC_VMNetworkAdapter.strings.psd1' not found.
DEBUG: Did not find matching file for current or parent culture, testing default culture:
LCID Name DisplayName
---- ---- -----------
1033 en-US English (United States)
DEBUG: Setting parameter UICulture to 'en-US'.
DEBUG: Looking for Localized data file using the current culture 'en-US'.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\en-US\DSC_VMNetworkAdapter.psd1' not found.
DEBUG: Found 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\en-US\DSC_VMNetworkAdapter.strings.psd1'.
DEBUG: Calling Microsoft.PowerShell.Utility\Import-LocalizedData using parameters:
Key Value
--- -----
UICulture en-US
FileName DSC_VMNetworkAdapter.strings.psd1
BaseDirectory C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter
DEBUG: Returning localized data.
VERBOSE: Exporting function 'Get-TargetResource'.
VERBOSE: Exporting function 'Set-TargetResource'.
VERBOSE: Exporting function 'Test-TargetResource'.
DEBUG: Invoking command 'Test-VMNetworkAdapterTargetResource'. Specifying a non-existent culture correctly falls back to en-US $script:localizedData = Get-LocalizedData -UICulture 'ab-CD' VERBOSE: Loading module from path 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\Modules\DscResource.Common\0.16.1\DscResource.Common.psd1'.
VERBOSE: Importing function 'Assert-BoundParameter'.
VERBOSE: Importing function 'Assert-ElevatedUser'.
VERBOSE: Importing function 'Assert-IPAddress'.
VERBOSE: Importing function 'Assert-Module'.
VERBOSE: Importing function 'Compare-DscParameterState'.
VERBOSE: Importing function 'Compare-ResourcePropertyState'.
VERBOSE: Importing function 'ConvertFrom-DscResourceInstance'.
VERBOSE: Importing function 'ConvertTo-CimInstance'.
VERBOSE: Importing function 'ConvertTo-HashTable'.
VERBOSE: Importing function 'Find-Certificate'.
VERBOSE: Importing function 'Get-ComputerName'.
VERBOSE: Importing function 'Get-DscProperty'.
VERBOSE: Importing function 'Get-EnvironmentVariable'.
VERBOSE: Importing function 'Get-LocalizedData'.
VERBOSE: Importing function 'Get-LocalizedDataForInvariantCulture'.
VERBOSE: Importing function 'Get-PSModulePath'.
VERBOSE: Importing function 'Get-TemporaryFolder'.
VERBOSE: Importing function 'New-InvalidArgumentException'.
VERBOSE: Importing function 'New-InvalidDataException'.
VERBOSE: Importing function 'New-InvalidOperationException'.
VERBOSE: Importing function 'New-InvalidResultException'.
VERBOSE: Importing function 'New-NotImplementedException'.
VERBOSE: Importing function 'New-ObjectNotFoundException'.
VERBOSE: Importing function 'Remove-CommonParameter'.
VERBOSE: Importing function 'Set-DscMachineRebootRequired'.
VERBOSE: Importing function 'Set-PSModulePath'.
VERBOSE: Importing function 'Test-AccountRequirePassword'.
VERBOSE: Importing function 'Test-DscParameterState'.
VERBOSE: Importing function 'Test-DscProperty'.
VERBOSE: Importing function 'Test-IsNanoServer'.
VERBOSE: Importing function 'Test-IsNumericType'.
DEBUG: Looking for resolved file with base name: 'DSC_VMNetworkAdapter'.
DEBUG: Using specified culture:
LCID Name DisplayName
---- ---- -----------
4096 ab-CD Unknown Locale (ab-CD)
DEBUG: Looking for Localized data file using the current culture 'ab-CD'.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\ab-CD\DSC_VMNetworkAdapter.psd1' not found.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\ab-CD\DSC_VMNetworkAdapter.strings.psd1' not found.
DEBUG: Did not find matching file for current culture, testing parent culture:
LCID Name DisplayName
---- ---- -----------
4096 ab Unknown Language (ab)
DEBUG: Looking for Localized data file using the current culture 'ab'.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\ab\DSC_VMNetworkAdapter.psd1' not found.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\ab\DSC_VMNetworkAdapter.strings.psd1' not found.
DEBUG: Did not find matching file for current or parent culture, testing default culture:
LCID Name DisplayName
---- ---- -----------
1033 en-US English (United States)
DEBUG: Setting parameter UICulture to 'en-US'.
DEBUG: Looking for Localized data file using the current culture 'en-US'.
DEBUG: File 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\en-US\DSC_VMNetworkAdapter.psd1' not found.
DEBUG: Found 'C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter\en-US\DSC_VMNetworkAdapter.strings.psd1'.
DEBUG: Calling Microsoft.PowerShell.Utility\Import-LocalizedData using parameters:
Key Value
--- -----
UICulture en-US
FileName DSC_VMNetworkAdapter.strings.psd1
BaseDirectory C:\Users\lb\Desktop\Dbg_Lability\DSCResources\HyperVDsc\DSCResources\DSC_VMNetworkAdapter
DEBUG: Returning localized data.
VERBOSE: Exporting function 'Get-TargetResource'.
VERBOSE: Exporting function 'Set-TargetResource'.
VERBOSE: Exporting function 'Test-TargetResource'. |
This is great! Then it works with passing just |
I still get the error in HyperVDSC 4.0.0-preview0005 (updated the bundled DscResources.Common to the current 0.16) and xPSDesiredStateConfiguration 9.2.0-preview0008 (already bundles DscResources.Common 0.16).
To me it looks like I am running into the condition
if ([String]::IsNullOrEmpty($languageFile))
.But
$languageFile
cannot be empty, the debug message shows a found file. Therefore$languageFile
should be set to$filePath
and break the foreach loop...Note the filepath in the above error record, which indicated that the file was also searched in the parent locale (
en
).To be honest, I am totally lost as why this happens...
Additional Information:
Running on Windows PowerShell 5.1:
The UICulture is en-US:
Originally posted by @lbrauns in #37 (comment)
The text was updated successfully, but these errors were encountered: