Ava*_*Ava 33 ruby macos gem sudo osx-mountain-lion
我检查了所有其他类似的答案,没有一个与我的完全一样,这些解决方案都没有为我工作.
gem environment并sudo gem environment给出相同的结果:
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/
Run Code Online (Sandbox Code Playgroud)
rvm -v : rvm 1.22.3
ruby -v : ruby 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> 给
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/lib/ruby/gems/1.8 directory.
Run Code Online (Sandbox Code Playgroud)
而我可以通过sudo安装相同的.我究竟做错了什么?
更新:
根据评论和这篇文章,我运行了以下内容:
rvm implode然后重新安装稳定版本.
rvm install 1.9.3或任何其他ruby安装失败
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.
Run Code Online (Sandbox Code Playgroud)
make.log
[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:
:
:
:
Run Code Online (Sandbox Code Playgroud)
小智 46
要解决此错误:
错误:执行gem时...(Gem :: FilePermissionError)您没有写入/usr/local/lib/ruby/gems/1.8目录的权限.
以下解决方案适合我:
sudo gem install -n /usr/local/bin cocoapods
Run Code Online (Sandbox Code Playgroud)
dim*_*iax 28
错误:执行gem时...(Gem :: FilePermissionError)您没有/Library/Ruby/Gems/2.3.0目录的写权限.
首先安装RVM,然后在.zshrc或.bashrc中设置用户gem文件夹,否则:
export GEM_HOME="$HOME/.gem"
Run Code Online (Sandbox Code Playgroud)
现在.zshrc将宝石放在安全的位置.
tad*_*man 25
如果您已rvm以root用户sudo身份安装,则必须安装任何内容.
您可以rvm作为普通用户以用户模式安装,在这种情况下,所有内容都存储在您的主目录中,sudo不需要.
如果您未致力于此特定安装,请键入sudo rvm implode并重新开始.
ILM*_*o_7 23
您的全局(系统范围)配置文件可能已设置--no-user-install标志.创建/编辑本地~/.gemrc文件并附加以下行:
:gemdir:
- ~/.gem/ruby
install: --user-install
Run Code Online (Sandbox Code Playgroud)
注意
该gemdir选项的实际目录将根据您的系统/期望而有所不同; 它可能需要也可能不需要,但最好在你的home文件夹(gemdir)中指定所需的安装目录,而不是假设它本身会被处理掉.
该ArchLinux的维基有关于这一些有用/组织良好的信息.
或者,类似于rvm已建议的解决方案,您可以尝试使用chruby来维护,配置和使用本地版本ruby.ruby但是,要安装其他版本,需要使用ruby-install.
$ 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
Run Code Online (Sandbox Code Playgroud)
从项目的自述文件中:
改变当前的Ruby.特征
Run Code Online (Sandbox Code Playgroud)Updates $PATH. Also adds RubyGems bin/ directories to $PATH. Correctly sets $GEM_HOME and $GEM_PATH. Users: gems are installed into ~/.gem/$ruby/$version. Root: gems are installed directly into /path/to/$ruby/$gemdir. Additionally sets $RUBY_ROOT, $RUBY_ENGINE, $RUBY_VERSION and $GEM_ROOT. Optionally sets $RUBYOPT if second argument is given. Calls hash -r to clear the command-lookup hash-table. Fuzzy matching of Rubies by name. Defaults to the system Ruby. Optionally supports auto-switching and the .ruby-version file. Supports bash and zsh. Small (~100 LOC). Has tests.防功能
Run Code Online (Sandbox Code Playgroud)Does not hook cd. Does not install executable shims. Does not require Rubies be installed into your home directory. Does not automatically switch Rubies by default. Does not require write-access to the Ruby directory in order to install gems.要求
Run Code Online (Sandbox Code Playgroud)bash >= 3 or zsh
小智 14
Macbook M1及更新机型:
打开终端
curl -L https://get.rvm.io | bash -s stable
重新打开终端
rvm install ruby-3.1.1
rvm use ruby-3.1.1
rvm --default use 3.1.1
Run Code Online (Sandbox Code Playgroud)
然后这按预期安装了cocoapods
sudo gem install cocoapods
Run Code Online (Sandbox Code Playgroud)
小智 8
如果您已经安装了 rbenv 并面临此错误,下面的答案将有所帮助(这对我来说是这样的)
问题:
$ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
Run Code Online (Sandbox Code Playgroud)
不要使用须藤
$ rbenv versions
* system (set by /Users/user/.rbenv/version)
2.3.8
Run Code Online (Sandbox Code Playgroud)
在这里,您可以看到,默认情况下它选择了系统。将其更改为您的 ruby 版本。
$ rbenv global 2.3.8
$ rbenv versions
system
* 2.3.8 (set by /Users/user/.rbenv/version)
Run Code Online (Sandbox Code Playgroud)
然后尝试安装捆绑器,它将起作用:
$gem install bundler -v 1.17.3
Fetching: bundler-1.17.3.gem (100%)
Successfully installed bundler-1.17.3
Parsing documentation for bundler-1.17.3
Installing ri documentation for bundler-1.17.3
Done installing documentation for bundler after 5 seconds
1 gem installed
Run Code Online (Sandbox Code Playgroud)
这里提到的“写权限”错误Gem::FilePermissionError是由于 Ruby 环境配置不当造成的。你应该永远不需要使用sudo来安装 gems,无论你在 Stack Overflow 上看到多少次它被接受的答案。原因如下。
概括地说,在 Mac 上设置合适的 Ruby 开发环境涉及六个步骤:
~/.bash_profile通过将适当的行添加到 shell 文件(或)来配置 Ruby 管理器~/.zshrc- 每个管理器都会有执行此操作的说明,这是人们错过的典型步骤我个人偏好是chruby和ruby-install。有关更多详细信息和可以自动化整个过程的脚本,请在此处查看我的答案: https: //stackoverflow.com/a/54873916/928191
小智 5
假设已安装rvm,则可以执行以下操作:
$ rvm install 2.1.1
$ rvm @global do gem install compass
Run Code Online (Sandbox Code Playgroud)
不需要做sudo。
| 归档时间: |
|
| 查看次数: |
65165 次 |
| 最近记录: |