Manindra Gautam
Manindra Gautam

Reputation: 387

rails new <app-name> requires password for gems installation in ./vendor/bundle

Your user account isn't allowed to install to the system RubyGems.

You can cancel this installation and run:

  bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to RubyGems using sudo.

Password:

Upvotes: 1

Views: 644

Answers (1)

xploshioOn
xploshioOn

Reputation: 4125

If it says that you don't have the priviliges, then you just need to run it with sudo

sudo gem install bundler --no-rdoc --no-ri

but I really recommend installing rbenv or rvm, to have a better control of the ruby versions and with that you don't need password or sudo command to install the gems.

I will guide you to install rvm here, this is for personal preference, but you con install rvenb too with the same result.

before anything else, you have to remove completely the ruby version that you have installed on this moment and all the gems

gem uninstall --all # maybe you will need sudo here
sudo apt-get purge ruby

first install mpapis public key

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

then install rvm

\curl -sSL https://get.rvm.io | bash

then add to .bashrc

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

add to .bash_profile

source ~/.profile

then you can install the ruby version that you want (i am using 2.3.0 here as an example, change for the version that you were working before on the app)

rvm install 2.3.0

with this you have installed ruby, I recommend to run this command if you would not use the documentation of gems in local

echo 'gem: --no-document' >> ~/.gemrc

then you can set the ruby version that you want to use, you have different options, select it manually everyime you open the terminal with

rvm use 2.3.0 # or the version that you want to use in that moment

or add to the gemfile the ruby version and rvm will select if for you everytime you make a cd to the path of the app adding this to your gemfile

source 'https://rubygems.org' # this is by default on your gemfile
ruby '2.3.0' # this is the line you need to add, change for the version that you want on he app

when you have the selected version of ruby, you have to install bundler gem, you need to run this just once by ruby version that you install

gem install bundle

then you can run bundle install on your app and will work like a charm.

With rvm you can have different versions of ruby on rails installed on your machine, an as I said, per version that you install you need to install the bundler gem once.

if you have differents version of ruby installed, I recommend that you add a default so if you haven't set the ruby version on the terminal in that session, it will take one by default, you can do it like this

rvm --default use 2.3.0

hope that this helps you to be clear.

Upvotes: 0

Related Questions