1
+ $rubies = @ (
2
+ @ {
3
+ " version" = " Ruby 2.6.9-1"
4
+ " install_path" = " C:\Ruby26"
5
+ " download_url" = " https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.9-1/rubyinstaller-2.6.9-1-x86.exe"
6
+ " devkit_url" = " "
7
+ " devkit_paths" = @ ()
8
+ " bundlerV2" = $true
9
+ }
10
+ @ {
11
+ " version" = " Ruby 2.6.9-1 (x64)"
12
+ " install_path" = " C:\Ruby26-x64"
13
+ " download_url" = " https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.9-1/rubyinstaller-2.6.9-1-x64.exe"
14
+ " devkit_url" = " "
15
+ " devkit_paths" = @ ()
16
+ " bundlerV2" = $true
17
+ }
18
+ @ {
19
+ " version" = " Ruby 2.7.8-1"
20
+ " install_path" = " C:\Ruby27"
21
+ " download_url" = " https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.8-1/rubyinstaller-2.7.8-1-x86.exe"
22
+ " devkit_url" = " "
23
+ " devkit_paths" = @ ()
24
+ " bundlerV2" = $true
25
+ }
26
+ @ {
27
+ " version" = " Ruby 2.7.8-1 (x64)"
28
+ " install_path" = " C:\Ruby27-x64"
29
+ " download_url" = " https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.8-1/rubyinstaller-2.7.8-1-x64.exe"
30
+ " devkit_url" = " "
31
+ " devkit_paths" = @ ()
32
+ " bundlerV2" = $true
33
+ }
34
+ )
35
+
36
+ function UpdateRubyPath ($rubyPath ) {
37
+ $env: path = ($env: path -split ' ;' | Where-Object { -not $_.contains (' \Ruby' ) }) -join ' ;'
38
+ $env: path = " $rubyPath ;$env: path "
39
+ }
40
+
41
+ function Install-Ruby ($ruby ) {
42
+ Write-Host " Installing $ ( $ruby.version ) " - ForegroundColor Cyan
43
+
44
+ # uninstall existing
45
+ $rubyUninstallPath = " $ruby .install_path\unins000.exe"
46
+ if ([IO.File ]::Exists($rubyUninstallPath )) {
47
+ Write-Host " Uninstalling previous Ruby 2.4..." - ForegroundColor Gray
48
+ " `" $rubyUninstallPath `" /silent" | out-file " $env: temp \uninstall-ruby.cmd" - Encoding ASCII
49
+ & " $env: temp \uninstall-ruby.cmd"
50
+ del " $env: temp \uninstall-ruby.cmd"
51
+ Start-Sleep - s 5
52
+ }
53
+
54
+ if (Test-Path $ruby.install_path ) {
55
+ Write-Host " Deleting $ ( $ruby.install_path ) " - ForegroundColor Gray
56
+ Remove-Item $ruby.install_path - Force - Recurse
57
+ }
58
+
59
+ $exePath = " $ ( $env: TEMP ) \rubyinstaller.exe"
60
+
61
+ Write-Host " Downloading $ ( $ruby.version ) from $ ( $ruby.download_url ) " - ForegroundColor Gray
62
+ (New-Object Net.WebClient).DownloadFile($ruby.download_url , $exePath )
63
+
64
+ Write-Host " Installing..." - ForegroundColor Gray
65
+ cmd / c start / wait $exePath / verysilent / allusers / dir= " $ ( $ruby.install_path.replace (' \' , ' /' )) " / tasks= " noassocfiles,nomodpath,noridkinstall"
66
+ del $exePath
67
+ Write-Host " Installed" - ForegroundColor Green
68
+
69
+ # setup Ruby
70
+ UpdateRubyPath " $ ( $ruby.install_path ) \bin"
71
+ Write-Host " ruby --version" - ForegroundColor Gray
72
+ cmd / c ruby -- version
73
+
74
+ Write-Host " gem --version" - ForegroundColor Gray
75
+ cmd / c gem -- version
76
+
77
+ # list installed gems
78
+ Write-Host " gem list --local" - ForegroundColor Gray
79
+ cmd / c gem list -- local
80
+
81
+ # delete temp path
82
+ if ($tempPath ) {
83
+ Write-Host " Cleaning up..." - ForegroundColor Gray
84
+ Remove-Item $tempPath - Force - Recurse
85
+ }
86
+
87
+ Write-Host " Done!" - ForegroundColor Green
88
+ }
89
+
90
+ for ($i = 0 ; $i -lt $rubies.Count ; $i ++ ) {
91
+ Install-Ruby $rubies [$i ]
92
+ }
0 commit comments