Failure to install ruby gems with rbenv - ruby-on-rails

I can't install any Ruby gems. I am using rbenv and when I use gem install rails, I get a permission error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
I have been trying to install Rails for days now, even with RVM.
I am pretty sure the problem lies with my $PATH but I do not know how to change this.
I am running Ruby version 2.0.0p247.

Can you try gem update --system, and try to gem install again, if it fails, post your log.

Related

Why doesn't gem install bundler work?

I am trying to deploy an application via Github pages, and based on this tutorial that I am watching, I need to install bundler first.
When I type in the command gem install bundler, I get the error:
While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
I do not have rbenv downloaded and I don't know how to. I also do not fully understand the concept of gems.
How can I bypass this issue?
Try 'sudo gem install bundler'

Can't install ruby on rails in ubuntu gnome 15.10

I am trying to install ruby on rails. I'm at version 2.3.0 for ruby and gem version of 2.5.1.
When I run the command gem install rails I get an error that says:
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/local/lib/ruby/gems/2.3.0 directory.
How can I fix this?
gem install tries to put files in "system-wide" directories. These are protected, such that only the root user can write into.
You have at least three possibilities:
sudo gem install ..., this will write the gem files into /usr/local/lib/ruby/gems/2.3.0
gem install --user-install, this will install the gem "locally" in your users home directory
apt-get install ruby-rails (not sure about the package name), which will install the ruby on rails version maintained by your distributions maintainers (Canonical).
install and use rvm or rbenv (and there might be other options). Afterwards gem install will usually just work and install the gems for your user only
While the rvm setup might be a tiny bit confusing for newbies, I recommend using that approach. It will make updating and installing ruby, gems and different versions of it really easy.

How to move or uninstall gems from default System Ruby folder to RVM?

I have so many issues trying to update from Rails 3.2 to Rails 4.1 following the guide that I decided to uninstall Ruby, Rails and RVM (with all its gems) and start over.
RVM and Ruby Gone. $ rvm remove
But still have a bunch of GEMS that I previously installed.
$gem list
As suggested on this answer, to remove all gems do:
$for i in `gem list --no-versions`; do gem uninstall -aIx $i; done
But I bump again on the error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
This is so frustrating! Using sudo does not make the fix either.
Even if I try to uninstall one by one, the system wont let me:
$rails uninstall
Could not find gem 'pg (~> 0.17.1) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
Why do I need another Gem to uninstall a Gem?!
Try
for i in `gem list --no-versions`; do sudo gem uninstall -aIx $i; done
This SO question has some ideas: getting rid of ruby gems that won't die
The answer to this SO question has step by step instructions to set it up properly: Removing Gems errors

ERROR: While executing gem ... (Errno::EISDIR) gem install rails

I'm trying to install Ruby on rails, so first I installed RVM rvm install 1.9.2. After that install this gem install rails. It shows this error
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.8 directory.
Then I used this sudo chmod 0777 /var/lib/gems/1.8/
After that when I install, its showing this error:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems/1.8/cache/railties-3.2.2.gem
Then I run sudo chmod 0777 /var/lib/gems/1.8/cache/railties-3.2.2.gem
After that I install gem install rails. Again its showing this error
ERROR: While executing gem ... (Errno::EISDIR)
Is a directory - /var/lib/gems/1.8/cache/railties-3.2.2.gem
You're still using the system ruby install (1.8). To use the Ruby you've just installed with rvm, do rvm use 1.9.2. Then try gem install rails again. The Rails gem should be installed under your home directory, you shouldn't need root permissions.
To make the rvm Ruby the default, so you always start with it when you open a new terminal, do rvm --default use 1.9.2 (note that's two dashes).
manually install gem-ctags, then retry installing your failing gem
gem install gem-ctags
gem install backports -v '3.3.3'
bundle install

'gem install' and 'sudo gem install'

I've got an issue installing gems on my mac (os 10.6).
I used to be able to run
gem install <gem-name-here>
but after updating something, it could be the version of gem I'm using, but it's unlikely, I now get the error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/bin directory.
On the face of it, it looks like my 'GEM_HOME' isn't set. If so, why has this been unset, and how can I change it back?
Secondly - when I run
gem list
I see all gems - including those in ~/.gem, but when I run:
gem server
I only see gems in /usr/bin... strange huh?
Any help would be great to resolve this - I dont like using sudo to install gems constantly.
Install RVM.
Profit!
It really is that simple. In addition, you will be able to install and easily switch between different Ruby versions and sets of gems with a single command. It will all be installed in ~/.rvm (by default) and you won't need to use sudo to install gems.
Have you tried doing $bundle update after installing the gems that you wanted?
Follow the instructions in this guide:
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
gem install <gem-name-here>
If you were already doing this, completely delete the ~/.gem directory and try again.

Resources