Ruby gem permission denied /var/lib/gems using Ubuntu - ruby

I'm trying to install Rails using Gem and did the following from the terminal:
sudo apt-get install ruby-full build-essential
sudo apt-get install rubygems
export PATH=/var/lib/gems/1.8/bin:$PATH
gem install rails
Then I get the following message:
ERROR: While executing gem ... (Errno:EACCES)
Permission denied - /var/lib/gems
I've followed the instruction from Ubuntu Help Guide & I'm using Oracle VM VirtualBox to run Ubuntu under Windows 7 and have RubyGems v1.8.15.

You need to prefix the gem command with sudo because /var/lib/gems is owned by root. You could also take a look at RVM which allows really easy installation and management of gems and Ruby versions. Best part, it's all in your home dir!
EDIT: per #AndrewMarshall's comment bellow, rbenv is an alternative to RVM.

Related

permission error when installing gem from terminal

I have been trying to install zsteg with the gem install command, but i get this error, even as a super-user:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
I have tried sudo gem install zsteg, sudo -s then gem install zsteg and just gem install zsteg, but none work. What should I do?
edit: I am using macOSX Mojave and I have ruby
I just reinstalled rake and zsteg and it worked for me.
1. make sure you have ruby-dev
2. update --system
3. sudo gem install rake
4. sudo gem install zsteg
good luck!
So I worked it out. I changed the install directory to /usr/local/bin using this:
gem install zsteg -n /usr/local/bin

Getting Errorno-EACCES error while installing Rails on ubuntu

I successfully installed ruby on my Ubuntu server by using the following command.
1-sudo apt-get install python-software-properties
2-sudo apt-add-repository ppa:brightbox/ruby-ng
3-sudo apt-get update
4-sudo apt-get install ruby2.1
But when i tried to install Rails version 4.2.0 using the below command.
gem install rails --version=4.2.0
i got the following error.
Error:
Error:While executing gem (Errorno-EACCES)
permission denied # dir_s_mkdir - /var/lib/gems
Please help me to resolve this error and install rails successfully.I also have another doubt here.After installing ruby when i chcked the version it is showing me the ruby version 2.1.7 but here i need ruby version 2.1.5.Please also help me do this.I am using Ubuntu 14.0 version.
The issue might be because the gem executable is not installed in user directory.
You can confirm this using which gem.
Run this command for installing rails.
sudo gem install rails --version=4.2.0
UPDATE:
The error : Errror: Error installing rails Error: failed to build gem native extension might be because of lack of dev-headers.
Try running this :
sudo apt-get install ruby2.1-dev
These errors are the reasons you should probably try using rbenv or rvm to install ruby and rails.

Ruby Gems : sudo gems not showing with gems

I have a sudo rights on my ssh user. I can not run sudo bundle install command but can run bundle install without sudo.
Once I run the bundle install, Few gems get install but those who need gcc and c++ compiler I have to install in sudo permissions like sudo gem install json -v '1.8.0'.
Now if I try to run bundle that gem is not available due to installed with sudo permission.
Is there any other way to install such compiler gems without sudo?
I was not getting the right environement for installing ruby and gemsets . But
rvmsudo worked for me
I tried installing those gems which required compiler like
rvmsudo gem install json -v '1.8.0'
And it worked for me.
I am having only local user access which does not have any rights to run commands like yum

Installing Compass & Susy on Ubuntu 12.04

I'm trying to install Compass and Susy on my Ubuntu 12.04.
What I have tried are the following steps on the console:
sudo apt-get install rubygems1.8
sudo gem install rubygems-update # Instead of sudo gem update --system
sudo update_rubygems
sudo gem install compass # Installing Compass & Sass
sudo gem install susy
So the gems are installed and will be listed when I do the following command:
gem list
But now, when I try to create a new compass project with
compass create project
I get the following error:
/usr/local/bin/compass: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory
My current ruby version is 1.8.7. So I installed ruby 1.9.1 and get it working.
The console still says the current ruby version is 1.8.7
My question: Do I have to run with both ruby versions to get that working? Is there another way under ubuntu? It's working, I know, but it's a bit confusing.
Using Ubuntu's package manager for multiple ruby versions is a bit of a lost cause.
Most people use rvm, which allows you to install and switch between multiple rubies very easily.
Other popular options are rbenv and chruby. It's just a question of personal preference, but I'd say that rvm has the slight edge for beginners.
Also, I wouldn't recommend installing ruby 1.9.1 - it's best to use 1.9.3 as there are some compatibility issues with other 1.9.x versions.
You can then install compass and sass via ruby gems (rather than aptitude):
$ gem install compass
$ gem install sass
This simple command works on ubuntu 14.10
sudo apt-get install ruby-compass
RVM is awesome and really easy to install. I managed to install rvm, compass, and sass with these commands in my terminal:
Firstly:
curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled --ruby=1.9.3
This will instal rvm, it will put a command in ~/.bash_profile to load rvm automatically, except this isn't what Ubuntu uses so put this line into your ~/.bashrc file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Then simply run:
gem install compass
gem install susy #(or sass)
Install build-essentials and ruby-dev packages to install compass without errors.
sudo apt-get install build-essential
sudo apt-get install ruby
sudo apt-get install ruby-dev
sudo gem install compass
Masterchief's answer is close, but didn't work for me. This web page provided a clear and reliably working way to install rvm on my ubuntu server instance: http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

Error with rhc-create-domain on command line (Openshitft)

First I do not know much about Ruby, but, the Openshit command line uses the 'rhc' to manage my apps on cloud. Nice!...but the 'rhc' program its based on Ruby, Rubygems....something.
Ok, i'm installed theses programs with apt-get on Linux Mint (Ubuntu based):
sudo apt-get install ruby1.8
sudo apt-get install gem
sudo apt-get install rubygems
gem install json_pure
gem install rake
gem install rhc
Nice!..rhc its visible in my console, but when i try execute any rhc command, the console returns for me this:
rhc-create-domain -n carlosjr -l carlosjrcabello#gmail.com
/usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find rhc (>= 0) amongst [json-1.6.6, json_pure-1.6.6, mime-types-1.18, parseconfig-0.5.2, rest-client-1.6.7] (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1231:in `gem'
from /usr/local/bin/rhc-create-domain:18
Remembering, i do not know if I have to update something in ruby or RubyGem.
No more for now. Thanks.
I solved the problem. The Linux Mint 12 (Lisa) with KDE contains the basic Ruby packages installed, so I purged all ruby packages before installing all required RHC apps. Here is my solution (in command line):
sudo apt-get purge ruby* (caution with grub packages)
sudo reboot
sudo apt-get install ruby1.8
sudo apt-get install gem
sudo apt-get install rubygems
gem install json_pure
gem install rake
gem install rhc
All rhc functionalities should now be working.
PS: I think that Openshift can be explain more the install process of Ruby apps..using my case for example, I dont have anything knowledge of Ruby :/
I had the same error message on Ubuntu 12.04. In my case the problem was /var/lib/gems/ was not world readable.

Resources