Skip to content

Commit f188253

Browse files
authored
Merge pull request #140 from initia-labs/fix/extract-file-error
fix: extract snapshot error
2 parents c951bde + c38cd4e commit f188253

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Its primary purpose is to solve several key challenges:
2121

2222
- Operating System: **Linux, macOS**
2323
- Go **v1.23** or higher when building from scratch
24+
- LZ4 compression tool
25+
- For macOS: `brew install lz4`
26+
- For Ubuntu/Debian: `apt-get install lz4`
27+
- For other Linux distributions: Use your package manager to install lz4
2428

2529
> **Important:** While Weave can run as root, it does not support switching users via commands like `sudo su ubuntu` or `su - someuser`. Instead, directly SSH or log in as the user you intend to run Weave with. For example:
2630
>

cmd/root.go

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package cmd
22

33
import (
44
"context"
5+
"fmt"
6+
"os/exec"
57

68
"github.com/spf13/cobra"
79
"github.com/spf13/viper"
@@ -23,6 +25,17 @@ func Execute() error {
2325
return err
2426
}
2527
analytics.Initialize(Version)
28+
29+
// Skip LZ4 check for certain commands that don't need it
30+
if cmd.Name() != "version" && cmd.Name() != "analytics" {
31+
if _, err := exec.LookPath("lz4"); err != nil {
32+
return fmt.Errorf("lz4 is not installed. Please install it first:\n" +
33+
"- For macOS: Run 'brew install lz4'\n" +
34+
"- For Ubuntu/Debian: Run 'apt-get install lz4'\n" +
35+
"- For other Linux distributions: Use your package manager to install lz4")
36+
}
37+
}
38+
2639
return nil
2740
},
2841
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {

models/initia/run_l1_node.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -1864,12 +1864,9 @@ func snapshotExtractor(ctx context.Context) tea.Cmd {
18641864
}
18651865

18661866
cmd := exec.Command("bash", "-c", fmt.Sprintf("lz4 -c -d %s | tar -x -C %s", filepath.Join(userHome, common.WeaveDataDirectory, common.SnapshotFilename), initiaHome))
1867-
cmd.Stdout = os.Stdout
1868-
cmd.Stderr = os.Stderr
1869-
1870-
err = cmd.Run()
1867+
output, err := cmd.CombinedOutput()
18711868
if err != nil {
1872-
return ui.ErrorLoading{Err: fmt.Errorf("[error] Failed to extract snapshot: %v", err)}
1869+
return ui.ErrorLoading{Err: fmt.Errorf("[error] Failed to extract snapshot: %v (output: %s)", err, string(output))}
18731870
}
18741871
return ui.EndLoading{}
18751872
}

0 commit comments

Comments
 (0)