IRB에서 다음 루비 코드를 실행하려고하지만 gem gem이 필요하지 않습니다. 루비Rubygems 경로 질문
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/johnnygoodman/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://rubygems.org/
- http://gems.github.com
: 그리고
>> Gem.path
=> ["/Users/johnnygoodman/.gem/ruby/1.8", "/Library/Ruby/Gems/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8"]
환경 출력 : 여기
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ irb
>> require 'rubygems'
=> false
>> require 'gmail'
NameError: uninitialized constant Gmail
from ./gmail.rb:6
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from (irb):2
가 Gem.path 출력이다
,174
require 'rubygems'
require 'gmail'
gmail = Gmail.new("user", "pass")
여기에 IRB 출력의
Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ which ruby
/usr/bin/ruby
그리고 .gemrc :
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ cat .gemrc
---
:sources:
- http://rubygems.org/
- http://gems.github.com
:backtrace: false
:benchmark: false
:verbose: true
:update_sources: true
:bulk_threshold: 1000
여기 내 gemlist입니다 :
내가 맥 포트를 제거하고 신선한 루비를 설치하는 hivelogic instructions을 사용했습니다Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ gem list
*** LOCAL GEMS ***
actionmailer (2.3.8, 2.3.5, 2.2.2, 1.3.6)
actionpack (2.3.8, 2.3.5, 2.2.2, 1.13.6)
actionwebservice (1.2.6)
activerecord (2.3.8, 2.3.5, 2.2.2, 1.15.6)
activeresource (2.3.8, 2.3.5, 2.2.2)
activesupport (2.3.8, 2.3.5, 2.2.2, 1.4.4)
acts_as_ferret (0.4.4, 0.4.3)
Ascii85 (1.0.0)
autotest (4.2.10, 4.2.9)
autotest-fsevent (0.2.2, 0.1.1)
autotest-growl (0.2.4, 0.2.0)
autotest-rails (4.1.0)
bigdecimal-segfault-fix (1.0.1)
capistrano (2.5.18, 2.5.11, 2.5.2)
cgi_multipart_eof_fix (2.5.0)
cheat (1.2.1)
chronic (0.2.3)
configuration (1.1.0)
daemons (1.0.10)
dnssd (1.3.1, 0.6.0)
fastthread (1.0.7, 1.0.1)
fcgi (0.8.8, 0.8.7)
ferret (0.11.6)
gem_plugin (0.2.3)
gemcutter (0.5.0, 0.4.1)
heroku (1.9.9, 1.8.5)
highline (1.5.2, 1.5.1, 1.5.0)
hoe (2.6.0, 2.5.0)
hpricot (0.8.2, 0.6.164)
json_pure (1.4.3, 1.2.3, 1.2.2)
launchy (0.3.5)
libxml-ruby (1.1.4, 1.1.3, 1.1.2)
mail (2.2.1)
mechanize (1.0.0, 0.9.3)
mime-types (1.16)
mongrel (1.1.5)
mysql (2.8.1)
needle (1.3.0)
net-scp (1.0.2, 1.0.1)
net-sftp (2.0.4, 2.0.1, 1.1.1)
net-ssh (2.0.22, 2.0.21, 2.0.17, 2.0.4, 1.1.4)
net-ssh-gateway (1.0.1, 1.0.0)
nokogiri (1.4.2, 1.4.1)
passenger (2.2.11, 2.2.9)
pdf-reader (0.8.5, 0.8.4, 0.8.3)
polyglot (0.3.1)
pony (1.0, 0.9, 0.6)
rack (1.1.0, 1.0.1)
rails (2.3.8, 2.3.5, 2.2.2, 1.2.6)
rake (0.8.7, 0.8.3)
RedCloth (4.2.3, 4.1.1)
rest-client (1.4.2, 1.3.1)
rspec (1.3.0)
rspec-rails (1.3.2)
ruby-gmail (0.2.1, 0.0.8)
ruby-openid (2.1.7, 2.1.2)
ruby-yadis (0.3.4)
rubyforge (2.0.4)
rubygems-update (1.3.7, 1.3.6, 1.3.5, 1.3.1)
rubynode (0.1.5)
scrapi (1.2.0)
shared-mime-info (0.1)
sqlite3-ruby (1.2.5, 1.2.4)
sys-uname (0.8.4)
termios (0.9.4)
tidy (1.1.2)
tmail (1.2.7.1)
treetop (1.4.5)
xmpp4r (0.5, 0.4)
ZenTest (4.3.1)
이/버전 레일은. 나는이 문제라고 생각하지만, 항상/usr/지방에로드 루비 경로를 강제로 읽을 것을 확실하지 않다
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ . ~/.profile
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ which ruby
/usr/local/bin/ruby
을 : 그러나, 나는 실행할 때까지 내있는 루비 hivelogic의 지침과 일치하지 않음을 알/bin/ruby. 나는 또한 단순히 부분이 어떻게 맞는지 모르기 때문에 붉은 청어가 될 수 있습니다. sudo gem 설치가 작동하지 않으면 기본적으로 잃어 버리게됩니다.
Johnny-Goodmans-MacBook-Pro:~ johnnygoodman$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'mechanize'
=> true
질문 :
참고 다른 보석 일을
때 sudo는 보석 뒤를 쫓고의 다음 단계에 무엇을, 당신은 클래스에서 개체를 만들 수 없습니다 설치 문제 제기?
이러한 종류의 문제를 해결하는 데 보석의 각 부분이 어떻게 적용 되는가? FAQ 및 문서 (http://docs.rubygems.org/read/book/3)를 읽었지만 놓쳤거나 관련 부분을 선택할 수 없습니다.
난에 가야 노력하고있어 보석을 내 보석 목록은 ruby-gmail (0.2.1, 0.0.8)입니다. gem docs http://github.com/dcparker/ruby-gmail의 예제 코드 섹션을 따랐습니다. 가 'Gmail은' 의 Gmail = Gmail.new (사용자 이름, 암호) # ... 할 일 ... gmail.logout을 필요로 내가 바라고있어 그 결과가 있습니다 : 여기 gmail.rb입니다 내 사용자와 암호를 정의하지 않는 것에 대한 오류가 있지만 나를 파는 대신 상수를 초기화 할 수 없습니다. 위의 게시물을 기반으로, 필자는 'gmail'이 gem을 로컬 디렉토리에서 호출하고 있다고 가정합니다. 보석 및 오류가 필요하지 않은 것과 관련이 없습니다. – johnnygoodman
나는 irb 세션을 실행 한 dir의 로컬 gmail.rb 파일없이 동일한 작업을 시도하기 위해 우분투 리눅스로 뒤집었다. 조니 @의 조니 - 노트북 : ~ $의 IRB IRB (주) : 001 : 0> '젬' => 진정한 IRB (주)가 필요합니다 : 002 : 0> '루비 Gmail이' LoadError이 필요합니다 그런를 'gem_original_require '/usr/local/lib/site_ruby/1.8/rubygems/에서 \t /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in에서 루비 Gmail이 \t를 -로드하는 파일 custom_require.rb : 31 :'require '에 \t from (irb) : 2 임의의 디렉토리에서 irb를 실행하는 Mac에서 동일한 결과를 얻습니다. 'Gmail'이 Gmail 클래스에 대한 액세스 권한을 부여해야합니까? – johnnygoodman
@ johnnygoodman 혹시 이것에 대한 해결책을 찾았습니까? – keypulsations