- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我一直在尝试使用以下方法从终端运行 ruby 文件:
ruby file_cleanse_auto.rb
但是我从 mechanize 得到一个错误:
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mechanize (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from file_cleanse_auto.rb:2:in `<main>'
在我的 ruby 文件中我有:
require 'open-uri'
require 'mechanize'
我能够在 Ruby shell (irb) 中毫无错误地使用 mechanize。当我尝试从命令行运行 ruby 文件时,这似乎只是一个问题。我安装的ruby和mechanize版本分别是2.0.0和2.7.5。我还尝试将 Mechanize 添加到 Gemfile(有和没有 nokogiri)。这是现在的样子:
source "https://rubygems.org"
gem 'nokogiri'
gem 'mechanize'
运行后:
bundle
我得到了:
Resolving dependencies...
Using mini_portile2 2.2.0
Using unf_ext 0.0.7.4
Using mime-types-data 3.2016.0521
Using net-http-digest_auth 1.4.1
Using net-http-persistent 2.9.4
Using ntlm-http 0.1.1
Using webrobots 0.1.2
Using bundler 1.15.1
Using nokogiri 1.8.0
Using unf 0.1.4
Using mime-types 3.1
Using domain_name 0.5.20170404
Using http-cookie 1.0.3
Using mechanize 2.7.5
Bundle complete! 2 Gemfile dependencies, 14 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
但是当我尝试再次运行 ruby 文件时,我仍然遇到同样的错误。有人知道我该如何解决这个错误吗?谢谢!
最佳答案
最近安装 ruby 2.4
后,我遇到了同样的问题。
你应该试试 gem install mechanize
这是因为每个 ruby installation have an independent directory for gems .希望这有效。
关于ruby - Mechanize/ ruby : `require' : cannot load such file -- mechanize (LoadError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44852292/
我确实安装了下面提到的 ruby 东西 当我尝试执行 chef-client 时,我收到下面提到的错误 c:\RubyDevKit>chef-client C:/Ruby193/lib/ruby/
完整堆栈跟踪: /Users/galharth/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencie
我尝试使用 Ruby(在 Windows 下)连接到数据库。为此: 在 C:\Ruby193 安装 Ruby 安装 devkit (c:\ruby193\devkit)。运行“ruby dk.rb i
当我尝试在命令行中包含一个库时,我收到 LoadError 消息 $ ruby -v ruby 1.8.7 (2012-06-29 patchlevel 370) $ gem list | grep
这里的 Ruby 新手试图弄清楚如何使用 Gem,到目前为止,体验并不是很好。 在通过 gem 安装 mysql2 之后,我尝试在一个简单的文件中使用它。 require 'mysql2'#clien
我已经按照 https://github.com/cucumber/cucumber-rails#installation 在新的 Rails 4 应用程序中安装了 Cucumber-rails ge
在我的应用程序中;当我提交表单时,出现此错误: LoadError at /questions Unable to autoload constant Message, expected /app/m
似乎自动加载器正在加载 lib/tools/address 而不是我的模型 地址抛出以下错误 LoadError: Unable to autoload constant Address, expec
我想使用 smarter_csv gem,但是当我在代码中写入 require "smarter_csv" 时,它会给我以下错误消息: /System/Library/Frameworks/Ruby.
我刚开始使用 ruby,但在使用 bundle 时遇到困难。 bundle install 我的错误: /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/c
在这个应用程序上一切正常,现在我在尝试推送到 Heroku 时得到了这个: Counting objects: 28, done. Delta compression using up to 4 th
我是 ruby 新手。我只是安装成功模块 libxml-ruby。当我运行一个需要“xml”的脚本时,它出现错误: C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core
我运行 pod install,但出现错误 LoadError - cannot load such file -- xcodeproj/prebuilt/x86_64-darwin12.5.0-2.
我正在尝试向我的 Xcode 项目添加一个 pod。我收到此错误: LoadError - no such file to load -- xcodeproj/prebuilt/universal-d
这个问题困扰了我几天...每当我使用 .bring_to_front 方法时 require "rubygems" require "watir" browser = Watir::Browser::
例如,当我需要一个文件(称为 st.rb)时: require 'rubygems' require 'mongrel' class TestHandler > require 'st.rb' Loa
我已经在 Ubuntu 上安装了 Julia 1.5.3,但 IJulia falis 带有 LoadError,如屏幕截图所示。 第一个conda环境的路径很不对,这个是在Ubuntu上跑的。 Pr
我在运行以下 Julia 代码片段时遇到错误 using GR, Interact t = 0:0.01:1 @manipulate for phi=0:0.1:6.28 plot(cos.(2
我无法运行 ruby Web 应用程序,并且收到以下消息错误: rackup webapp/config.ru --debug nil Exception `LoadError' at /usr/
我正在尝试按照本教程使用设计创建 token 身份验证: http://www.strukturedkaos.com/2011/09/19/soup-to-nuts-token-authenticat
我是一名优秀的程序员,十分优秀!