How to install last stable version of Ruby with RVM without root privileges?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I'm creating a bash script to install automatically the last stable version of ruby without root privileges. This is what I have so far:



#Install GPG Keys
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import

#Install RVM
curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile

#Set environment
source $HOME/.rvm/scripts/rvm

#Install Ruby
rvm install $RUBY_VERSION


I need to find the last stable Ruby version to set RUBY_VERSION variable.







share|improve this question























    up vote
    0
    down vote

    favorite












    I'm creating a bash script to install automatically the last stable version of ruby without root privileges. This is what I have so far:



    #Install GPG Keys
    curl -sSL https://rvm.io/mpapis.asc | gpg2 --import

    #Install RVM
    curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles
    echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile

    #Set environment
    source $HOME/.rvm/scripts/rvm

    #Install Ruby
    rvm install $RUBY_VERSION


    I need to find the last stable Ruby version to set RUBY_VERSION variable.







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm creating a bash script to install automatically the last stable version of ruby without root privileges. This is what I have so far:



      #Install GPG Keys
      curl -sSL https://rvm.io/mpapis.asc | gpg2 --import

      #Install RVM
      curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles
      echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile

      #Set environment
      source $HOME/.rvm/scripts/rvm

      #Install Ruby
      rvm install $RUBY_VERSION


      I need to find the last stable Ruby version to set RUBY_VERSION variable.







      share|improve this question











      I'm creating a bash script to install automatically the last stable version of ruby without root privileges. This is what I have so far:



      #Install GPG Keys
      curl -sSL https://rvm.io/mpapis.asc | gpg2 --import

      #Install RVM
      curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles
      echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile

      #Set environment
      source $HOME/.rvm/scripts/rvm

      #Install Ruby
      rvm install $RUBY_VERSION


      I need to find the last stable Ruby version to set RUBY_VERSION variable.









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jun 6 at 20:07









      Facundo Chambo

      11




      11




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote















          Assuming the last stable version is always the last file with a filename like ruby-2.5.1.tar.gz on https://cache.ruby-lang.org/pub/ruby/, you can extract the version number with:



          curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'


          This approach uses curl Install curl to retrieve the file list and GNU sed Install sed to cut out the version number as explained in this SO answer. You could also use grep with lookarounds instead, it even may be slightly faster:



          curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1


          Just add a line setting the RUBY_VERSION variable to your script:



          #Get version number of latest stable Ruby version
          RUBY_VERSION=$(curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p')

          #Install Ruby
          rvm install $RUBY_VERSION


          Example run



          $ curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'
          2.5.1
          $ curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1
          2.5.1





          share|improve this answer























            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1044283%2fhow-to-install-last-stable-version-of-ruby-with-rvm-without-root-privileges%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote















            Assuming the last stable version is always the last file with a filename like ruby-2.5.1.tar.gz on https://cache.ruby-lang.org/pub/ruby/, you can extract the version number with:



            curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'


            This approach uses curl Install curl to retrieve the file list and GNU sed Install sed to cut out the version number as explained in this SO answer. You could also use grep with lookarounds instead, it even may be slightly faster:



            curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1


            Just add a line setting the RUBY_VERSION variable to your script:



            #Get version number of latest stable Ruby version
            RUBY_VERSION=$(curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p')

            #Install Ruby
            rvm install $RUBY_VERSION


            Example run



            $ curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'
            2.5.1
            $ curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1
            2.5.1





            share|improve this answer



























              up vote
              0
              down vote















              Assuming the last stable version is always the last file with a filename like ruby-2.5.1.tar.gz on https://cache.ruby-lang.org/pub/ruby/, you can extract the version number with:



              curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'


              This approach uses curl Install curl to retrieve the file list and GNU sed Install sed to cut out the version number as explained in this SO answer. You could also use grep with lookarounds instead, it even may be slightly faster:



              curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1


              Just add a line setting the RUBY_VERSION variable to your script:



              #Get version number of latest stable Ruby version
              RUBY_VERSION=$(curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p')

              #Install Ruby
              rvm install $RUBY_VERSION


              Example run



              $ curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'
              2.5.1
              $ curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1
              2.5.1





              share|improve this answer

























                up vote
                0
                down vote










                up vote
                0
                down vote











                Assuming the last stable version is always the last file with a filename like ruby-2.5.1.tar.gz on https://cache.ruby-lang.org/pub/ruby/, you can extract the version number with:



                curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'


                This approach uses curl Install curl to retrieve the file list and GNU sed Install sed to cut out the version number as explained in this SO answer. You could also use grep with lookarounds instead, it even may be slightly faster:



                curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1


                Just add a line setting the RUBY_VERSION variable to your script:



                #Get version number of latest stable Ruby version
                RUBY_VERSION=$(curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p')

                #Install Ruby
                rvm install $RUBY_VERSION


                Example run



                $ curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'
                2.5.1
                $ curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1
                2.5.1





                share|improve this answer

















                Assuming the last stable version is always the last file with a filename like ruby-2.5.1.tar.gz on https://cache.ruby-lang.org/pub/ruby/, you can extract the version number with:



                curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'


                This approach uses curl Install curl to retrieve the file list and GNU sed Install sed to cut out the version number as explained in this SO answer. You could also use grep with lookarounds instead, it even may be slightly faster:



                curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1


                Just add a line setting the RUBY_VERSION variable to your script:



                #Get version number of latest stable Ruby version
                RUBY_VERSION=$(curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p')

                #Install Ruby
                rvm install $RUBY_VERSION


                Example run



                $ curl -s https://cache.ruby-lang.org/pub/ruby/ | sed -nr '1h;1!H;$!d;x;s/.*ruby-([0-9.]+).tar.gz.*/1/p'
                2.5.1
                $ curl -s https://cache.ruby-lang.org/pub/ruby/ | grep -oP '(?<=ruby-)d.d.d(?=.tar.gz)' | tail -1
                2.5.1






                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited Jun 8 at 12:41


























                answered Jun 8 at 12:23









                dessert

                19.4k55494




                19.4k55494






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1044283%2fhow-to-install-last-stable-version-of-ruby-with-rvm-without-root-privileges%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    pylint3 and pip3 broken

                    Missing snmpget and snmpwalk

                    How to enroll fingerprints to Ubuntu 17.10 with VFS491