完全脱机安装RVM

时间:2012-02-27 01:52:48

标签: ruby macos rvm

我打算为ruby脚本创建一个安装程序,但我希望能够确保该机器已安装RVM。有没有办法完全离线安装RVM并且不显眼(通过不引人注目的方式,如创建一个可以执行所有操作的脚本,而不是要求用户向bash_profile或bashrc添加内容)

我不是要求脚本本身,只是一个关于如何走这条路线的快速指针(如果可能的话)。我们也研究过这个有用的问题:

RVM - is there a way for simple offline install?

但有点误导,因为答案只向我们展示了如何在RVM中离线安装ruby。我们需要能够离线安装RVM,并查看脚本

https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer

我只是包含整个脚本并将rvm_releases_url更改为其他内容吗?将rvm路径附加到用户的bash_profile或bashrc而不是要求他们这样做是否安全?

3 个答案:

答案 0 :(得分:4)

根据编辑此评论所给的建议。 :-)

脱机安装RVM:

- Download the rvm tarball: 

            curl -sSL https://github.com/rvm/rvm/tarball/stable -o rvm-stable.tar.gz

- Create and enter rvm directory: 

            mkdir rvm && cd rvm 

- Unpack the tar file : 

            tar --strip-components=1 -xzf ../rvm-stable.tar.gz

- Install rvm: 

            ./install --auto-dotfiles

            use --help to get the options

- Load rvm: 

            source ~/.rvm/scripts/rvm

下载Ruby,rubygems和yaml:

- Download ruby

    o Find tar.bz2 version at: 

            https://ftp.ruby-lang.org/pub/ruby/ (check sub-directories)

    o Download with curl: :

            curl -sSL https://ftp.ruby-lang.org/pub/ruby/ruby-2.2.0.tar.bz2 -o ruby-2.2.0.tar.bz2

    o Make sure you are downloading with the extension " .tar.bz2 "

- Download rubygems

    o Find version at:

            https://github.com/rubygems/rubygems/tags
    o Download with curl:

            curl -sSL http://production.cf.rubygems.org/rubygems/rubygems-2.4.6.tgz -o rubygems-2.4.6.tgz

安装依赖项:

- Disable automatic dependencies ("requirements") fetching using the following command.

             rvm autolibs read-fail

- Manually download and install dependencies

    o Get the list of dependencies using

             rvm requirements

安装Ruby:

Clean default gems:

            echo "" > ~/.rvm/gemsets/default.gems

Clean global gems:

            echo "" > ~/.rvm/gemsets/global.gems

Install Ruby:

            rvm install 2.2.0 --rubygems 2.4.6 (this may require sudo password for autolibs)

Install any other Ruby versions you want similarly

Set default Ruby version: rvm use 2.2.0 --default

注意:红宝石和其他包装应放在$ rvm_path / archives /目录中。

安装宝石:

    There are multiple ways to install gems, we can download the gem files,
    but the best way seems to be Bundler: http://bundler.io/bundle_package.html

安装rails gem的示例:

    Offline
    --------

        Create a directory:

                    mkdir gems; cd gems

        Unpack gems:
                    tar xzf gems.tgz

        Install bundler:

                    gem install bundler-1.8.3.gem

                    [ This needs internet, to avoid internet connection you need to install bundler gem using --local option with the bundler.x.x.gem file ]

        Install gems:

                    bundle install --local

UNINSTALL rvm:

    rvm implode --force

    Then remove rvm from following locations:

    rm -rf /usr/local/rvm
    sudo rm /etc/profile.d/rvm.sh
    sudo rm /etc/rvmrc
    sudo rm ~/.rvmrc

    Check the following files and remove or comment out references to rvm

    ~/.bashrc
    ~/.bash_profile
    ~/.profile
    ~/.zshrc
    ~/.zlogin

    Comment-out / Remove the following lines from /etc/profile

     source /etc/profile.d/sm.sh
     source /etc/profile.d/rvm.sh

    /etc/profile is a readonly file so use

    sudo vim /etc/profile

您也可以在这里找到安装方法...

参考:https://github.com/rvm/rvm-site/blob/master/content/rvm/offline.md

答案 1 :(得分:2)

获取源的副本并运行就足够了:

./install

在它的根目录中,

要安装ruby,您需要将{* 1}}的ruby和rubygems归档并在rvm/archives中设置rubygems_version=1.8.24

我还涉及另一个项目,它将嵌入RVM并允许离线安装:https://github.com/railsinstaller/railsinstaller-nix

答案 2 :(得分:2)

更新:最后终于终于!!!我们拥有它!

https://rvm.io/rvm/offline/

离线安装的完整说明!