Skip to content

Commit c003c99

Browse files
refactor: enhance runtime installation process with pre-checks and logging
This update improves the InstallRuntime function by adding checks to determine if a runtime is already installed before proceeding with the installation. It also includes logging for both successful installations and errors related to missing binaries after extraction. These changes enhance the user experience by providing clearer feedback during the installation process.
1 parent c325916 commit c003c99

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.cursor/rules/cursor.mdc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ alwaysApply: true
99
## Key Rules
1010
- use fulnames like e.g. feature, instaed of feat
1111
- run go build after each code modification to see if app compiles
12-
- remove dead unused code
12+
- remove dead unused code
13+
- look for constants like file permissons in `constants` folder
1314

1415
## Code Style Guidelines
1516
- **Imports**: Standard lib first, external packages second, internal last
@@ -24,4 +25,4 @@ alwaysApply: true
2425
- `cmd/`: CLI command implementations
2526
- `config/`: Configuration handling
2627
- `tools/`: Tool-specific implementations
27-
- `utils/`: Utility functions and static - look for static like default file permisson here
28+
- `utils/`: Utility functions

config/runtimes-installer.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ func InstallRuntimes(config *ConfigType) error {
4747

4848
// InstallRuntime installs a specific runtime
4949
func InstallRuntime(name string, runtimeInfo *plugins.RuntimeInfo) error {
50+
51+
// Check if the runtime is already installed
52+
if isRuntimeInstalled(runtimeInfo) {
53+
logger.Info("Runtime already installed", logrus.Fields{
54+
"runtime": name,
55+
"version": runtimeInfo.Version,
56+
})
57+
fmt.Printf("Runtime %s v%s is already installed\n", name, runtimeInfo.Version)
58+
return nil
59+
}
60+
5061
// Download and extract the runtime
5162
err := downloadAndExtractRuntime(runtimeInfo)
5263
if err != nil {
@@ -55,6 +66,10 @@ func InstallRuntime(name string, runtimeInfo *plugins.RuntimeInfo) error {
5566

5667
// Verify that the runtime binaries are available
5768
if !isRuntimeInstalled(runtimeInfo) {
69+
logger.Error("Runtime binaries not found after extraction", logrus.Fields{
70+
"runtime": name,
71+
"version": runtimeInfo.Version,
72+
})
5873
return fmt.Errorf("runtime %s was extracted but binaries are not available", name)
5974
}
6075

0 commit comments

Comments
 (0)