Skip to content

Instantly share code, notes, and snippets.

@haushinka2dx
Created March 20, 2014 08:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save haushinka2dx/9659729 to your computer and use it in GitHub Desktop.
Windowsマシンで chocolatey 入れて、rubyインストールしてcapistranoまで入れてみた
Windows 向けのパッケージマネージャーがあるということなのでインストールしてみる。
ただ、本来の目的はcapistranoをWindowsで使いたいというだけ。
## Windows向けのパッケージマネージャー
いくつかある感じ。
1. [Chocolatey](http://chocolatey.org/)
2. [npackd](https://code.google.com/p/windows-package-manager/)
3. [nuget](http://www.nuget.org/)
nugetは.NETの開発環境向けのようなので除外。
npackdとchocolateyはあまり違いが分からないが、サイトを見る限りだとchocolateyの方が分かりやすいのでひとまずこちらを使ってみる。
## Chocolatey のインストール
[サイト](http://chocolatey.org)を見るとインストール方法として、
```
c:\> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
```
とあるが、別ディレクトリにインストールしたいのでこれは使わない。
と、こちらにあった。
https://github.com/chocolatey/chocolatey/wiki/Installation#before-you-install
1. 環境変数 `ChocolateyInstall` にインストール先のディレクトリを指定 **ユーザー変数の方に入れなきゃダメらしい**
2. 1で指定したディレクトリを作る(当たり前だけど)
3. コマンドプロンプトを起動
4. 環境変数が反映されているか確認
1. コマンドプロンプトで `echo %ChocolateyInstall%` で出ればOK
2. Windows Powershell で `$Env:ChocolateyInstall` で出ればOK
5. 別ディレクトリにインストールする際のインストールコマンドが書いてないけど、パス指定している箇所だけ変えて適当にやってみる
```
c:\> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ChocolateyInstall%\bin
```
`chocolatey /?` と打ったらちゃんと動いたので大丈夫っぽい。
## Ruby のインストール
### ruby のバージョンを確認
```
> chocolatey version ruby
name : ruby
found : no version
latestCompare : 000000000002.000000000000.000000000000.000000035300
verMessage : A more recent version is available
latest : 2.0.0.35300
foundCompare :
```
最新は 2.1 だけどとりあえずインストール
```
> chocolatey install ruby
Chocolatey (v0.9.8.23) is installing 'ruby' and dependencies. By installing you
accept the license for 'ruby' and each dependency you are installing.
______ ruby v2.0.0.35300 ______
Downloading ruby 32 bit (http://dl.bintray.com/oneclick/rubyinstaller/rubyinstal
ler-2.0.0-p353.exe?direct) to C:\Users\115080~1\AppData\Local\Temp\chocolatey\ru
by\rubyInstall.exe
Using this proxyserver: ********
Installing ruby...
Elevating Permissions and running C:\Users\******\AppData\Local\Temp\chocolate
y\ruby\rubyInstall.exe /verysilent /dir="C:\ruby200" /tasks="assocfiles,modpath"
. This may take awhile, depending on the statements.
ruby has been installed.
ruby has finished successfully! The chocolatey gods have answered your request!
Adding 'C:\ruby200\bin' to the local path
ruby has finished successfully! The chocolatey gods have answered your request!
Finished installing 'ruby' and dependencies - if errors not shown in console, no
ne detected. Check log for errors if unsure.
Reading environment variables from registry. Please wait... Done.
```
パスにインストール先が入ってないので追加。
`> set path=%path%;c:\ruby200\bin`
で、確認
```
> ruby -v
ruby 2.0.0p353 (2013-11-22) [i386-mingw32]
```
入った。だけど別のところに入れたいな…。
```
> chocolatey version ruby -ia '/dir=''D:\path\to\install'' '
```
とやってみたらできた。
## rubygemsのインストール
これ必要?
```
chocolatey install rubygems
```
おまけにエラー出てるし。
## capistranoのインストール
の前に gems を最新に
```
gem update --system
```
で、インストール(今回は2.x系)
```
gem install capistrano --version "2.15.5"
```
プロキシがある場合は以下のようにする
```
gem install capistrano --version "2.15.5" --http-proxy http://プロキシー:ポート
```
だらだらーっと出るけど成功したようす。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment