Textmate + RVM + Rake = Rake 不使用预期的 gem 环境 [英] Textmate + RVM + Rake = Rake not using expected gem environment

查看:86
本文介绍了Textmate + RVM + Rake = Rake 不使用预期的 gem 环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用:

TextMate:版本 2.0-alpha.9511

TextMate: version 2.0-alpha.9511

rvm:1.25.15(稳定)

rvm: 1.25.15 (stable)

红宝石:版本 2.1.0p0

ruby: version 2.1.0p0

oh-my-zshell: 5.0.2

oh-my-zshell: 5.0.2

Mac OS X:10.9.1(小牛队)

Mac OS X: 10.9.1 (Mavericks)

我已经设置好可以使用的 rvm 和 textmate

I have rvm and textmate set up to use

TM_RUBY=/Users/<myuser>/.rvm/bin/rvm-auto-ruby

问题:

当我尝试在 textmate 中使用 rake 包运行我的 rake 任务时,我收到一些关于文件未加载的错误:无法加载此类文件 -- rubocop/rake_task"

The problem:

when I try to run my rake tasks using the rake bundle in textmate, I get some errors about the file not loading: "cannot load such file -- rubocop/rake_task"

我更改了我的 rakefile 以便它只报告gem env";对于默认任务.当我然后运行任务时,我看到一个完全不同的 gem 环境,如果我在终端命令行中使用 rake,我会看到.

I changed my rakefile so that it simply reports the "gem env" for the default task. When I then run the task, I see a completely different gem environment, than I would see if I used rake at the terminal command line.

RakeMate v2.0.0
>>> /Users/Johno/Projects/puzzles/triangle/Rakefile

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-13
  - GEM PATHS:
     - /Library/Ruby/Gems/2.0.0
     - /Users/Johno/.gem/ruby/2.0.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

而我在运行时看到这个$ 宝石环境在我的终端中,用于我的项目

Whereas I see this when running $ gem env in my terminal, for my project

  RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0.rc.1
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /Users/Johno/.rvm/gems/ruby-2.1.0@puzzles
- RUBY EXECUTABLE: /Users/Johno/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/Johno/.rvm/gems/ruby-2.1.0@puzzles/bin
- SPEC CACHE DIRECTORY: /Users/Johno/.gem/specs
- RUBYGEMS PLATFORMS:
  - ruby
  - x86_64-darwin-12
- GEM PATHS:
   - /Users/Johno/.rvm/gems/ruby-2.1.0@puzzles
   - /Users/Johno/.rvm/gems/ruby-2.1.0@global
- GEM CONFIGURATION:
   - :update_sources => true
   - :verbose => true
   - :backtrace => false
   - :bulk_threshold => 1000
- REMOTE SOURCES:
   - https://rubygems.org/
- SHELL PATH:
   - /Users/Johno/.rvm/gems/ruby-2.1.0@puzzles/bin
   - /Users/Johno/.rvm/gems/ruby-2.1.0@global/bin
   - /Users/Johno/.rvm/rubies/ruby-2.1.0/bin
   - /Users/Johno/.rvm/bin
   - /usr/local/bin
   - /Users/Johno/Projects/Scripts/Ruby
   - /Users/Johno/Projects/Scripts/bash
   - /Users/Johno/Projects/Scripts/perl
   - /Users/Johno/Projects/Scripts/Geek Tool
   - /usr/bin
   - /bin

我怀疑 textmate 试图使用错误"rake,或未能正确设置环境.

I suspect that textmate is trying to use the "wrong" rake, or failing to set up the environment properly.

我认为问题可能出在 text mate 的 ruby​​ bundle 命令中:

I think the problem may lie in the ruby bundle command from text mate:

#!/usr/bin/env bash

export RUBYLIB="$TM_BUNDLE_SUPPORT/RakeMate${RUBYLIB:+:$RUBYLIB}"
export TM_RAKE=$(which "${TM_RAKE:-rake}")

"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby" -- "$TM_BUNDLE_SUPPORT/RakeMate/rake_mate.rb"

它似乎使用特定的 ruby​​ (1.8) 而不是 rvm 项目特定的 ruby​​

It appears to be using a specific ruby (1.8) rather than the rvm project specific ruby

有人对如何解决这个问题有建议吗?

Does anyone have a suggestion as to how to resolve this?

谢谢,约翰·尚克

按照建议设置 TM_RAKE 并没有帮助.我尝试了建议的设置,并使用了 which rake

Followed the advice to set TM_RAKE and it didn't help. I tried both the suggested setting, and using the results of which rake

/Users/Johno/.rvm/gems/ruby-2.1.0@puzzles/bin/rake

/Users/Johno/.rvm/gems/ruby-2.1.0@puzzles/bin/rake

当使用我的 TM_RAKE 时,得到一个不同的错误

When using my TM_RAKE, is get a different error

RakeMate v2.0.0
>>> /Users/Johno/Projects/puzzles/triangle/Rakefile

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'rake' (>= 0) among 5 total gem(s) (Gem::LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /Users/Johno/.rvm/gems/ruby-2.1.0@puzzles/bin/rake:22:in `<main>'

这恰好与我尝试使用 rubocop.tmbundle 时遇到的错误相同

This happens to be the same error I get when I try to use the rubocop.tmbundle

在我看来,gem 环境仍然没有传递给子进程.

It still looks to me like the gem environment is not being passed to the child process.

推荐答案

我自己解决了问题.以下是遇到此问题的其他人的详细信息...

I solved my own problem. Here are the details for anyone else who has this problem...

首先,这个问题的答案TextMate、rvm 和 TM_RUBY几乎是完美的.

First, the answer in this question TextMate, rvm and TM_RUBY is almost perfect.

我必须创建一个 textmate_ruby 和一个 textmate_rake 脚本,并在 text mate 中的变量中引用它们:TM_RUBY 和 TM_RAKE.

I had to create a textmate_ruby, and a textmate_rake script, and reference them in the variables in text mate: TM_RUBY, and TM_RAKE.

其次,由于我使用的是 zsh,所以我必须将 textmate_xxx 脚本中的 shebang 行更改为使用 zsh.

Second, since I'm using zsh, I had to change the shebang line in the textmate_xxx scripts to use zsh.

最后,帮助我找到正确解决方案的关键是我将项目 rakefile 修改为:

Finally, the key that helped me arrive at the correct solution is that I modified my project rakefile to :

task :default do
  system "gem env"
  system "ruby --version"
  system "pwd"
  system "printenv"
end

然后当我在 textmate 中运行 rake 任务时,它会转储我的环境、ruby 版本、当前目录和 gem 环境的当前值.这确实有助于了解发生了什么.

Then when I ran the rake task in textmate, it would dump the current values of my environment, ruby version, current directory, and gem environment. This really helped to see what was going on.

这篇关于Textmate + RVM + Rake = Rake 不使用预期的 gem 环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