-
Notifications
You must be signed in to change notification settings - Fork 464
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·434 lines (379 loc) · 12.4 KB
/
install.sh
File metadata and controls
executable file
·434 lines (379 loc) · 12.4 KB
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
#!/bin/bash
# RuVector Installer
# Usage: curl -fsSL https://raw.githubusercontent.com/ruvnet/ruvector/main/install.sh | bash
# Or: wget -qO- https://raw.githubusercontent.com/ruvnet/ruvector/main/install.sh | bash
# Don't exit on error - we handle errors manually
set +e
# Colors (disable if not a terminal)
if [ -t 1 ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
else
RED=''
GREEN=''
YELLOW=''
BLUE=''
CYAN=''
NC=''
fi
print_banner() {
echo -e "${CYAN}"
echo " ____ __ __ _ "
echo " | _ \ _ _ \ \ / /__ ___| |_ ___ _ __ "
echo " | |_) | | | | \ \ / / _ \/ __| __/ _ \| '__|"
echo " | _ <| |_| | \ V / __/ (__| || (_) | | "
echo " |_| \_\\\\__,_| \_/ \___|\___|\__\___/|_| "
echo -e "${NC}"
echo -e "${YELLOW}Vector database that learns${NC}"
echo ""
}
print_step() {
echo -e "${BLUE}==>${NC} $1"
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
print_warning() {
echo -e "${YELLOW}!${NC} $1"
}
# Detect OS and architecture
detect_platform() {
OS="$(uname -s 2>/dev/null || echo "Unknown")"
ARCH="$(uname -m 2>/dev/null || echo "Unknown")"
case "$OS" in
Linux*) PLATFORM="linux" ;;
Darwin*) PLATFORM="darwin" ;;
MINGW*|MSYS*|CYGWIN*)
PLATFORM="windows"
print_warning "Windows detected. For best results, use WSL2 or run in Git Bash."
print_warning "Native Windows: use 'cargo install' manually after installing Rust."
;;
*) PLATFORM="unknown" ;;
esac
case "$ARCH" in
x86_64|amd64) ARCH="x64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) ARCH="unknown" ;;
esac
echo "${PLATFORM}-${ARCH}"
}
# Check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check for required build dependencies
check_dependencies() {
print_step "Checking dependencies..."
local missing=()
# curl or wget required
if ! command_exists curl && ! command_exists wget; then
missing+=("curl or wget")
fi
# Check for C compiler (needed for Rust builds)
if ! command_exists cc && ! command_exists gcc && ! command_exists clang; then
missing+=("C compiler (gcc/clang)")
fi
if [ ${#missing[@]} -gt 0 ]; then
print_warning "Missing optional dependencies: ${missing[*]}"
echo " Some crates may fail to compile without a C compiler."
if [ "$PLATFORM" = "linux" ]; then
echo " Install with: sudo apt-get install build-essential (Debian/Ubuntu)"
echo " or: sudo yum groupinstall 'Development Tools' (RHEL/CentOS)"
elif [ "$PLATFORM" = "darwin" ]; then
echo " Install with: xcode-select --install"
fi
echo ""
else
print_success "All dependencies found"
fi
}
# Install Rust if not present
install_rust() {
if command_exists rustc; then
RUST_VERSION=$(rustc --version | cut -d' ' -f2)
print_success "Rust ${RUST_VERSION} already installed"
return 0
fi
print_step "Installing Rust via rustup..."
if ! command_exists curl; then
print_error "curl is required to install Rust"
echo " Install curl first, then re-run this script"
return 1
fi
if curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; then
# Source cargo env if it exists
if [ -f "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env"
elif [ -f "$HOME/.cargo/bin/cargo" ]; then
export PATH="$HOME/.cargo/bin:$PATH"
fi
if command_exists rustc; then
print_success "Rust installed successfully"
return 0
else
print_error "Rust installation completed but rustc not found in PATH"
echo " Try running: source \$HOME/.cargo/env"
return 1
fi
else
print_error "Failed to install Rust"
return 1
fi
}
# Install CLI binary from crates.io
install_cli() {
print_step "Installing ruvector-cli from crates.io..."
if ! command_exists cargo; then
print_error "cargo not found. Install Rust first."
return 1
fi
# Install with visible output so users can see progress/errors
echo " Running: cargo install ruvector-cli"
if cargo install ruvector-cli 2>&1 | while read -r line; do echo " $line"; done; then
if command_exists ruvector-cli; then
print_success "ruvector-cli installed"
return 0
fi
fi
# Check if it was already installed
if command_exists ruvector-cli; then
print_success "ruvector-cli already installed"
return 0
fi
print_warning "ruvector-cli installation had issues"
echo " This may be due to missing build dependencies."
echo " Try manually: cargo install ruvector-cli"
return 1
}
# Install Node.js packages
install_npm() {
if ! command_exists node; then
print_warning "Node.js not found - skipping npm packages"
echo " Install Node.js from https://nodejs.org to use npm packages"
return 0
fi
print_step "Installing npm packages..."
if ! command_exists npm; then
print_warning "npm not found"
return 1
fi
NODE_VERSION=$(node --version)
print_success "Node.js ${NODE_VERSION} detected"
# Install with visible output
echo " Running: npm install -g ruvector"
if npm install -g ruvector 2>&1 | while read -r line; do echo " $line"; done; then
print_success "ruvector npm package installed"
else
print_warning "npm install had issues (may need sudo on some systems)"
echo " Try: sudo npm install -g ruvector"
echo " Or use npx: npx ruvector"
fi
}
# Show available crates (informational - these are LIBRARY crates)
show_crates() {
echo ""
echo -e "${CYAN}Available RuVector Rust Crates:${NC}"
echo ""
echo -e "${GREEN}Add to your Cargo.toml with 'cargo add':${NC}"
echo ""
echo " # Core (vector database)"
echo " cargo add ruvector-core"
echo ""
echo " # Graph database with Cypher"
echo " cargo add ruvector-graph"
echo ""
echo " # Graph Neural Networks"
echo " cargo add ruvector-gnn"
echo ""
echo " # Distributed systems"
echo " cargo add ruvector-cluster"
echo " cargo add ruvector-raft"
echo " cargo add ruvector-replication"
echo ""
echo " # AI routing"
echo " cargo add ruvector-tiny-dancer-core"
echo " cargo add ruvector-router-core"
echo ""
echo -e "${YELLOW}Note: These are library crates. Use 'cargo add' in your project.${NC}"
echo ""
}
# Show npm packages
show_npm() {
echo -e "${CYAN}Available npm Packages:${NC}"
echo ""
echo " # All-in-one CLI (recommended)"
echo " npm install ruvector"
echo " npx ruvector"
echo ""
echo " # Individual packages"
echo " npm install @ruvector/core # Vector database"
echo " npm install @ruvector/gnn # Graph Neural Networks"
echo " npm install @ruvector/graph-node # Hypergraph database"
echo ""
echo " # List all available packages"
echo " npx ruvector install"
echo ""
}
# Show uninstall instructions
show_uninstall() {
echo -e "${CYAN}Uninstall Instructions:${NC}"
echo ""
echo " # Remove CLI binary"
echo " cargo uninstall ruvector-cli"
echo ""
echo " # Remove npm packages"
echo " npm uninstall -g ruvector"
echo ""
echo " # Remove Rust entirely (optional)"
echo " rustup self uninstall"
echo ""
}
# Main installation
main() {
print_banner
PLATFORM=$(detect_platform)
print_step "Detected platform: ${PLATFORM}"
echo ""
# Parse arguments
INSTALL_RUST=true
INSTALL_CLI=true
INSTALL_NPM=true
SHOW_ONLY=false
SHOW_UNINSTALL=false
while [[ $# -gt 0 ]]; do
case $1 in
--rust-only)
INSTALL_NPM=false
shift
;;
--npm-only)
INSTALL_RUST=false
INSTALL_CLI=false
shift
;;
--cli-only)
INSTALL_NPM=false
shift
;;
--list|--show)
SHOW_ONLY=true
shift
;;
--uninstall)
SHOW_UNINSTALL=true
shift
;;
--help|-h)
echo "Usage: install.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --rust-only Install Rust and CLI only (no npm)"
echo " --npm-only Install npm packages only (no Rust)"
echo " --cli-only Install ruvector-cli binary only"
echo " --list Show available packages without installing"
echo " --uninstall Show uninstall instructions"
echo " --help Show this help"
echo ""
echo "Examples:"
echo " curl -fsSL https://raw.githubusercontent.com/ruvnet/ruvector/main/install.sh | bash"
echo " curl -fsSL ... | bash -s -- --rust-only"
echo " curl -fsSL ... | bash -s -- --npm-only"
echo " curl -fsSL ... | bash -s -- --list"
exit 0
;;
*)
print_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
if [ "$SHOW_UNINSTALL" = true ]; then
show_uninstall
exit 0
fi
if [ "$SHOW_ONLY" = true ]; then
show_crates
show_npm
exit 0
fi
# Check dependencies
check_dependencies
# Track what was installed
INSTALLED_RUST=false
INSTALLED_CLI=false
INSTALLED_NPM=false
# Install Rust
if [ "$INSTALL_RUST" = true ]; then
if install_rust; then
INSTALLED_RUST=true
fi
echo ""
fi
# Install CLI
if [ "$INSTALL_CLI" = true ] && { [ "$INSTALLED_RUST" = true ] || command_exists cargo; }; then
if install_cli; then
INSTALLED_CLI=true
fi
echo ""
fi
# Install npm
if [ "$INSTALL_NPM" = true ]; then
if install_npm; then
INSTALLED_NPM=true
fi
echo ""
fi
# Show summary
echo ""
echo -e "${GREEN}════════════════════════════════════════════════════════════${NC}"
echo -e "${GREEN} Installation Summary${NC}"
echo -e "${GREEN}════════════════════════════════════════════════════════════${NC}"
echo ""
if [ "$INSTALLED_RUST" = true ] || command_exists rustc; then
RUST_V=$(rustc --version 2>/dev/null | cut -d' ' -f2 || echo "installed")
echo -e " Rust: ${GREEN}✓${NC} ${RUST_V}"
else
echo -e " Rust: ${YELLOW}○${NC} not installed"
fi
if [ "$INSTALLED_CLI" = true ] || command_exists ruvector-cli; then
echo -e " ruvector-cli: ${GREEN}✓${NC} installed"
else
echo -e " ruvector-cli: ${YELLOW}○${NC} not installed"
fi
if command_exists node; then
NODE_V=$(node --version)
echo -e " Node.js: ${GREEN}✓${NC} ${NODE_V}"
if npm list -g ruvector >/dev/null 2>&1; then
echo -e " ruvector npm: ${GREEN}✓${NC} installed"
else
echo -e " ruvector npm: ${YELLOW}○${NC} use 'npx ruvector'"
fi
else
echo -e " Node.js: ${YELLOW}○${NC} not installed"
fi
echo ""
show_crates
show_npm
echo -e "${CYAN}Quick Start:${NC}"
echo ""
echo " # Rust project"
echo " cargo new my-vector-app && cd my-vector-app"
echo " cargo add ruvector-core ruvector-gnn"
echo ""
echo " # Node.js"
echo " npx ruvector info"
echo " npx ruvector benchmark"
echo ""
echo -e "${CYAN}Documentation:${NC} https://github.com/ruvnet/ruvector"
echo -e "${CYAN}Issues:${NC} https://github.com/ruvnet/ruvector/issues"
echo ""
}
main "$@"