首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >在ruby中安装Mechanize时的一些问题

在ruby中安装Mechanize时的一些问题
EN

Stack Overflow用户
提问于 2012-10-28 10:42:59
回答 1查看 871关注 0票数 1

我在ubuntu 12.04上使用ruby 1.8.7和rubygem 1.8.15

首先,我输入sudo gem install mechanize --no-ri --no-rdoc

它似乎工作得很好。

代码语言:javascript
代码运行次数:0
运行
复制
Building native extensions.  This could take a while...
Fetching: ntlm-http-0.1.1.gem (100%)
WARNING: ntlm-http-0.1.1 has an invalid nil value for @cert_chain
Fetching: webrobots-0.0.13.gem (100%)
Fetching: unf_ext-0.0.5.gem (100%)
Building native extensions.  This could take a while...
Fetching: unf-0.0.5.gem (100%)
Fetching: domain_name-0.5.4.gem (100%)
Fetching: mechanize-2.5.1.gem (100%)
Successfully installed nokogiri-1.5.5
Successfully installed ntlm-http-0.1.1
Successfully installed webrobots-0.0.13
Successfully installed unf_ext-0.0.5
Successfully installed unf-0.0.5
Successfully installed domain_name-0.5.4
Successfully installed mechanize-2.5.1
7 gems installed

然后我写了我的第一个程序

代码语言:javascript
代码运行次数:0
运行
复制
require 'rubygems'
require 'mechanize'

agent = Mechanize.new

它就是不工作

代码语言:javascript
代码运行次数:0
运行
复制
./mechanize.rb uninitialized constant Mechanize (NameError)
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in        gem_original_require'
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from mechanize.rb:2

有人能帮帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2012-10-28 10:54:15

将您的文件重命名为'mechanize-test.rb‘或其他名称,以避免与库混淆。看起来1.8的require表现得很奇怪。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13105954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档