error instatlling ruby on rails in mac - ruby-on-rails

I was trying to install ruby on rails in mac.
I have Xcode and gcc compiler installed. When i tried to install git, it showed me the following error:
$:~ gem install git
$ ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Library/Ruby/Gems/1.8/gems/git-1.2.5
I changed the permissions of my 1.8 and gems directory. Still it is showing the same error. Any suggestions?

Have you tried with sudo? Try sudo gem install git.
Reference documentation: https://github.com/schacon/ruby-git#install

Related

Unknown Host Error while updating Ruby-Gems

I am trying to update ruby gems by using:
gem update --system
But I am getting error:
ERROR: While executing gem ...(Gem::RemoteFetcher::UnknownHostError)
no such name (https://rubygems.org/specs.4.8.gz).
Unsure what version of rubygems you have installed, however there are three ways to fix:
network issues - try again later.
the version you have is bricked for updates, and you will need to install another way
NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no rubygems-update installed. You will need to use the following instructions if you see Nothing to update. If you have an older version of RubyGems installed, then you can still do it in two steps:
$ gem install rubygems-update # might need to be admin/root
$ update_rubygems
Failing that you have to get your hands dirty:
Download from https://rubygems.org/pages/download
Unpack into a directory and cd there
Install with: ruby setup.rb (you may need admin/root privilege)
See https://rubygems.org/pages/download for more info

Permission Error When Trying To Install Rails (OSX)

I am new to programming and am trying to get rails installed on my terminal. I have been following instructions from a friend, installing the xcode command line tools, homebrew, git, rbenv, ruby-build, ruby gems, ruby, and postgres. But whenever, I try $gem install rails, I get the following:
Russell-Silvers-MacBook-Pro:~ Russell_Silver$ gem install rails
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-4.2.0/README.md
This is especially frustrating because when I run $gem list, it says I have rails 3.2.18. Which is peculiar, because when I run $rails v$, it tells me I have Rails 4.2.0.
When I try to use rails rails my new_app
Errno::EACCES: Permission denied # rb_sysopen - /Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-4.2.0/README.md
An error occurred while installing rails (4.2.0), and Bundler cannot continue.
Make sure that `gem install rails -v '4.2.0'` succeeds before bundling.
run bundle exec spring binstub --all
/Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/shared_helpers.rb:83: warning: Insecure world writable dir /Users/Russell_Silver in PATH, mode 040707
bundler: command not found: spring
Install missing gem executables with `bundle install`
Russell-Silvers-MacBook-Pro:~ Russell_Silver$ bundle install
/Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/vendor/thor/shell/basic.rb:355: warning: Insecure world writable dir /Users/Russell_Silver in PATH, mode 040707
Could not locate Gemfile or .bundle/ directory
This is really frustrating, especially for someone new to programming such as myself, so I am seeking help from anybody who might know what is wrong.
Your rbenv installation was incorrectly installed as it had elevated privileges which caused your user account to not have write access to ~/.rbenv.
Issue the following command in order to take of ownership of the directory:
sudo chown -R Russell_Silver ~/.rbenv
Note that some users may have a different rbenv directory, e.g. /usr/local/var/rbenv. This would take the place of ~/.rbenv in the above command.

Failure to install ruby gems with rbenv

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.

Error during Installing Rails in Ubuntu 10.04

First I installed rvm for multi-user using script
\curl -L https://get.rvm.io | sudo bash -s stable
and I added users to rvm group.
and rvm seems worked fine. so I installed ruby 1.9.3 and set 1.9.3 as default
and now I tried to install rails with command
gem install rails
It seems worked fine, but when fetching json-1.7.6.gem and an error occurs.
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby extconf.rb
creating Makefile
make
sh: make: Permission denied
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p374/gems/json-1.7.6 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p374/gems/json-1.7.6/ext/json/ext/generator/gem_make.out
So I thought it would be related with permission, so I tried
sudo gem install rails
but then this error occurs.
sudo: gem: command not found
What should I do?
use sudo as follows..
sudo gem install rails
Updated Answer:
our $PATH variable needs to include the exact path to your Ruby's bin directory. Adding a directory to the PATH does not include it's subfolders. Try adding the bin directory via:
export PATH=$PATH:/home/adam/.gem/ruby/1.8/bin
or if you installed the gem using sudo:
export PATH=$PATH:/usr/lib/ruby/gems/1.8/bin
You might want to add this to your .bashrc file, so that you don't have to set this manually every time your open up a new bash.
you can use rvmsudo to run sudo commands. But you should really be using Gemfiles to install gems using Bundler.

Errors when trying to update ruby gems from 2.0.1

I am trying to set myself up on a mac to learn Ruby on Rails, however I seem to be having some problems. If I try to run commands such as ./script/server, i get this:
Rails requires RubyGems >= 0.9.4 (you have 0.9.2). Please gem update --system and try again.
When I run "gem update.." I get this:
Updating RubyGems...
Attempting remote update of rubygems-update
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /opt/local/lib/ruby/gems/1.8/cache/rubygems-update-1.3.0.gem
got it.
sudo gem update --system
Starting with El Capitan, Apple prevents user applications to modify /usr/bin for security reasons. So better install/update rubygems in the recommended folder, /usr/local/bin:
sudo gem update -n /usr/local/bin --system
(recommendation taken from https://stackoverflow.com/a/39928447/1033581)

Resources