RVM gem permissions error - ruby-on-rails

I started trying to set up a local rails installation for development. After I installed in using apt-get, however, I learned about RVM, so I removed the earlier one, and reinstalled from RVM. It looks like I have residual problems, though. Specifically, when I try to install rails I get...
$ gem install rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.9.1 directory.
This already looks like a problem, because I don't want it to be in the /var/ directory, I want it to be in the user directory. So, I check the following...
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/myusername/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
As well as sudo'd:
$ sudo gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/myusername/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
gems seem to live in /var/lib for some reason. Is this normal? How can I fix this so I can install the rails gem?
EDIT: UPDATE!
It appears to me that I have gems installed twice, once in /var/lib/gems/1.9.91 (bad) and once in /home/myusername/.gem/ruby/1.9.1 (good).
I think what is happening here is that when I type "gem" the installation in /var/lib/gems/1.9.1 (bad) is taking priority over /home/myusername/.gem/ruby/1.9.1 (good). Can anyone confirm that? Also, would it be OK and fix things just to delete the bad directory, or would that cause problems?

You missed to use ruby, you can do it with:
rvm use 1.9.3 --install
In case 1.9.3 was not installed, this command will also install it!
It also looks you are using Ubuntu, make sure you are not using RVM from Ubuntu package - that thing is broken! You can find instruction how to fix it here: https://stackoverflow.com/a/9056395/497756

Related

rails c throws error bin_path': can't find executable rails for rails-3.2.8 (Gem::Exception)

I am trying to open rails console in production mode and it throws below error,
/usr/local/lib/ruby/1.9.1/rubygems.rb:340:in `bin_path':
can't find executable rails for rails-3.2.8 (Gem::Exception)
from /usr/local/bin/rails:19:in `<main>'
I have not used rvm. Other commands like rake:xyz runs properly. Output of $gem env is as follows,
RubyGems Environment:
RUBYGEMS VERSION: 1.3.7
RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-linux]
INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
RUBY EXECUTABLE: /usr/local/bin/ruby
EXECUTABLE DIRECTORY: /usr/local/bin
RUBYGEMS PLATFORMS:
ruby
x86_64-linux
GEM PATHS:
/usr/local/lib/ruby/gems/1.9.1
/root/.gem/ruby/1.9.1
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:benchmark => false
:backtrace => false
:bulk_threshold => 1000
REMOTE SOURCES:
http://rubygems.org/
Please let me know what needs to be. I cannot go for bundle install, etc as its production env and there are few tasks running. I dont want to break existing tasks / processes
It worked by using,
RAILS_ENV=production bundle exec rails c
Being a beginner,I have tried the same on my system and I got into the rails console.In fact my gem env resulted in
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/mmohan/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
On reading the error, gem is found to be outdated. The best method to tackle it is by updating gem to latest one. If for assistance, check thishttp://www.coval.nl/blog/?p=18

Error updating Gemfile

So my issue seems to be coming from an old Gemfile (from a past project) that still seems to by linked to an old Gemfile. What I am trying to do is update the current information stored with new PATHS for installation and execution.
I am working on a new project but continue to run into errors and hope to update the information. When I run GEM ENV the results print paths to a different directory other than the info stored in my .bash_profile & .gemrc:
Example:
$ gem env
Failed to load /Users/brainz/.gemrc
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
- INSTALLATION DIRECTORY: /Users/brainz/dev/oldfile/local/gems
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /Users/brainz/dev/oldfile/local/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-12
- GEM PATHS:
- /Users/brainz/dev/csbox/local/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
This is what I would like my -> .gemrc file:
gem: --no-ri --no-rdoc
gemhome: /home/brainz/.gems
gempath:
- /home/brainz/.gems
- usr/lib/ruby/gems/2.0
:benchmark: false
:update_sources: true
:verbose: false
:backtrace: false
:sources
- http://gems.rubyforge.org/
:bulk_threshold: 1000
Any help would be greatly appreciated as I have hit a wall.
Clear your Gemfile.lock then hit bundle update
have you tried deleting your Gemfile.lock file and bundle install again

Gem environment/install location and bundler

it's been a while since I setup a brand new Rails environment.
I am trying to get gems to install under ~/.gems as opposed to /usr to avoid sudo-ing constantly.
Here is my gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/myname/.gems
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /home/myname/.gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/myname/.gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri"
- "gemhome" => "/home/myname/.gems"
- "gempath" => ["/home/myname/.gems"]
- REMOTE SOURCES:
- https://rubygems.org/
$ which bundle
/home/myname/.gems/bin/bundle
now I did rails new SomeApp and when I run
bundle install
I get:
Errno::EACCES: Permission denied - /usr/local/lib/ruby/gems/2.0.0/build_info/jquery-rails-3.0.4.info
An error occurred while installing jquery-rails (3.0.4), and Bundler cannot continue
Which tells me that it's still trying to install the gem NOT where I want it. Any thoughts what to check? (I do have a ~/.gemrc file, the contents are the last 3 lines of the GEM CONFIGURATION section above).
Many thanks for all tips -- this was supposed to be a quick and easy step :)
highly recommend rbenv and rbenv-gemset, installing here with homebrew:
brew install rbenv rbenv-gemset
cd into/project/
echo specialgemsetname > .rbenv-gemsets
now start a new terminal (to ensure environment is correct) and setup your project.

$ gem install rails failing. Any workaround?

I'm having problems installing Rails on OS X Lion for some reason...
Installing under RVM...
$ gem install rails
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Forbidden 403 (http://production.cf.rubygems.org/gems/rdoc-3.12.gem)
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.12
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-darwin11.2.0]
- INSTALLATION DIRECTORY: /Users/ethan/.rvm/gems/ruby-1.9.3-p0#mtc_apps
- RUBY EXECUTABLE: /Users/ethan/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/ethan/.rvm/gems/ruby-1.9.3-p0#mtc_apps/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/ethan/.rvm/gems/ruby-1.9.3-p0#mtc_apps
- /Users/ethan/.rvm/gems/ruby-1.9.3-p0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gemcutter.org", "http://gems.rubyforge.org/", "http://gems.github.com"]
- "install" => "--no-rdoc --no-ri"
- "update" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
Anyone seen this? Know of a way to get it to work?
Actually, it seemed to be hanging up specifically on rdoc on my system. So I downloaded the gem to my desktop and installed it with...
$ gem install --local ~/Desktop/rdoc-3.12.gem
Then the Rails install was able to complete after that.
Looks like temporary problems with rubygems servers.
I have troubles updating my gems right now.
Just try again after some time, from few minutes to few hours.

Installing ruby executables via bundler puts them in a different location than gem install

Having some issues installing a gemset in ruby 1.8.7p334 (enterprise edition) running rails 1.2.6 on Fedora 8.
The main issue I have is that bundler installs the executables in /usr/lib/ruby/gems/1.8/bin. However, Gem installs the executables in /usr/bin, which is where I want them.
How can I tell bundler to place them in /usr/bin? I've looked at the --binstubs flag, but it doesn't seem to complete the necessary requirements.
Any help is much appreciated.
RubyGems Environment:
- RUBYGEMS VERSION: 1.5.2
- RUBY VERSION: 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /root/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Of course I find the answer after posting the question. It's the little-documented BUNDLE_BIN configuration key. It can be set by .bundle/config, an environment variable (my choice) or by bundle config. Looks like you can also specify it on the command line as --bin.
$ export BUNDLE_BIN="/usr/bin"
bin (BUNDLE_BIN)
Install executables from gems in the bundle to the specified directory.
Defaults to false.

Resources