Skip to content

Unable to "puro use stable" (CouldNotAutoloadMatchingModule PowerShell error) #89

@DanTup

Description

@DanTup

This seems similar to #47 but that was marked as resolved. I was trying to test something with Puro but I've spent quite a while wrestling to try and get it to run.

Each time I run puro use stable I get a failure like this:

[W] dart version check failed, deleting cache
[E] powershell: Import-Module : File C:\program
    files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1 cannot be loaded because
    running scripts is disabled on this system. For more information, see about_Execution_Policies at
    https:/go.microsoft.com/fwlink/?LinkID=135170.
    At line:1 char:1
    + Import-Module Microsoft.PowerShell.Archive; Expand-Archive C:\Users\d ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
        + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
    Expand-Archive : The 'Expand-Archive' command was found in the module 'Microsoft.PowerShell.Archive', but the module
    could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Archive'.
    At line:1 char:45
    + Import-Module Microsoft.PowerShell.Archive; Expand-Archive C:\Users\d ...
    +                                             ~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Expand-Archive:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule


[x] Assertion failed: "powershell subprocess failed with exit code 1"
    #0      runProcess (package:puro/src/process.dart:121)
    <asynchronous suspension>
    #1      unzip (package:puro/src/env/engine.dart:153)

The first error ("cannot be loaded because
running scripts is disabled on this system. For more information, see about_Execution_Policies") suggests an execution policy issue, but I've tried setting this to both Bypass and Unrestricted and there's no change:

PS C:\Dev> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine    Unrestricted

The error also says:

The 'Expand-Archive' command was found in the module 'Microsoft.PowerShell.Archive', but the module
    could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Archive'.

However running that command manually in the shell works fine:

PS C:\Dev\Test Projects\puro_test> Import-Module Microsoft.PowerShell.Archive
PS C:\Dev\Test Projects\puro_test>

I'm not really sure what else to try. The file in the error (C:\program files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1) does exist.

Also, when this error happens, the environments folder seems to be left in a broken state because trying to run the command again results in errors like:

PS C:\Dev\Test Projects\puro_test> puro use stable
[E] Exception while installing IntelliJ config
[E] PathNotFoundException: Cannot open file, path = 'C:\Users\danny\.puro\envs\stable\flutter\bin\cache\dart-sdk\lib\_internal\sdk_library_metadata\lib\libraries.dart' (OS Error: The system cannot find the path specified.
    , errno = 3)
    #0      _checkForErrorResponse (dart:io/common.dart:55)
    #1      _File.open.<anonymous closure> (dart:io/file_impl.dart:381)
    <asynchronous suspension>
    #2      _File.readAsBytes.<anonymous closure> (dart:io/file_impl.dart:562)
    <asynchronous suspension>
    #3      _File.readAsString (dart:io/file_impl.dart:621)
    <asynchronous suspension>
    #4      LineSplitter.convert (dart:convert/line_splitter.dart:52)
    <asynchronous suspension>
    #5      IntelliJConfig.save (package:puro/src/workspace/intellij.dart:84)

So I have to manually delete the stable folder before trying again (which is quite a pain while repeatedly trying to resolve the issue).

I'm on Windows 11 Pro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    Status

    Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions