/var/lib/gems/2.3.0 디렉토리에 대한 쓰기 권한이 없습니다.
우분투 16.04에 루비가 설치되어 있습니다.
$which ruby
/usr/bin/ruby
$ruby -v
ruby 2.3.0p0 (2015-12-25) [x86_64-linux-gnu]
$gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.
어떤 도움이라도 대단히 감사하겠습니다!
먼저 우분투가 설치 한 루비를 sudo apt-get remove ruby
.
그런 다음 해당 문서에 따라 rbenv 및 ruby-build를 사용하여 루비를 다시 설치합니다 .
cd $HOME
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.3.1
rbenv global 2.3.1
ruby -v
마지막 단계는 Bundler를 설치하는 것입니다.
gem install bundler
rbenv rehash
그럼 즐기세요!
데릭
rb-env / rvm 대신 배포판 Ruby를 사용하려면 GEM_HOME
현재 사용자에 대해 a 를 설정할 수 있습니다 . 의 루비 보석 저장할 디렉토리 생성하여 시작 하여 사용자 :
$ mkdir ~/.ruby
그런 다음 해당 디렉토리를 사용하도록 쉘을 GEM_HOME
업데이트 PATH
하고 Ruby gem bin 디렉토리를 포함하도록 변수를 업데이트하십시오 .
$ echo 'export GEM_HOME=~/.ruby/' >> ~/.bashrc
$ echo 'export PATH="$PATH:~/.ruby/bin"' >> ~/.bashrc
$ source ~/.bashrc
(That last line will reload the environment variables in your current shell.)
Now you should be able to install Ruby gems under your user using the gem
command. I was able to get this working with Ruby 2.5.1 under Ubuntu 18.04. If you are using a shell that is not Bash, then you will need to edit the startup script for that shell instead of bashrc
.
(January 2019) To install Ruby using the Rbenv script, follow these steps:
1. First, update the packages index and install the packages required for the ruby-build tool to build Ruby from source:
sudo apt-get remove ruby
sudo apt update
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev
2. Next, run the following curl command to install both rbenv and ruby-build:
curl -sL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash -
3. Add $HOME/.rbenv/bin to the system PATH.
If you are using Bash, run:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
If you are using Zsh run:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
4. Install the latest stable version of Ruby and set it as a default version with:
rbenv install 2.5.1
rbenv global 2.5.1
To list all available Ruby versions you can use:
rbenv install -l
5. Verify that Ruby was properly installed by printing out the version number:
ruby -v
# Output
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
SOURCE: How To Install Ruby on Ubuntu 18.04
EDIT: Install rubygems:
sudo apt-get install rubygems
Rather than changing owners, which might lock out other local users, or –some day– your own ruby server/deployment-things... running under a different user...
I would rather simply extend rights of that particular folder to... well, everybody:
cd /var/lib
sudo chmod -R a+w gems/
(I did encounter your error as well. So this is fairly verified.)
Try using chown -R
on the var/lib/gems
directory, assigning ownership to the user [rubyusername
] in this example, the user that will be installing and developing with gems.
# chown -R rubyusername:rubyusername /var/lib/gems
This recursively changes everything under the gems directory. For extra security on multi-user systems, you can also create a group, rather than chowning the individual rubyusername, and add users to that group.
Building on derek's answer above, it is generally not recommended to use the system provided Ruby instance for your own development work, as system tools might depend on the particular version or location of the Ruby install. Similar to this answer for Mac OSX, you will want to follow derek's instructions on using something like rbenv (RVM is a similar alternative) to install your own Ruby instance.
However, there is no need to uninstall the system version of Ruby, the rbenv installation instructions provide a mechanism to make sure that the instance of Ruby available in your shell is the rbenv instance, not the system instance. This is the
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
line in derek's answer.
For me, this problem ammounted to simply adding sudo to the front of this bash command:
gem install rails -v 5.2.3
SO IT SHOULD BE
sudo gem install rails -v 5.2.3
'Programing' 카테고리의 다른 글
여러 글꼴 두께, 하나의 @ font-face 쿼리 (0) | 2020.09.15 |
---|---|
Angular2-Http POST 요청 매개 변수 (0) | 2020.09.15 |
Html을 일반 텍스트로 어떻게 변환합니까? (0) | 2020.09.15 |
C #의 팩토리 패턴 : 팩토리 클래스에서만 개체 인스턴스를 만들 수 있는지 확인하는 방법은 무엇입니까? (0) | 2020.09.15 |
액세스 토큰을 사용하여 Facebook 사용자 ID를 얻는 방법 (0) | 2020.09.15 |