gem 安装权限被拒绝

发布于 2025-01-16 20:02:45 字数 1267 浏览 1 评论 0原文

无论我做什么,flutter doctor 总会返回:

[!] Xcode - develop for iOS and macOS (Xcode 13.3)
• Xcode at /Volumes/ssd/Applications/Xcode.app/Contents/Developer
✗ CocoaPods not installed.
    CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
    Without CocoaPods, plugins will not work on iOS or macOS.
    For more info, see https://flutter.dev/platform-plugins
  To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

当我跑步时,

$ gem install cocoapods

我得到: 错误:执行 gem 时... (Errno::EACCES) 权限被拒绝@ dir_s_mkdir - /Users/omkar/.local/share/gem/specs

我尝试使用

$ sudo chown -R /Users/omkar/.local/share/gem/*

密码:

但我得到: 用法: chown [-fhnvx] [-R [-H | -L | -P]] 所有者[:组] 文件 ... chown [-fhnvx] [-R [-H | ] -L | -P]] :group file ...

并且没有权限的问题仍然存在。

我怎样才能给予所需的许可?

更多信息: 我已按照这个答案安装brew 以下是输出:

$ which ruby 

/usr/local/opt/ruby/bin/ruby

$ ruby -v 

ruby​​ 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin21]

No matter what I do, flutter doctor always returns:

[!] Xcode - develop for iOS and macOS (Xcode 13.3)
• Xcode at /Volumes/ssd/Applications/Xcode.app/Contents/Developer
✗ CocoaPods not installed.
    CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
    Without CocoaPods, plugins will not work on iOS or macOS.
    For more info, see https://flutter.dev/platform-plugins
  To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

when I run

$ gem install cocoapods

I get:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ dir_s_mkdir - /Users/omkar/.local/share/gem/specs

I tried using

$ sudo chown -R /Users/omkar/.local/share/gem/*

Password:

But I got:
usage: chown [-fhnvx] [-R [-H | -L | -P]] owner[:group] file ...
chown [-fhnvx] [-R [-H | -L | -P]] :group file ...

and the issue of no permission still persists.

How can I give the required permission?

More info:
I have followed this answer to install brew
and following is the output:

$ which ruby 

/usr/local/opt/ruby/bin/ruby

$ ruby -v 

ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin21]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

金橙橙 2025-01-23 20:02:45

你尝试过使用

$ sudo gem install cocoapods

Did you try using

$ sudo gem install cocoapods
等风来 2025-01-23 20:02:45

对于仍然遇到此问题的人,这解决了我的问题: https://mac.install.guide/ ruby/13.html

TLDR;

  1. brew 安装 ruby​​

  2. 如果使用zsh,则open -e ~/.zshrc,如果使用bash ,然后open -e ~/.bashrc

  3. 将这些行添加到末尾:
    对于苹果英特尔:

if [ -d "/usr/local/opt/ruby/bin" ]; then
  export PATH=/usr/local/opt/ruby/bin:$PATH
  export PATH=`gem environment gemdir`/bin:$PATH
fi

对于Apple Silicon:

if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
  export PATH=/opt/homebrew/opt/ruby/bin:$PATH
  export PATH=`gem environment gemdir`/bin:$PATH
fi

现在重新打开终端并输入pod,它应该按预期工作。

for anyone still having this problem, this solved my problem: https://mac.install.guide/ruby/13.html

TLDR;

  1. brew install ruby

  2. if using zsh, then open -e ~/.zshrc, if using bash, then open -e ~/.bashrc

  3. add these lines to the end:
    for Apple Intel:

if [ -d "/usr/local/opt/ruby/bin" ]; then
  export PATH=/usr/local/opt/ruby/bin:$PATH
  export PATH=`gem environment gemdir`/bin:$PATH
fi

for Apple Silicon:

if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
  export PATH=/opt/homebrew/opt/ruby/bin:$PATH
  export PATH=`gem environment gemdir`/bin:$PATH
fi

now reopen the terminal and type pod and it should work as expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文