Installing Ruby gem without using `sudo`











up vote
0
down vote

favorite












The following Ruby gem installation without sudo used to work back in the day:



xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH=/usr/local/bin:$PATH
launchctl setenv PATH “/usr/local/bin:$PATH”
brew install ruby
gem install jekyll


But now on the last step, I get:




ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.




I have tried this solution - https://gist.github.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3. And, it sort of worked, but now my $PATH is messed up. echo $PATH returns - /Users/username/.rbenv/shims:/Users/username/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.



I have fully removed rbenv and cleared .bash_profile. Now my $PATH looks like so /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin what gets me back to the point one:




ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.




Can anyone share a correct up-to-date way to install Ruby gem without using sudo and messing up the $PATH?



macOS 10.14.1



ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.2.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/username/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/username/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/username/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin









share|improve this question
























  • what version of MacOS are you on? Are you still trying to use system ruby? I would still recommend using RVM as you should not have any permissions issues with that.
    – lacostenycoder
    Nov 11 at 11:57










  • Can you also paste the output off gem env? The error is because whatever you're doing is trying to modify system library directories/files which you can't do without sudo. But installing gems with sudo is not recommended. Also this thread my give some insight github.com/rbenv/rbenv/issues/1122
    – lacostenycoder
    Nov 11 at 11:59

















up vote
0
down vote

favorite












The following Ruby gem installation without sudo used to work back in the day:



xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH=/usr/local/bin:$PATH
launchctl setenv PATH “/usr/local/bin:$PATH”
brew install ruby
gem install jekyll


But now on the last step, I get:




ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.




I have tried this solution - https://gist.github.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3. And, it sort of worked, but now my $PATH is messed up. echo $PATH returns - /Users/username/.rbenv/shims:/Users/username/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.



I have fully removed rbenv and cleared .bash_profile. Now my $PATH looks like so /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin what gets me back to the point one:




ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.




Can anyone share a correct up-to-date way to install Ruby gem without using sudo and messing up the $PATH?



macOS 10.14.1



ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.2.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/username/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/username/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/username/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin









share|improve this question
























  • what version of MacOS are you on? Are you still trying to use system ruby? I would still recommend using RVM as you should not have any permissions issues with that.
    – lacostenycoder
    Nov 11 at 11:57










  • Can you also paste the output off gem env? The error is because whatever you're doing is trying to modify system library directories/files which you can't do without sudo. But installing gems with sudo is not recommended. Also this thread my give some insight github.com/rbenv/rbenv/issues/1122
    – lacostenycoder
    Nov 11 at 11:59















up vote
0
down vote

favorite









up vote
0
down vote

favorite











The following Ruby gem installation without sudo used to work back in the day:



xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH=/usr/local/bin:$PATH
launchctl setenv PATH “/usr/local/bin:$PATH”
brew install ruby
gem install jekyll


But now on the last step, I get:




ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.




I have tried this solution - https://gist.github.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3. And, it sort of worked, but now my $PATH is messed up. echo $PATH returns - /Users/username/.rbenv/shims:/Users/username/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.



I have fully removed rbenv and cleared .bash_profile. Now my $PATH looks like so /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin what gets me back to the point one:




ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.




Can anyone share a correct up-to-date way to install Ruby gem without using sudo and messing up the $PATH?



macOS 10.14.1



ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.2.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/username/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/username/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/username/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin









share|improve this question















The following Ruby gem installation without sudo used to work back in the day:



xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH=/usr/local/bin:$PATH
launchctl setenv PATH “/usr/local/bin:$PATH”
brew install ruby
gem install jekyll


But now on the last step, I get:




ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.




I have tried this solution - https://gist.github.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3. And, it sort of worked, but now my $PATH is messed up. echo $PATH returns - /Users/username/.rbenv/shims:/Users/username/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.



I have fully removed rbenv and cleared .bash_profile. Now my $PATH looks like so /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin what gets me back to the point one:




ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.




Can anyone share a correct up-to-date way to install Ruby gem without using sudo and messing up the $PATH?



macOS 10.14.1



ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.2.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/username/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/username/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/username/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin






ruby macos path rubygems homebrew






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 9:25

























