gpt4 book ai didi

从 Xcode shell 脚本运行时缺少 Ruby gems

转载 作者:数据小太阳 更新时间:2023-10-29 08:04:23 27 4
gpt4 key购买 nike

我正在尝试运行一个 grunt 脚本来编译一堆东西,包括来自 Xcode 的 grunt-contrib-compass。在 Xcode 外部运行 grunt debug 运行良好,但在 Xcode 中作为构建阶段的一部分作为 shell 脚本调用时则不然。

运行 grunt debug 我收到:

/Users/MY_USER/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'compass' (>= 0) among 14 total gem(s) (Gem::LoadError)

在脚本顶部加载我的 PATH 变量:

PATH=$(bash -l -c 'echo $PATH')

Xcode 似乎加载了正确版本的 ruby​​ 和 gem:

which ruby     ->  /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin/ruby
which compass -> /Users/MY_USER/.rvm/gems/ruby-2.1.0/bin/compass
which gem -> /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin/gem

这些与 bash 报告的相同。

但是,gem query --local 在 Xcode 中执行时返回的列表与从 bash 中运行时返回的列表不同。此列表不包含 compass - 我想这可能就是我收到 Could not find 'compass' 错误的原因,知道我可以做些什么来解决这个问题吗?

这是我的 gem 环境,由 Xcode 执行的 shell 脚本报告:

RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /Users/MY_USER/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin
- SPEC CACHE DIRECTORY: /Users/MY_USER/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/MY_USER/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0
- /Users/MY_USER/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/MY_USER/.rvm/gems/ruby-2.1.0/bin
- /Users/MY_USER/.rvm/gems/ruby-2.1.0@global/bin
- /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin
- /opt/local/bin
- /opt/local/sbin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/bin
- /usr/local/git/bin
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin
- /Applications/Xcode.app/Contents/Developer/usr/bin
- /Applications/Xcode.app/Contents/Developer/usr/local/bin
- /Applications/Xcode.app/Contents/Developer/Tools
- /Users/MY_USER/bin
- /Users/MY_USER/Development/adt-bundle/sdk/platform-tools
- /Users/MY_USER/Development/adt-bundle/sdk/tools
- /Users/MY_USER/.rvm/bin

最佳答案

所以我最终作弊了 -

echo $(bash -l -c  "source ~/.bashrc && cd $myProjectLocation && grunt debug")

在一个新的 bash 实例中运行 grunt 命令,它不继承 Xcode 的环境变量,与 Xcode 之外的 bash 相同。

虽然它并不完美 - 虽然回显 bash 的结果给我所有的日志消息,但它们的格式很糟糕,如果出现错误它不会停止主脚本的执行。

所以理想情况下,如果有人有任何建议,我仍然希望对我的原始问题有一个适当的解决方案。

关于从 Xcode shell 脚本运行时缺少 Ruby gems,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21702472/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com