在amazon linux 2 ec2中使用gem安装时没有写入权限

vuktfyat  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(354)

我的ruby应用程序正在AmazonLinux2ElasticBeanstalk中运行。当我将应用程序部署到环境中时,它会告诉我bunlder没有安装。我在安装bundler时遇到以下错误, sudo gem 也不行

[ec2-user@ip-10-0-2-220 ~]$ gem install bundler
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /opt/rubies/ruby-2.7.4/lib/ruby/gems/2.7.0 directory.
[ec2-user@ip-10-0-2-220 ~]$ sudo gem install bundler
sudo: gem: command not found

您能告诉我如何获得写入权限吗?

70gysomp

70gysomp1#

您可以尝试以下几种可能性:

i: change permission of the directory 
[ec2-user@ip-10-0-2-220 ~]$ chmod 777 -R /opt/rubies/ruby-2.7.4/lib/ruby/gems/2.7.0

[ec2-user@ip-10-0-2-220 ~]$ gem install bundler

这会给你所有的权限(如果它不允许你的话,你可以使用sudo chmod)到这个目录

ii. get the path of gem and create a sym link to it in /bin 
then sudo gem command would work for you. 

to know the gem binary path just do 

[ec2-user@ip-10-0-2-220 ~]$ type gem

this would return you current gem binary path

create a sym link  
[ec2-user@ip-10-0-2-220 ~]$ ln -s gempath /bin/gem 
( gempath here is the output of "type gem" command)

and then "sudo gem install blunder" should work

相关问题