@@ -8,7 +8,7 @@ $if windows {
8
8
}
9
9
}
10
10
fn main () {
11
- vexe := pref.vexe_path ()
11
+ vexe := os. real_path ( pref.vexe_path () )
12
12
$if windows {
13
13
setup_symlink_windows (vexe)
14
14
} $else {
@@ -36,10 +36,10 @@ fn setup_symlink(vexe string) {
36
36
if ret.exit_code == 0 {
37
37
println ('Symlink "$link_path " has been created' )
38
38
} else {
39
- println ('Failed to create symlink "$link_path ". Try again with sudo.' )
39
+ eprintln ('Failed to create symlink "$link_path ". Try again with sudo.' )
40
40
}
41
41
} else {
42
- println ('Failed to create symlink "$link_path ". Try again with sudo.' )
42
+ eprintln ('Failed to create symlink "$link_path ". Try again with sudo.' )
43
43
}
44
44
}
45
45
@@ -56,22 +56,24 @@ fn setup_symlink_windows(vexe string) {
56
56
} else {
57
57
os.rm (vsymlink)
58
58
}
59
- // try to create a native symlink at .\.bin\v.exe
59
+ // First, try to create a native symlink at .\.bin\v.exe
60
60
os.symlink (vsymlink, vexe) or {
61
61
// typically only fails if you're on a network drive (VirtualBox)
62
62
// do batch file creation instead
63
- eprint ( 'NOTE: Could not create a native symlink: $err ' )
63
+ eprintln ( ' Could not create a native symlink: $err ' )
64
64
eprintln ('Creating a batch file instead...' )
65
65
vsymlink = os.join_path (vsymlinkdir, 'v.bat' )
66
66
if os.exists (vsymlink) {
67
67
os.rm (vsymlink)
68
68
}
69
69
os.write_file (vsymlink, '@echo off\n $vexe %*' )
70
+ eprintln ('$vsymlink file written.' )
70
71
}
71
72
if ! os.exists (vsymlink) {
72
73
warn_and_exit ('Could not create $vsymlink ' )
73
74
}
74
- print ('Symlink $vsymlink to $vexe created.\n\n Checking system %PATH%...' )
75
+ println ('Symlink $vsymlink to $vexe created.' )
76
+ println ('Checking system %PATH%...' )
75
77
reg_sys_env_handle := get_reg_sys_env_handle () or {
76
78
warn_and_exit (err)
77
79
return
@@ -87,31 +89,36 @@ fn setup_symlink_windows(vexe string) {
87
89
current_sys_paths := sys_env_path.split (os.path_delimiter).map (it .trim ('/$os.path_separator ' ))
88
90
mut new_paths := [vsymlinkdir]
89
91
for p in current_sys_paths {
92
+ if p == '' {
93
+ continue
94
+ }
90
95
if p ! in new_paths {
91
96
new_paths << p
92
97
}
93
98
}
94
99
new_sys_env_path := new_paths.join (';' )
95
100
if new_sys_env_path == sys_env_path {
96
- println ('configured.' )
101
+ println ('System %PATH% was already configured.' )
97
102
} else {
98
- print ('not configured.\n Adding symlink directory to system %PATH%...' )
103
+ println ('System %PATH% was not configured.' )
104
+ println ('Adding symlink directory to system %PATH%...' )
99
105
set_reg_value (reg_sys_env_handle, 'Path' , new_sys_env_path) or {
100
106
warn_and_exit (err)
101
107
C.RegCloseKey (reg_sys_env_handle)
102
108
return
103
109
}
104
110
println ('done.' )
105
111
}
106
- print ( 'Letting running process know to update their Environment...' )
112
+ println ( 'Notifying running processes to update their Environment...' )
107
113
send_setting_change_msg ('Environment' ) or {
108
- eprintln (' \n ' + err)
114
+ eprintln (err)
109
115
warn_and_exit ('You might need to run this again to have the `v` command in your %PATH%' )
110
116
C.RegCloseKey (reg_sys_env_handle)
111
117
return
112
118
}
113
119
C.RegCloseKey (reg_sys_env_handle)
114
- println ('finished.\n\n Note: restart your shell/IDE to load the new %PATH%.' )
120
+ println ('' )
121
+ println ('Note: restart your shell/IDE to load the new %PATH%.' )
115
122
println ('After restarting your shell/IDE, give `v version` a try in another dir!' )
116
123
}
117
124
}
0 commit comments