asked Nov 10 at 9:14









alljamin

512527




512527












  • what version of MacOS are you on? Are you still trying to use system ruby? I would still recommend using RVM as you should not have any permissions issues with that.
    – lacostenycoder
    Nov 11 at 11:57










  • Can you also paste the output off gem env? The error is because whatever you're doing is trying to modify system library directories/files which you can't do without sudo. But installing gems with sudo is not recommended. Also this thread my give some insight github.com/rbenv/rbenv/issues/1122
    – lacostenycoder
    Nov 11 at 11:59




















  • what version of MacOS are you on? Are you still trying to use system ruby? I would still recommend using RVM as you should not have any permissions issues with that.
    – lacostenycoder
    Nov 11 at 11:57










  • Can you also paste the output off gem env? The error is because whatever you're doing is trying to modify system library directories/files which you can't do without sudo. But installing gems with sudo is not recommended. Also this thread my give some insight github.com/rbenv/rbenv/issues/1122
    – lacostenycoder
    Nov 11 at 11:59


















what version of MacOS are you on? Are you still trying to use system ruby? I would still recommend using RVM as you should not have any permissions issues with that.
– lacostenycoder
Nov 11 at 11:57




what version of MacOS are you on? Are you still trying to use system ruby? I would still recommend using RVM as you should not have any permissions issues with that.
– lacostenycoder
Nov 11 at 11:57












Can you also paste the output off gem env? The error is because whatever you're doing is trying to modify system library directories/files which you can't do without sudo. But installing gems with sudo is not recommended. Also this thread my give some insight github.com/rbenv/rbenv/issues/1122
– lacostenycoder
Nov 11 at 11:59






Can you also paste the output off gem env? The error is because whatever you're doing is trying to modify system library directories/files which you can't do without sudo. But installing gems with sudo is not recommended. Also this thread my give some insight github.com/rbenv/rbenv/issues/1122
– lacostenycoder
Nov 11 at 11:59














2 Answers
2






active

oldest

votes

















up vote
0
down vote













Don't install ruby with homebrew if you are going to use a ruby version manager, i.e. rbevn.



I would at this point recommend brew uninstall ruby



Then use rbenv if you already have it working to install your ruby version.



But if you are confused and not sure what you're doing, you might wanna consider using RVM instead of RBENV as the install/setup is easier.



If so see How do you uninstall rbenv on OSX?



Then see https://rvm.io/rvm/install



Looking at your gist
echo "export PATH=$HOME/gems/bin:$PATH" >> ~/.bashrc



You may need to edit your ~/.bashrc and remove that export line



You will probably want to close and reopen your terminal before doing any of the above. Anything that makes changes to ~/.bashrc won't take effect until you restart your terminal






share|improve this answer





















  • Thanks for your input! I have updated my question with more details.
    – alljamin
    Nov 11 at 9:32


















up vote
0
down vote













Thanks for the helpful link lacostenycoder. I have managed to get Ruby gems installed without sudo the following way:



xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install rbenv
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
rbenv install 2.5.1
rbenv global 2.5.1
gem install jekyll





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',
    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%2f53237532%2finstalling-ruby-gem-without-using-sudo%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Don't install ruby with homebrew if you are going to use a ruby version manager, i.e. rbevn.



    I would at this point recommend brew uninstall ruby



    Then use rbenv if you already have it working to install your ruby version.



    But if you are confused and not sure what you're doing, you might wanna consider using RVM instead of RBENV as the install/setup is easier.



    If so see How do you uninstall rbenv on OSX?



    Then see https://rvm.io/rvm/install



    Looking at your gist
    echo "export PATH=$HOME/gems/bin:$PATH" >> ~/.bashrc



    You may need to edit your ~/.bashrc and remove that export line



    You will probably want to close and reopen your terminal before doing any of the above. Anything that makes changes to ~/.bashrc won't take effect until you restart your terminal






    share|improve this answer





















    • Thanks for your input! I have updated my question with more details.
      – alljamin
      Nov 11 at 9:32















    up vote
    0
    down vote













    Don't install ruby with homebrew if you are going to use a ruby version manager, i.e. rbevn.



    I would at this point recommend brew uninstall ruby



    Then use rbenv if you already have it working to install your ruby version.



    But if you are confused and not sure what you're doing, you might wanna consider using RVM instead of RBENV as the install/setup is easier.



    If so see How do you uninstall rbenv on OSX?



    Then see https://rvm.io/rvm/install



    Looking at your gist
    echo "export PATH=$HOME/gems/bin:$PATH" >> ~/.bashrc



    You may need to edit your ~/.bashrc and remove that export line



    You will probably want to close and reopen your terminal before doing any of the above. Anything that makes changes to ~/.bashrc won't take effect until you restart your terminal






    share|improve this answer





















    • Thanks for your input! I have updated my question with more details.
      – alljamin
      Nov 11 at 9:32













    up vote
    0
    down vote










    up vote
    0
    down vote









    Don't install ruby with homebrew if you are going to use a ruby version manager, i.e. rbevn.



    I would at this point recommend brew uninstall ruby



    Then use rbenv if you already have it working to install your ruby version.



    But if you are confused and not sure what you're doing, you might wanna consider using RVM instead of RBENV as the install/setup is easier.



    If so see How do you uninstall rbenv on OSX?



    Then see https://rvm.io/rvm/install



    Looking at your gist
    echo "export PATH=$HOME/gems/bin:$PATH" >> ~/.bashrc



    You may need to edit your ~/.bashrc and remove that export line



    You will probably want to close and reopen your terminal before doing any of the above. Anything that makes changes to ~/.bashrc won't take effect until you restart your terminal






    share|improve this answer












    Don't install ruby with homebrew if you are going to use a ruby version manager, i.e. rbevn.



    I would at this point recommend brew uninstall ruby



    Then use rbenv if you already have it working to install your ruby version.



    But if you are confused and not sure what you're doing, you might wanna consider using RVM instead of RBENV as the install/setup is easier.



    If so see How do you uninstall rbenv on OSX?



    Then see https://rvm.io/rvm/install



    Looking at your gist
    echo "export PATH=$HOME/gems/bin:$PATH" >> ~/.bashrc



    You may need to edit your ~/.bashrc and remove that export line



    You will probably want to close and reopen your terminal before doing any of the above. Anything that makes changes to ~/.bashrc won't take effect until you restart your terminal







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 10 at 12:28









    lacostenycoder

    3,56511226




    3,56511226












    • Thanks for your input! I have updated my question with more details.
      – alljamin
      Nov 11 at 9:32


















    • Thanks for your input! I have updated my question with more details.
      – alljamin
      Nov 11 at 9:32
















    Thanks for your input! I have updated my question with more details.
    – alljamin
    Nov 11 at 9:32




    Thanks for your input! I have updated my question with more details.
    – alljamin
    Nov 11 at 9:32












    up vote
    0
    down vote













    Thanks for the helpful link lacostenycoder. I have managed to get Ruby gems installed without sudo the following way:



    xcode-select --install
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    brew install rbenv
    echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
    rbenv install 2.5.1
    rbenv global 2.5.1
    gem install jekyll





    share|improve this answer

























      up vote
      0
      down vote













      Thanks for the helpful link lacostenycoder. I have managed to get Ruby gems installed without sudo the following way:



      xcode-select --install
      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
      brew install rbenv
      echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
      rbenv install 2.5.1
      rbenv global 2.5.1
      gem install jekyll





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Thanks for the helpful link lacostenycoder. I have managed to get Ruby gems installed without sudo the following way:



        xcode-select --install
        /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
        brew install rbenv
        echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
        rbenv install 2.5.1
        rbenv global 2.5.1
        gem install jekyll





        share|improve this answer












        Thanks for the helpful link lacostenycoder. I have managed to get Ruby gems installed without sudo the following way:



        xcode-select --install
        /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
        brew install rbenv
        echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
        rbenv install 2.5.1
        rbenv global 2.5.1
        gem install jekyll






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 10:43









        alljamin

        512527




        512527






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53237532%2finstalling-ruby-gem-without-using-sudo%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

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly