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

can't read "project_name": no such variable (on exit_with_error in exit_if_not_installed) #113

Open
chelmuth opened this issue Jan 6, 2025 · 2 comments
Labels
bug Something isn't working fixed Issue is resolved

Comments

@chelmuth
Copy link
Member

chelmuth commented Jan 6, 2025

If goa fails really early due to missing tools

exit_if_not_installed xmllint git find sed make diff tar wget"
    (file "/home/krishna/bin/goa" line 42)

the output does not help to identify the program missing as project_name is not yet defined.

@chelmuth
Copy link
Member Author

chelmuth commented Jan 6, 2025

Both following patches fix the issue, while I'd prefer the first if there's not implicit tool dependency in command_line.tcl.

+++ b/bin/goa
@@ -39,10 +39,10 @@ if {[llength $argv] == 0} {
 
 source [file join $tool_dir lib util.tcl]
 
-exit_if_not_installed xmllint git find sed make diff tar wget
-
 source [file join $tool_dir lib command_line.tcl]
 
+exit_if_not_installed xmllint git find sed make diff tar wget
+
 source [file join $tool_dir lib actions generic.tcl]
 
 ##################
+++ b/share/goa/lib/util.tcl
@@ -22,6 +22,8 @@ proc stacktrace { } {
 
 proc exit_with_error { args } {
        global project_name verbose
+       if ![info exists project_name] { set project_name "global" }
+       if ![info exists verbose]      { set verbose false }
        puts stderr "\[$project_name\] Error: [join $args { }]"
        if {$verbose} { stacktrace }
        exit 1

jschlatow added a commit that referenced this issue Jan 9, 2025
If goa fails early due to missing tools, `exit_with_error` failed on a
missing variable. This commit makes the utility functions robust
against missing variable definitions.

Fixes #113
@jschlatow
Copy link
Member

Thanks for the patches! Unfortunately, there is a tool dependency in command_line.tcl. I therefore came up with a modified variant of your second patch (see 48833c9).

@jschlatow jschlatow added bug Something isn't working fixed Issue is resolved labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Issue is resolved
Projects
None yet
Development

No branches or pull requests

2 participants