Skip to content

Commit d6f78fa

Browse files
joa-quimclaude
andcommitted
iview_app.vbs: resolve install path via Julia at every launch, not self
Self-locating-to-own-folder broke the moment this file was copied anywhere outside the exact checkout it launched from -- and a plain Pkg.add install lives in a content-hashed folder that changes on every Pkg.update, so a Desktop shortcut pointing at it (or a copy of it) went stale on every update. Now it asks Julia fresh each launch (Base.find_package -- reads the Manifest, doesn't load the package) and runs from whatever that resolves to. Works unmodified for the dev checkout too (dev'd packages resolve the same way). Verified: dry-run with an argument forwards correctly, quoting intact. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 8ca2e04 commit d6f78fa

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

iview_app.vbs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,46 @@
22
' STARTUPINFO SW_HIDE, which the Qt GUI window would inherit and stay invisible. iview_app.jl
33
' hides its own console on startup, so only the viewer window remains.
44
'
5-
' Self-locating (same trick as deps/installer/iview_launch.vbs): finds its own folder at runtime
6-
' instead of hardcoding a julia.exe path + dev checkout path, so this works on any machine/checkout
7-
' without editing. Calls `julia` bare (from PATH) with --project pointed at this same folder.
5+
' Resolves InteractiveGMT's install path by ASKING JULIA at every launch (Base.find_package —
6+
' just reads the active project's Manifest, does not load/precompile the package) instead of
7+
' hardcoding a location. This matters because a git-based Pkg install lives in a content-hashed
8+
' folder (~/.julia/packages/InteractiveGMT/<hash>/) that gets a NEW <hash> on every
9+
' `Pkg.update("InteractiveGMT")` — a script that instead finds its OWN folder (fso.GetParentFolderName)
10+
' would go stale the moment you copy it to a Desktop shortcut and then update. Asking Julia fresh
11+
' every time means the SAME copy of this file — wherever you put it, including a Desktop shortcut
12+
' — keeps working across every future update, no re-copying, ever.
13+
'
14+
' Also works unmodified for a plain dev checkout (this file run in place): Base.find_package
15+
' resolves `dev`ed packages from the Manifest too, same as `add`ed ones.
16+
'
17+
' The lookup expression is written to a temp .jl file rather than passed inline on the command
18+
' line, to sidestep Windows/VBScript quote-escaping entirely.
819
'
920
' Files dropped ONTO the desktop shortcut arrive here as WScript.Arguments; we forward each path
1021
' to Julia, and iview_app.jl opens it (otherwise, with no args, it opens an empty launcher).
1122
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
12-
Dim here : here = fso.GetParentFolderName(WScript.ScriptFullName)
13-
Dim sh : Set sh = CreateObject("WScript.Shell")
23+
Dim sh : Set sh = CreateObject("WScript.Shell")
24+
25+
Dim tmp : tmp = sh.ExpandEnvironmentStrings("%TEMP%") & "\igmt_locate_" & CStr(Timer) & ".jl"
26+
Dim f : Set f = fso.CreateTextFile(tmp, True)
27+
f.WriteLine "p = Base.find_package(" & Chr(34) & "InteractiveGMT" & Chr(34) & ")"
28+
f.WriteLine "print(p === nothing ? " & Chr(34) & Chr(34) & " : dirname(dirname(p)))"
29+
f.Close
30+
31+
Dim ex : Set ex = sh.Exec("julia --startup-file=no " & Chr(34) & tmp & Chr(34))
32+
Dim here : here = Trim(ex.StdOut.ReadAll())
33+
fso.DeleteFile tmp, True
34+
35+
If here = "" Then
36+
MsgBox "Could not locate InteractiveGMT." & vbCrLf & _
37+
"Is it added ('] add https://github.com/GenericMappingTools/InteractiveGMT') or dev'd in Julia's default environment?", _
38+
vbExclamation, "iGMT"
39+
WScript.Quit 1
40+
End If
41+
1442
Dim extra : extra = ""
1543
Dim i
1644
For i = 0 To WScript.Arguments.Count - 1
17-
extra = extra & " """ & WScript.Arguments(i) & """"
45+
extra = extra & " " & Chr(34) & WScript.Arguments(i) & Chr(34)
1846
Next
19-
sh.Run "julia --project=""" & here & """ """ & here & "\iview_app.jl""" & extra, 7, False
47+
sh.Run "julia --project=" & Chr(34) & here & Chr(34) & " " & Chr(34) & here & "\iview_app.jl" & Chr(34) & extra, 7, False

0 commit comments

Comments
 (0)