ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / cli / src / util / prereqs.rs 407 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
use std:: cmp:: Ordering ;
use crate :: constants:: QUALITYLESS_SERVER_NAME ;
use crate :: update_service:: Platform ;
use regex:: bytes:: Regex as BinRegex ;
use regex:: Regex ;
use std:: sync:: LazyLock ;
use tokio:: fs;
use super :: errors:: CodeError ;
is_nixos skip_glibc_checks or_musl
gnu_a gnu_b skip_glibc_checks
gnu_a gnu_b is_nixos
_ _ _
target_arch
target_arch
_
or_musl
target_arch
errors
e gnu_a
errors e
e gnu_b
errors e
e or_musl
errors e
bullets errors
bullets
name
target_arch
version
v
v v
v v
v
version
o stdout
v version
v
v
libstdc_path
libstdc_path
libstdc_path
o stdout
libstdc_path
path path
contents contents
e
contents
max_version
contents
major m s
minor m s
patch m s
max_version max_version
max_version
max_version
from
output
output
major m s
minor m s
patch
output
output
major m s
minor m s
patch
output
output
l
cap
cap
b
b
major
minor
patch
other
other
other
major major other major
major
major
minor minor other minor
minor
minor
patch other patch
s
s major s minor s patch
f
f
major minor patch
major
minor
patch
actual
actual
actual
actual
actual2
actual2
static
LDCONFIG_STDC_RE
:
LazyLock
<
Regex
>
=
LazyLock
::
new
(
| |
Regex
::
new
(
r"libstdc\+\+.* => (.+)"
)
.
unwrap
(
)
)
;
static
LDD_VERSION_RE
:
LazyLock
<
BinRegex
>
=
LazyLock
::
new
(
| |
BinRegex
::
new
(
r"^ldd.*\s(\d+)\.(\d+)(?:\.(\d+))?\s"
)
.
unwrap
(
)
)
;
static
GENERIC_VERSION_RE
:
LazyLock
<
Regex
>
=
LazyLock
::
new
(
| |
Regex
::
new
(
r"^([0-9]+)\.([0-9]+)$"
)
.
unwrap
(
)
)
;
#[cfg(target_os = "linux" )]
static
LIBSTD_CXX_VERSION_RE
:
LazyLock
<
BinRegex
>
=
LazyLock
::
new
(
| |
BinRegex
::
new
(
r"GLIBCXX_([0-9]+)\.([0-9]+)(?:\.([0-9]+))?"
)
.
unwrap
(
)
)
;
#[cfg(target_os = "linux" )]
static
MIN_LDD_VERSION
:
LazyLock
<
SimpleSemver
>
=
LazyLock
::
new
(
| |
SimpleSemver
::
new
(
2
,
28
,
0
)
)
;
#[cfg(target_os = "linux" )]
#[cfg(target_arch = "arm" )]
static
MIN_CXX_VERSION
:
LazyLock
<
SimpleSemver
>
=
LazyLock
::
new
(
| |
SimpleSemver
::
new
(
3
,
4
,
26
)
)
;
#[cfg(target_os = "linux" )]
#[cfg(not(target_arch = "arm" ))]
static
MIN_CXX_VERSION
:
LazyLock
<
SimpleSemver
>
=
LazyLock
::
new
(
| |
SimpleSemver
::
new
(
3
,
4
,
25
)
)
;
const
NIXOS_TEST_PATH
:
&
str
=
"/etc/NIXOS"
;
pub
struct
PreReqChecker
{
}
impl
Default
for
PreReqChecker
{
fn
default
(
)
->
Self
{
Self
::
new
(
)
}
}
impl
PreReqChecker
{
pub
fn
new
(
)
->
PreReqChecker
{
PreReqChecker
{
}
}
#[cfg(not(target_os = "linux" ))]
pub
async
fn
verify
(
&
self
)
->
Result
<
Platform
,
CodeError
>
{
Platform
::
env_default
(
)
.
ok_or_else
(
| |
{
CodeError
::
UnsupportedPlatform
(
format!
(
"{} {}"
,
std:: env:: consts::
OS
,
std:: env:: consts::
ARCH
)
)
}
)
}
#[cfg(target_os = "linux" )]
pub
async
fn
verify
(
&
self
)
->
Result
<
Platform
,
CodeError
>
{
let
(
,
,
)
=
tokio::
join!
(
check_is_nixos
(
)
,
skip_requirements_check
(
)
,
check_musl_interpreter
(
)
)
;
let
(
,
)
=
if
!
{
tokio::
join!
(
check_glibc_version
(
)
,
check_glibcxx_version
(
)
)
}
else
{
println!
(
"!!! WARNING: Skipping server pre-requisite check !!!"
)
;
println!
(
"!!! Server stability is not guaranteed. Proceed at your own risk. !!!"
)
;
(
Ok
(
true
)
,
Ok
(
true
)
)
}
;
match
(
&
,
&
,
)
{
(
Ok
(
true
)
,
Ok
(
true
)
,
)
|
(
,
,
true
)
=>
{
return
Ok
(
if
cfg!
(
=
"x86_64"
)
{
Platform
::
LinuxX64
}
else
if
cfg!
(
=
"arm"
)
{
Platform
::
LinuxARM32
}
else
{
Platform
::
LinuxARM64
}
)
;
}
=>
{
}
}
;
if
.
is_ok
(
)
{
return
Ok
(
if
cfg!
(
=
"x86_64"
)
{
Platform
::
LinuxAlpineX64
}
else
{
Platform
::
LinuxAlpineARM64
}
)
;
}
let
mut
:
Vec
<
String
>
=
vec!
[
]
;
if
let
Err
(
)
=
{
.
push
(
)
;
}
else
if
let
Err
(
)
=
{
.
push
(
)
;
}
if
let
Err
(
)
=
{
.
push
(
)
;
}
let
=
.
iter
(
)
.
map
(
| e|
format!
(
" - {e}"
)
)
.
collect
::
<
Vec
<
String
>>
(
)
.
join
(
"\n"
)
;
Err
(
CodeError
::
PrerequisitesFailed
{
,
:
QUALITYLESS_SERVER_NAME
,
}
)
}
}
#[allow(dead_code)]
async
fn
check_musl_interpreter
(
)
->
Result
<
(
)
,
String
>
{
const
MUSL_PATH
:
&
str
=
if
cfg!
(
=
"aarch64"
)
{
"/lib/ld-musl-aarch64.so.1"
}
else
{
"/lib/ld-musl-x86_64.so.1"
}
;
if
fs::
metadata
(
MUSL_PATH
)
.
await
.
is_err
(
)
{
return
Err
(
format!
(
"find {MUSL_PATH}, which is required to run the {QUALITYLESS_SERVER_NAME} in musl environments"
)
)
;
}
Ok
(
(
)
)
}
#[cfg(target_os = "linux" )]
async
fn
check_glibc_version
(
)
->
Result
<
bool
,
String
>
{
#[cfg(target_env = "gnu" )]
let
=
{
let
=
unsafe
{
libc::
gnu_get_libc_version
(
)
}
;
let
=
unsafe
{
std:: ffi::
CStr
::
from_ptr
(
)
}
;
let
=
.
to_str
(
)
.
unwrap
(
)
;
extract_generic_version
(
)
}
;
#[cfg(not(target_env = "gnu" ))]
let
=
{
super
:: command::
capture_command
(
"ldd"
,
[
"--version"
]
)
.
await
.
ok
(
)
.
and_then
(
| o|
extract_ldd_version
(
&
.
)
)
}
;
if
let
Some
(
)
=
{
return
if
>=
*
MIN_LDD_VERSION
{
Ok
(
true
)
}
else
{
Err
(
format!
(
"find GLIBC >= {} (but found {} instead) for GNU environments"
,
*
MIN_LDD_VERSION
,
)
)
}
;
}
Ok
(
false
)
}
#[allow(dead_code)]
async
fn
check_is_nixos
(
)
->
bool
{
fs::
metadata
(
NIXOS_TEST_PATH
)
.
await
.
is_ok
(
)
}
#[cfg(not(windows))]
pub
async
fn
skip_requirements_check
(
)
->
bool
{
std:: env::
var
(
"VSCODE_SERVER_CUSTOM_GLIBC_LINKER"
)
.
is_ok
(
)
||
fs::
metadata
(
"/tmp/vscode-skip-server-requirements-check"
)
.
await
.
is_ok
(
)
}
#[cfg(windows)]
pub
async
fn
skip_requirements_check
(
)
->
bool
{
false
}
#[cfg(target_os = "linux" )]
async
fn
check_glibcxx_version
(
)
->
Result
<
bool
,
String
>
{
let
mut
:
Option
<
String
>
=
None
;
#[cfg(any(target_arch = "x86_64" , target_arch = "aarch64" ))]
const
DEFAULT_LIB_PATH
:
&
str
=
"/usr/lib64/libstdc++.so.6"
;
#[cfg(any(target_arch = "x86" , target_arch = "arm" ))]
const
DEFAULT_LIB_PATH
:
&
str
=
"/usr/lib/libstdc++.so.6"
;
const
LDCONFIG_PATH
:
&
str
=
"/sbin/ldconfig"
;
if
fs::
metadata
(
DEFAULT_LIB_PATH
)
.
await
.
is_ok
(
)
{
=
Some
(
DEFAULT_LIB_PATH
.
to_owned
(
)
)
;
}
else
if
fs::
metadata
(
LDCONFIG_PATH
)
.
await
.
is_ok
(
)
{
=
super
:: command::
capture_command
(
LDCONFIG_PATH
,
[
"-p"
]
)
.
await
.
ok
(
)
.
and_then
(
| o|
extract_libstd_from_ldconfig
(
&
.
)
)
;
}
match
{
Some
(
)
=>
match
fs::
read
(
&
)
.
await
{
Ok
(
)
=>
check_for_sufficient_glibcxx_versions
(
)
,
Err
(
)
=>
Err
(
format!
(
"validate GLIBCXX version for GNU environments, but could not: {e}"
)
)
,
}
,
None
=>
Err
(
"find libstdc++.so or ldconfig for GNU environments"
.
to_owned
(
)
)
,
}
}
#[cfg(target_os = "linux" )]
fn
check_for_sufficient_glibcxx_versions
(
:
Vec
<
u8
>
)
->
Result
<
bool
,
String
>
{
let
=
LIBSTD_CXX_VERSION_RE
.
captures_iter
(
&
)
.
map
(
| m|
SimpleSemver
{
:
.
get
(
1
)
.
map_or
(
0
,
| s|
u32_from_bytes
(
.
as_bytes
(
)
)
)
,
:
.
get
(
2
)
.
map_or
(
0
,
| s|
u32_from_bytes
(
.
as_bytes
(
)
)
)
,
:
.
get
(
3
)
.
map_or
(
0
,
| s|
u32_from_bytes
(
.
as_bytes
(
)
)
)
,
}
)
.
max
(
)
;
if
let
Some
(
)
=
&
{
if
>=
&
*
MIN_CXX_VERSION
{
return
Ok
(
true
)
;
}
}
Err
(
format!
(
"find GLIBCXX >= {} (but found {} instead) for GNU environments"
,
*
MIN_CXX_VERSION
,
.
as_ref
(
)
.
map
(
String
::
)
.
unwrap_or
(
"none"
.
to_string
(
)
)
)
)
}
#[allow(dead_code)]
fn
extract_ldd_version
(
:
&
[
u8
]
)
->
Option
<
SimpleSemver
>
{
LDD_VERSION_RE
.
captures
(
)
.
map
(
| m|
SimpleSemver
{
:
.
get
(
1
)
.
map_or
(
0
,
| s|
u32_from_bytes
(
.
as_bytes
(
)
)
)
,
:
.
get
(
2
)
.
map_or
(
0
,
| s|
u32_from_bytes
(
.
as_bytes
(
)
)
)
,
:
0
,
}
)
}
#[allow(dead_code)]
fn
extract_generic_version
(
:
&
str
)
->
Option
<
SimpleSemver
>
{
GENERIC_VERSION_RE
.
captures
(
)
.
map
(
| m|
SimpleSemver
{
:
.
get
(
1
)
.
map_or
(
0
,
| s|
.
as_str
(
)
.
parse
(
)
.
unwrap
(
)
)
,
:
.
get
(
2
)
.
map_or
(
0
,
| s|
.
as_str
(
)
.
parse
(
)
.
unwrap
(
)
)
,
:
0
,
}
)
}
#[allow(dead_code)]
fn
extract_libstd_from_ldconfig
(
:
&
[
u8
]
)
->
Option
<
String
>
{
String
::
from_utf8_lossy
(
)
.
lines
(
)
.
find_map
(
| l|
LDCONFIG_STDC_RE
.
captures
(
)
)
.
and_then
(
| cap|
.
get
(
1
)
)
.
map
(
| cap|
.
as_str
(
)
.
to_owned
(
)
)
}
fn
u32_from_bytes
(
:
&
[
u8
]
)
->
u32
{
String
::
from_utf8_lossy
(
)
.
parse
::
<
u32
>
(
)
.
unwrap_or
(
0
)
}
#[derive(Debug, Default, PartialEq, Eq)]
struct
SimpleSemver
{
:
u32
,
:
u32
,
:
u32
,
}
impl
PartialOrd
for
SimpleSemver
{
fn
partial_cmp
(
&
self
,
:
&
Self
)
->
Option
<
Ordering
>
{
Some
(
self
.
cmp
(
)
)
}
}
impl
Ord
for
SimpleSemver
{
fn
cmp
(
&
self
,
:
&
Self
)
->
Ordering
{
let
=
self
.
.
cmp
(
&
.
)
;
if
!=
Ordering
::
Equal
{
return
;
}
let
=
self
.
.
cmp
(
&
.
)
;
if
!=
Ordering
::
Equal
{
return
;
}
self
.
.
cmp
(
&
.
)
}
}
impl
From
<
&
SimpleSemver
>
for
String
{
fn
from
(
:
&
SimpleSemver
)
->
Self
{
format!
(
"v{}.{}.{}"
,
.
,
.
,
.
)
}
}
impl
std:: fmt::
Display
for
SimpleSemver
{
fn
fmt
(
&
self
,
:
&
mut
std:: fmt::
Formatter
)
->
std:: fmt::
Result
{
write!
(
,
"{}"
,
String
::
from
(
self
)
)
}
}
#[allow(dead_code)]
impl
SimpleSemver
{
fn
new
(
:
u32
,
:
u32
,
:
u32
)
->
SimpleSemver
{
SimpleSemver
{
,
,
,
}
}
}
#[cfg(test)]
mod
tests
{
use
super
::
*
;
#[test]
fn
test_extract_libstd_from_ldconfig
(
)
{
let
=
"
libstoken.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libstoken.so.1
libstemmer.so.0d (libc6,x86-64) => /lib/x86_64-linux-gnu/libstemmer.so.0d
libstdc++.so.6 (libc6,x86-64) => /lib/x86_64-linux-gnu/libstdc++.so.6
libstartup-notification-1.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libstartup-notification-1.so.0
libssl3.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libssl3.so
"
.
to_owned
(
)
.
into_bytes
(
)
;
assert_eq!
(
extract_libstd_from_ldconfig
(
&
)
,
Some
(
"/lib/x86_64-linux-gnu/libstdc++.so.6"
.
to_owned
(
)
)
,
)
;
assert_eq!
(
extract_libstd_from_ldconfig
(
&
"nothing here!"
.
to_owned
(
)
.
into_bytes
(
)
)
,
None
,
)
;
}
#[test]
fn
test_gte
(
)
{
assert!
(
SimpleSemver
::
new
(
1
,
2
,
3
)
>=
SimpleSemver
::
new
(
1
,
2
,
3
)
)
;
assert!
(
SimpleSemver
::
new
(
1
,
2
,
3
)
>=
SimpleSemver
::
new
(
0
,
10
,
10
)
)
;
assert!
(
SimpleSemver
::
new
(
1
,
2
,
3
)
>=
SimpleSemver
::
new
(
1
,
1
,
10
)
)
;
assert!
(
SimpleSemver
::
new
(
1
,
2
,
3
)
<
SimpleSemver
::
new
(
1
,
2
,
10
)
)
;
assert!
(
SimpleSemver
::
new
(
1
,
2
,
3
)
<
SimpleSemver
::
new
(
1
,
3
,
1
)
)
;
assert!
(
SimpleSemver
::
new
(
1
,
2
,
3
)
<
SimpleSemver
::
new
(
2
,
2
,
1
)
)
;
}
#[test]
fn
check_for_sufficient_glibcxx_versions
(
)
{
let
=
"ldd (Ubuntu GLIBC 2.31-0ubuntu9.7) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper."
.
to_owned
(
)
.
into_bytes
(
)
;
assert_eq!
(
extract_ldd_version
(
&
)
,
Some
(
SimpleSemver
::
new
(
2
,
31
,
0
)
)
,
)
;
let
=
"ldd (GNU libc) 2.40.9000
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper."
.
to_owned
(
)
.
into_bytes
(
)
;
assert_eq!
(
extract_ldd_version
(
&
)
,
Some
(
SimpleSemver
::
new
(
2
,
40
,
0
)
)
,
)
;
}
}