C:\Users\wipe\Quora-Personal-Analytics>ruby hello.rb
hello
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original
_require': no such file to load -- bundler/setup (LoadError)
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require'
from hello.rb:4
C:\Users\wipe\Quora-Personal-Analytics>ruby require 'date'
ruby: No such file or directory -- require (LoadError)
C:\Users\wipe\Quora-Personal-Analytics>ruby require 'rubygems'
ruby: No such file or directory -- require (LoadError)
C:\Users\wipe\Quora-Personal-Analytics>
===
我正在使用Ruby 1.8.7。此外,这在以前工作(在同一台计算机上)。
当我从交互式ruby中尝试时,所有做的require语句都有效。所有这些都已安装完毕。但我需要命令行。
==
编辑:以下是Hello.rb的内容
puts "hello"
require 'rubygems'
require 'bundler/setup'
require 'date'
require 'watir'
require 'optparse'
还有一些新错误:
C:\Users\wipe\Quora-Personal-Analytics>ruby require 'rubygems'
ruby: No such file or directory -- require (LoadError)
C:\Users\wipe\Quora-Personal-Analytics>ruby hello.rb
hello
←[31mCould not find OptionParser-0.5.1 in any of the sources←[0m
←[33mRun `bundle install` to install missing gems.←[0m
C:\Users\wipe\Quora-Personal-Analytics>ruby bundle install
ruby: No such file or directory -- bundle (LoadError)
C:\Users\wipe\Quora-Personal-Analytics>ruby -e "require 'date'"
C:\Users\wipe\Quora-Personal-Analytics>ruby -e "require 'rubygems'"
C:\Users\wipe\Quora-Personal-Analytics>ruby QuoraStats.rb "firstname-lastname"
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original
_require': no such file to load -- httparty (LoadError)
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require'
from ./lib/Content.rb:1
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`gem_original_require'
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require'
from QuoraStats.rb:10
不知何故,ruby bundle install不能很好地运行:
C:\Users\wipe\Quora-Personal-Analytics>ruby bundle install
ruby: No such file or directory -- bundle (LoadError)
答案 0 :(得分:4)
看起来您没有安装捆绑包。尝试运行gem install bundler
,然后重新运行ruby hello.rb
。
此外,您输入的最后两个命令将无效。 ruby require 'date'
将尝试运行文件“require”并将参数'date'
传递给它,而不是执行require 'date'
。要只执行一行ruby,请使用-e
标志,如下所示:
ruby -e "require 'date'"
答案 1 :(得分:1)
您的堆栈跟踪说
`gem_original _require':没有要加载的文件 - bundler / setup(LoadError)
您确定实际安装了捆绑包吗?如果没有,请尝试
gem install bundler
并重试。
编辑:
根据您收到的新错误,只需尝试运行
即可`bundle install`
然后再试一次。