rbenv bundle install tries to install gems into wrong path
I just had the same problem and this solved it for me:
gem uninstall bundler
gem update --system
rbenv rehash
gem install bundler
Most likely only gem update --system
were mandatory.
How to install a gem or update RubyGems if it fails with a permissions error
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
means exactly that, you don't have permission to write there.
That is the version of Ruby installed by Apple, for their own use. While it's OK to make minor modifications to that if you know what you're doing, because you are not sure about the permissions problem, I'd say it's not a good idea to continue along that track.
Instead, I'll strongly suggest you look into using either rbenv or RVM to manage a separate Ruby, installed into a sandbox in your home directory, that you can modify/fold/spindle/change without worrying about messing up the system Ruby.
Between the two, I use rbenv, though I used RVM a lot in the past. rbenv takes a more "hands-off" approach to managing your Ruby installation. RVM has a lot of features and is very powerful, but, as a result is more intrusive. In either case, READ the installation documentation for them a couple times before starting to install whichever you pick.
Rubygems issue when runnuing rails new
Ok, here is how I solved it for reference. I saw the a similar issue in this thread
A step by step solution would be:
Run
gem env
. You should see a list of paths like so under GEM PATHS:/Library/Ruby/Gems/2.0.0
/Users/sam/.gem/ruby/2.0.0
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
Open your ~/.bashrc file and add the paths as follows:
export GEM_HOME=/Library/Ruby/Gems/2.0.0
export PATH=$PATH:$GEM_HOME:/Users/sam/.gem/ruby/2.0.0:/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
Open a new shell and run the
gem install rubygems-update
. Everything should run fine now without sudo.
Related Topics
Rails Generate Has_Many Association
Ruby - Bundle Install/Update Too Slow
Ruby Replace String with Captured Regex Pattern
Reading the First Line of a File in Ruby
In Ruby How to Generate a Long String of Repeated Text
How to Render a Partial in Sinatra View (Haml in Haml)
Code to Generate Gaussian (Normally Distributed) Random Numbers in Ruby
Rails Project Using Spork - Always Have to Use Spork
Sending a Post Request with Net/Http
Rails: Serializing Objects in a Database
Can't Use Compass After Installing It
Uninstall Ruby Version from Rbenv
How to Delete Specific Characters from a String in Ruby
Deleting Table from Schema - Rails
Ruby on Rails: Provide VS Content_For
Cool Tricks and Expressive Snippets with Ruby Collections/Enumerables