Problems installing “rails” in Ubuntu












0















I am new to programming and trying to install Rails on Ubuntu 18.10, but I get the following error when running $ gem install rails. How do I avoid this error and install rails?



ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ dir_s_mkdir - /home/bernardo/.gem/specs


I'm running Ruby 2.5.3p105










share|improve this question























  • Howdy, looks like your issue is related to permissions on your system. You could get around that by running sudo in front of your command. However i think your best course of action is to remove ruby from your system (sudo apt-get purge ruby) and then start over with rbenv. github.com/rbenv/rbenv

    – Austio
    Nov 20 '18 at 1:57






  • 2





    You almost certainly did sudo gem install on some other gem previously, and now your /home/bernardo/.gem directory is owned by root. The easiest way to fix this is a bit of a sledgehammer, but you should do it: sudo rm -rf ~/.gem, and then reinstall any gems you want. This will delete all your gems (some of which are owned by root), but it'll fix your problem. Just do that and then reinstall the gems you want, and never ever sudo gem install for any reason.

    – Jim Stewart
    Nov 20 '18 at 6:47











  • @Austio above is on the right track, but wrong about the underlying cause, and purging/reinstalling Ruby is not going to help.

    – Jim Stewart
    Nov 20 '18 at 6:52
















0















I am new to programming and trying to install Rails on Ubuntu 18.10, but I get the following error when running $ gem install rails. How do I avoid this error and install rails?



ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ dir_s_mkdir - /home/bernardo/.gem/specs


I'm running Ruby 2.5.3p105










share|improve this question























  • Howdy, looks like your issue is related to permissions on your system. You could get around that by running sudo in front of your command. However i think your best course of action is to remove ruby from your system (sudo apt-get purge ruby) and then start over with rbenv. github.com/rbenv/rbenv

    – Austio
    Nov 20 '18 at 1:57






  • 2





    You almost certainly did sudo gem install on some other gem previously, and now your /home/bernardo/.gem directory is owned by root. The easiest way to fix this is a bit of a sledgehammer, but you should do it: sudo rm -rf ~/.gem, and then reinstall any gems you want. This will delete all your gems (some of which are owned by root), but it'll fix your problem. Just do that and then reinstall the gems you want, and never ever sudo gem install for any reason.

    – Jim Stewart
    Nov 20 '18 at 6:47











  • @Austio above is on the right track, but wrong about the underlying cause, and purging/reinstalling Ruby is not going to help.

    – Jim Stewart
    Nov 20 '18 at 6:52














0












0








0


1






I am new to programming and trying to install Rails on Ubuntu 18.10, but I get the following error when running $ gem install rails. How do I avoid this error and install rails?



ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ dir_s_mkdir - /home/bernardo/.gem/specs


I'm running Ruby 2.5.3p105










share|improve this question














I am new to programming and trying to install Rails on Ubuntu 18.10, but I get the following error when running $ gem install rails. How do I avoid this error and install rails?



ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ dir_s_mkdir - /home/bernardo/.gem/specs


I'm running Ruby 2.5.3p105







ruby-on-rails ruby linux ubuntu






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 1:11









Bernardo Garza LandaBernardo Garza Landa

1




1













  • Howdy, looks like your issue is related to permissions on your system. You could get around that by running sudo in front of your command. However i think your best course of action is to remove ruby from your system (sudo apt-get purge ruby) and then start over with rbenv. github.com/rbenv/rbenv

    – Austio
    Nov 20 '18 at 1:57






  • 2





    You almost certainly did sudo gem install on some other gem previously, and now your /home/bernardo/.gem directory is owned by root. The easiest way to fix this is a bit of a sledgehammer, but you should do it: sudo rm -rf ~/.gem, and then reinstall any gems you want. This will delete all your gems (some of which are owned by root), but it'll fix your problem. Just do that and then reinstall the gems you want, and never ever sudo gem install for any reason.

    – Jim Stewart
    Nov 20 '18 at 6:47











  • @Austio above is on the right track, but wrong about the underlying cause, and purging/reinstalling Ruby is not going to help.

    – Jim Stewart
    Nov 20 '18 at 6:52



















  • Howdy, looks like your issue is related to permissions on your system. You could get around that by running sudo in front of your command. However i think your best course of action is to remove ruby from your system (sudo apt-get purge ruby) and then start over with rbenv. github.com/rbenv/rbenv

    – Austio
    Nov 20 '18 at 1:57






  • 2





    You almost certainly did sudo gem install on some other gem previously, and now your /home/bernardo/.gem directory is owned by root. The easiest way to fix this is a bit of a sledgehammer, but you should do it: sudo rm -rf ~/.gem, and then reinstall any gems you want. This will delete all your gems (some of which are owned by root), but it'll fix your problem. Just do that and then reinstall the gems you want, and never ever sudo gem install for any reason.

    – Jim Stewart
    Nov 20 '18 at 6:47











  • @Austio above is on the right track, but wrong about the underlying cause, and purging/reinstalling Ruby is not going to help.

    – Jim Stewart
    Nov 20 '18 at 6:52

















Howdy, looks like your issue is related to permissions on your system. You could get around that by running sudo in front of your command. However i think your best course of action is to remove ruby from your system (sudo apt-get purge ruby) and then start over with rbenv. github.com/rbenv/rbenv

– Austio
Nov 20 '18 at 1:57





Howdy, looks like your issue is related to permissions on your system. You could get around that by running sudo in front of your command. However i think your best course of action is to remove ruby from your system (sudo apt-get purge ruby) and then start over with rbenv. github.com/rbenv/rbenv

– Austio
Nov 20 '18 at 1:57




2




2





You almost certainly did sudo gem install on some other gem previously, and now your /home/bernardo/.gem directory is owned by root. The easiest way to fix this is a bit of a sledgehammer, but you should do it: sudo rm -rf ~/.gem, and then reinstall any gems you want. This will delete all your gems (some of which are owned by root), but it'll fix your problem. Just do that and then reinstall the gems you want, and never ever sudo gem install for any reason.

– Jim Stewart
Nov 20 '18 at 6:47





You almost certainly did sudo gem install on some other gem previously, and now your /home/bernardo/.gem directory is owned by root. The easiest way to fix this is a bit of a sledgehammer, but you should do it: sudo rm -rf ~/.gem, and then reinstall any gems you want. This will delete all your gems (some of which are owned by root), but it'll fix your problem. Just do that and then reinstall the gems you want, and never ever sudo gem install for any reason.

– Jim Stewart
Nov 20 '18 at 6:47













@Austio above is on the right track, but wrong about the underlying cause, and purging/reinstalling Ruby is not going to help.

– Jim Stewart
Nov 20 '18 at 6:52





@Austio above is on the right track, but wrong about the underlying cause, and purging/reinstalling Ruby is not going to help.

– Jim Stewart
Nov 20 '18 at 6:52












4 Answers
4






active

oldest

votes


















0














Just go through the steps given in below link: https://gorails.com/setup/ubuntu/16.04
and make sure you install ruby using rvm and set is default ruby. Then install rails.
This will resolve your issue.



If still the problem is not resolved, then remove previously installed ruby and go through all the steps for ruby and rails installation.






