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

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

Open
DanTup opened this issue Jun 20, 2024 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@DanTup
Copy link

DanTup commented Jun 20, 2024

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.

@pingbird
Copy link
Owner

I haven't been able to reproduce this unfortunately and don't have an idea of what could be going wrong, it's possible windows defender has decided puro is sus and shouldn't be allowed to load powershell scripts.

@BenevidesLecontes
Copy link

BenevidesLecontes commented Oct 25, 2024

I'm having this issue as well on macOS Sequoia.
CleanShot 2024-10-25 at 15 30 26@2x

@pingbird pingbird added bug Something isn't working help wanted Extra attention is needed labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants