puro icon indicating copy to clipboard operation
puro copied to clipboard

`puro rm -f` removes the base version even when two envs share it

Open FMorschel opened this issue 10 months ago • 4 comments

@pingbird, I had two envs set to the same version. I ran puro rm env1 -f since it was being used by a project. Now when I do puro ls:

[i] Environments:
    * stable     (stable / 3.27.3 / c519ee916e)
      beta       (beta / 3.23.0-0.1.pre / 2feea7a407)
      master     (3.29.0-1.0.pre.114 / a16de734bd)
      produtores (unknown)

And when I do puro rm produtores -f this is the output:

FileSystemException: Cannot resolve symbolic links, path = 'C:\Users\felip_0vh5fa6\.puro\envs\produtores\flutter\bin\cache\dart-sdk\bin\dart.exe' (OS Error: The system cannot find the path specified.
    , errno = 3)
    #0      FileSystemEntity._throwIfError (dart:io/file_system_entity.dart:826)
    #1      FileSystemEntity.resolveSymbolicLinksSync (dart:io/file_system_entity.dart:357)
    #2      ForwardingFileSystemEntity.resolveSymbolicLinksSync (package:file/src/forwarding/forwarding_file_system_entity.dart:56)
    #3      deleteEnvironment (package:puro/src/env/delete.dart:64)
    <asynchronous suspension>
    #4      EnvRmCommand.run (package:puro/src/commands/env_rm.dart:27)
    <asynchronous suspension>
    #5      CommandRunner.runCommand (package:args/command_runner.dart:212)
    <asynchronous suspension>
    #6      main (package:puro/src/cli.dart:279)
    <asynchronous suspension>

[x] Puro crashed! Please file an issue at https://github.com/pingbird/puro
    Consider running the command with a higher log level: `--log-level=4`

I think -f ignored that another env was using the same version and deleted it all and not only the symlink.

FMorschel avatar Jan 28 '25 12:01 FMorschel

Now I also can't upgrade:

[E] git: fatal: not a git repository (or any of the parent directories): .git
[x] Bad state: git subprocess failed with exit code 128
    #0      GitClient._ensureSuccess (package:puro/src/git.dart:109)
    #1      GitClient.revParse (package:puro/src/git.dart:340)
    <asynchronous suspension>
    #2      GitClient.revParseSingle (package:puro/src/git.dart:351)
PS C:\Users\felip_0vh5fa6\SUNSIG\trunk\Delphiap\Desenvol\Sunsoft Flutter\Gestor\gestor> puro upgrade produtores 3.27.0
[E] git: fatal: not a git repository (or any of the parent directories): .git
[x] Bad state: git subprocess failed with exit code 128
    #0      GitClient._ensureSuccess (package:puro/src/git.dart:109)
    #1      GitClient.revParse (package:puro/src/git.dart:340)
    <asynchronous suspension>
    #2      GitClient.revParseSingle (package:puro/src/git.dart:351)
    <asynchronous suspension>
    #3      GitClient.getCurrentCommitHash (package:puro/src/git.dart:437)
    <asynchronous suspension>
    #4      upgradeEnvironment (package:puro/src/env/upgrade.dart:78)
    <asynchronous suspension>
    #5      CommandRunner.runCommand (package:args/command_runner.dart:212)
    <asynchronous suspension>
    #6      main (package:puro/src/cli.dart:279)
    <asynchronous suspension>

[x] Puro crashed! Please file an issue at https://github.com/pingbird/puro
    Consider running the command with a higher log level: `--log-level=4`

Do you want me to run it with --log-level=4?

FMorschel avatar Jan 28 '25 12:01 FMorschel

Also, one last thing, how should I remove this produtores env?

FMorschel avatar Jan 28 '25 12:01 FMorschel

The original error seems to be a red herring, it means the environment directory failed to be deleted for some reason, try deleting C:\Users\felip_0vh5fa6\.puro\envs\produtores manually

I've fixed the bug that hid the original error, there's likely a running process with a handle on something in the environment

pingbird avatar Feb 14 '25 17:02 pingbird

I've deleted the folder manually already, thanks!

I'm unsure if I was clear enough with what caused this so:

Both produtores and env1 had the same version. Thats why the issue is called this way. I feel like something was deleted internally on shared that was used by produtores and then we couldn't know the version anymore.

I've fixed the bug that hid the original error

Thanks!

FMorschel avatar Feb 14 '25 17:02 FMorschel