从Xcode shell脚本运行时缺少Ruby gems
我正试图运行一个grunt脚本来编译一些东西,包括来自Xcode的从Xcode shell脚本运行时缺少Ruby gems,ruby,xcode,gruntjs,compass-sass,Ruby,Xcode,Gruntjs,Compass Sass,我正试图运行一个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':在总共14个宝石中找不
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':在总共14个宝石中找不到“compass”(>=0)
(Gem::LoadError)
在脚本顶部加载my 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运行时返回的列表不同。此列表不包含指南针-我想这可能是我收到找不到“指南针”
错误的原因,知道我能做些什么来修复此问题吗
这是我的gem env,由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的结果时,会给我所有的日志消息,它们的格式很差,如果出现错误,它不会停止主脚本的执行
所以理想情况下,我还是希望我的原始问题有一个合适的解决方案,如果有人有任何建议。您是否考虑过添加一个
Gemfile
并运行bundle exec grunt debug
?您的意思是我可以通过budle exec
运行grunt cli
。?您对此有过进一步的了解吗?是的-我们不再使用依赖ruby的任何东西,并使用libsass来构建sass!当build.sh脚本可能包含gulp build
等内容时,作为xcode中脚本构建阶段的一部分,这可以正常工作:source~/.bash\u profile&&sh scripts/build.sh
。