首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:执行gem时...(Gem::FilePermissionError)

错误:执行gem时...(Gem::FilePermissionError)
EN

Stack Overflow用户
提问于 2013-09-04 03:21:20
回答 15查看 104.1K关注 0票数 55

我已经检查了所有其他类似的答案,没有一个与我的完全相同,这些解决方案也没有一个对我有效。

gem environmentsudo gem environment给出了相同的结果:

代码语言:javascript
复制
RubyGems Environment:
  - RUBYGEMS VERSION: 1.5.3
  - RUBY VERSION: 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - 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.8
     - /home/ava/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

rvm -vrvm 1.22.3

ruby -vruby 1.8.7

OSX 10.8.4

echo $PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/ava/.rvm/bin:/home/ava/bin

gem install <gem-name>给出

代码语言:javascript
复制
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /usr/local/lib/ruby/gems/1.8 directory.

而我可以通过sudo安装相同的软件。我做错了什么?

更新:

根据评论和这个post,我运行了以下命令:

rvm implode,然后重新安装稳定版本。rvm install 1.9.3或任何其他ruby安装都会失败,并显示

代码语言:javascript
复制
Error running '__rvm_make -j24',
please read /home/ava/.rvm/log/log/1378418790_ruby-1.9.3-p194/make.log
There has been an error while running make. Halting the installation.

make.log

代码语言:javascript
复制
    [2013-09-05 22:06:48] make
current path: /home/ava/.rvm/src/ruby-1.9.3-p194
command(2): make -j24
        CC = gcc
        LD = ld
        LDSHARED = gcc -shared
        CFLAGS = -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Werror-implicit-function-declaration  -fPIC
        XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
        CPPFLAGS =   -I. -I.ext/include/x86_64-linux -I./include -I.
        DLDFLAGS = -Wl,-soname,libruby.so.1.9
        SOLIBS = -lpthread -lrt -ldl -lcrypt -lm
compiling main.c
compiling dmydln.c
compiling dmyencoding.c
compiling version.c
compiling miniprelude.c
compiling array.c
compiling bignum.c
compiling class.c
compiling compar.c
compiling complex.c
compiling dir.c
compiling dln_find.c
compiling enum.c
compiling enumerator.c
compiling error.c
compiling eval.c
compiling load.c
compiling proc.c
compiling file.c
:
:
:
In file included from ossl.h:213,
                 from ossl_pkcs5.c:5:
openssl_missing.h:71: error: conflicting types for ‘HMAC_CTX_copy’
/usr/local/include/openssl/hmac.h:102: error: previous declaration of ‘HMAC_CTX_copy’ was here
openssl_missing.h:95: error: conflicting types for ‘EVP_CIPHER_CTX_copy’
/usr/local/include/openssl/evp.h:459: error: previous declaration of ‘EVP_CIPHER_CTX_copy’ was here
make[2]: *** [ossl_pkcs5.o] Error 1
In file included from ossl.h:213,
                 from ossl_x509req.c:11:
:
:
:
EN

回答 15

Stack Overflow用户

发布于 2018-06-25 02:50:23

错误:执行gem时...(Gem::FilePermissionError)您没有/Library/Ruby/Gems/2.3.0目录的写入权限。

  1. 安装RVM
  2. 在shell资源文件中设置gem文件夹。即.zshrc.bashrc

代码语言:javascript
复制
export GEM_HOME="$HOME/.gem"

gem gem i LIBRARY_NAME安装

票数 66
EN

Stack Overflow用户

发布于 2016-02-27 12:59:30

要解决错误,请执行以下操作:

错误:执行gem时...(Gem::FilePermissionError)您没有/usr/local/lib/ruby/gems/1.8目录的写权限。

下面的解决方案对我很有效:

代码语言:javascript
复制
sudo gem install -n /usr/local/bin cocoapods
票数 59
EN

Stack Overflow用户

发布于 2014-09-08 09:08:54

您的全局(系统范围)配置文件可能设置了--no-user-install标志。创建/编辑本地~/.gemrc文件并附加以下行:

代码语言:javascript
复制
:gemdir:
    - ~/.gem/ruby
install: --user-install

便笺

gemdir选项的实际目录将根据您的系统/需要而有所不同;可能需要也可能不需要,但在home文件夹(gemdir)中指定所需的安装目录可能比假定它会自己处理更好。

ArchLinux Wiki提供了一些与此相关的有用/组织良好的信息。

chruby

或者,与已经建议的rvm解决方案类似,您可以尝试使用chruby来维护、配置和使用ruby的本地版本。但是,要安装其他版本的ruby,您需要使用ruby-install

代码语言:javascript
复制
$ brew install chruby ruby-install
$ ruby-install ruby 2.4.0

$ echo "source /usr/local/opt/chruby/share/chruby/chruby.sh" >> ~/.bash_profile
$ echo "chruby ruby" >> ~/.bash_profile

# Do this to select the default alternative ruby installation, assuming
# there is no other version installed.
$ chruby ruby

## Otherwise, list the available ruby versions installed, and select
$ chruby
ruby-2.3.0
ruby-2.4.0

$ chruby ruby-2.4.0

从项目的自述文件中:

改变了当前的拼音。特性

更新$PATH。还会将RubyGems bin/目录添加到$PATH。正确设置$GEM_HOME和$GEM_PATH。用户:.gem安装在~/.gem/$ruby/$version中。Root: gem直接安装到/path/to/$ruby/$gemdir中。另外设置$RUBY_ROOT、$RUBY_ENGINE、$RUBY_VERSION和$GEM_ROOT。如果给定第二个参数,则可选择设置$RUBYOPT。调用哈希-r以清除命令查找哈希表。红宝石的名字模糊匹配。默认为系统拼音。支持自动切换和.ruby版本文件。支持bash和zsh。小(~100 LOC)。有测试。

反功能

不能挂接cd。不安装可执行的垫片。不需要将Rubies安装到您的主目录中。默认情况下,不会自动切换红宝石。不需要对Ruby目录的写访问权限即可安装gem。

要求

bash >= 3或zsh

票数 37
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18599889

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档