share|improve this answer































    0














    Here are the steps that I took to install rbenv in ubuntu server



    git clone https://github.com/rbenv/rbenv.git ~/.rbenv
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
    echo 'eval "$(rbenv init -)"' >> ~/.bashrc
    source ~/.bashrc
    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
    rbenv -v
    rbenv install 2.5.3
    rbenv global 2.5.3
    rbenv rehash
    ruby -v
    gem install bundler
    # inside rails application
    bundle install


    Explanation:




    • Line 1: clone rbenv project

    • line 2-4: enter rbenv path and settings to your bashrc

    • rbenv -v = check whether your rbenv is running correctly

    • then install ruby version (I checked above you running version 2.5.3)

    • rbenv global 2.5.3 (set version 2.5.3 in any folder paths)

    • rbenv rehash (after you set global / local make sure you do rehash)






    share|improve this answer

































      0














      Never install a gem with sudo command.



      use



      gem install rails


      instead of



      sudo gem install rails 





      share|improve this answer































        -1














        Use sudo gem install rails May helps you.






        share|improve this answer























          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384844%2fproblems-installing-rails-in-ubuntu%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Just go through the steps given in below link: https://gorails.com/setup/ubuntu/16.04
          and make sure you install ruby using rvm and set is default ruby. Then install rails.
          This will resolve your issue.



          If still the problem is not resolved, then remove previously installed ruby and go through all the steps for ruby and rails installation.






          share|improve this answer




























            0














            Just go through the steps given in below link: https://gorails.com/setup/ubuntu/16.04
            and make sure you install ruby using rvm and set is default ruby. Then install rails.
            This will resolve your issue.



            If still the problem is not resolved, then remove previously installed ruby and go through all the steps for ruby and rails installation.






            share|improve this answer


























              0












              0








              0







              Just go through the steps given in below link: https://gorails.com/setup/ubuntu/16.04
              and make sure you install ruby using rvm and set is default ruby. Then install rails.
              This will resolve your issue.



              If still the problem is not resolved, then remove previously installed ruby and go through all the steps for ruby and rails installation.






              share|improve this answer













              Just go through the steps given in below link: https://gorails.com/setup/ubuntu/16.04
              and make sure you install ruby using rvm and set is default ruby. Then install rails.
              This will resolve your issue.



              If still the problem is not resolved, then remove previously installed ruby and go through all the steps for ruby and rails installation.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 20 '18 at 5:39









              Cryptex TechnologiesCryptex Technologies

              790213




              790213

























                  0














                  Here are the steps that I took to install rbenv in ubuntu server



                  git clone https://github.com/rbenv/rbenv.git ~/.rbenv
                  echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
                  echo 'eval "$(rbenv init -)"' >> ~/.bashrc
                  source ~/.bashrc
                  git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
                  rbenv -v
                  rbenv install 2.5.3
                  rbenv global 2.5.3
                  rbenv rehash
                  ruby -v
                  gem install bundler
                  # inside rails application
                  bundle install


                  Explanation:




                  • Line 1: clone rbenv project

                  • line 2-4: enter rbenv path and settings to your bashrc

                  • rbenv -v = check whether your rbenv is running correctly

                  • then install ruby version (I checked above you running version 2.5.3)

                  • rbenv global 2.5.3 (set version 2.5.3 in any folder paths)

                  • rbenv rehash (after you set global / local make sure you do rehash)






                  share|improve this answer






























                    0














                    Here are the steps that I took to install rbenv in ubuntu server



                    git clone https://github.com/rbenv/rbenv.git ~/.rbenv
                    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
                    echo 'eval "$(rbenv init -)"' >> ~/.bashrc
                    source ~/.bashrc
                    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
                    rbenv -v
                    rbenv install 2.5.3
                    rbenv global 2.5.3
                    rbenv rehash
                    ruby -v
                    gem install bundler
                    # inside rails application
                    bundle install


                    Explanation:




                    • Line 1: clone rbenv project

                    • line 2-4: enter rbenv path and settings to your bashrc

                    • rbenv -v = check whether your rbenv is running correctly

                    • then install ruby version (I checked above you running version 2.5.3)

                    • rbenv global 2.5.3 (set version 2.5.3 in any folder paths)

                    • rbenv rehash (after you set global / local make sure you do rehash)






                    share|improve this answer




























                      0












                      0








                      0







                      Here are the steps that I took to install rbenv in ubuntu server



                      git clone https://github.com/rbenv/rbenv.git ~/.rbenv
                      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
                      echo 'eval "$(rbenv init -)"' >> ~/.bashrc
                      source ~/.bashrc
                      git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
                      rbenv -v
                      rbenv install 2.5.3
                      rbenv global 2.5.3
                      rbenv rehash
                      ruby -v
                      gem install bundler
                      # inside rails application
                      bundle install


                      Explanation:




                      • Line 1: clone rbenv project

                      • line 2-4: enter rbenv path and settings to your bashrc

                      • rbenv -v = check whether your rbenv is running correctly

                      • then install ruby version (I checked above you running version 2.5.3)

                      • rbenv global 2.5.3 (set version 2.5.3 in any folder paths)

                      • rbenv rehash (after you set global / local make sure you do rehash)






                      share|improve this answer















                      Here are the steps that I took to install rbenv in ubuntu server



                      git clone https://github.com/rbenv/rbenv.git ~/.rbenv
                      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
                      echo 'eval "$(rbenv init -)"' >> ~/.bashrc
                      source ~/.bashrc
                      git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
                      rbenv -v
                      rbenv install 2.5.3
                      rbenv global 2.5.3
                      rbenv rehash
                      ruby -v
                      gem install bundler
                      # inside rails application
                      bundle install


                      Explanation:




                      • Line 1: clone rbenv project

                      • line 2-4: enter rbenv path and settings to your bashrc

                      • rbenv -v = check whether your rbenv is running correctly

                      • then install ruby version (I checked above you running version 2.5.3)

                      • rbenv global 2.5.3 (set version 2.5.3 in any folder paths)

                      • rbenv rehash (after you set global / local make sure you do rehash)







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 20 '18 at 8:06









                      Pang

                      6,9011664102




                      6,9011664102










                      answered Nov 20 '18 at 6:43









                      widjajaydwidjajayd

                      3,23231323




                      3,23231323























                          0














                          Never install a gem with sudo command.



                          use



                          gem install rails


                          instead of



                          sudo gem install rails 





                          share|improve this answer




























                            0














                            Never install a gem with sudo command.



                            use



                            gem install rails


                            instead of



                            sudo gem install rails 





                            share|improve this answer


























                              0












                              0








                              0







                              Never install a gem with sudo command.



                              use



                              gem install rails


                              instead of



                              sudo gem install rails 





                              share|improve this answer













                              Never install a gem with sudo command.



                              use



                              gem install rails


                              instead of



                              sudo gem install rails 






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 20 '18 at 9:30









                              Vikram SharmaVikram Sharma

                              30536




                              30536























                                  -1














                                  Use sudo gem install rails May helps you.






                                  share|improve this answer




























                                    -1














                                    Use sudo gem install rails May helps you.






                                    share|improve this answer


























                                      -1












                                      -1








                                      -1







                                      Use sudo gem install rails May helps you.






                                      share|improve this answer













                                      Use sudo gem install rails May helps you.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 20 '18 at 8:02









                                      Maheshkumar.JMaheshkumar.J

                                      147




                                      147






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384844%2fproblems-installing-rails-in-ubuntu%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          How to change which sound is reproduced for terminal bell?

                                          Can I use Tabulator js library in my java Spring + Thymeleaf project?

                                          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents