`require': 无法加载这样的文件 -- oj (LoadError)
`require': cannot load such file -- oj (LoadError)
我只知道 Ruby 的基础知识并正在尝试修复此错误。已经有相同的问题,但无法从中解决。
当我 运行 在我的 Ruby 项目中执行命令时
rerun 'ruby app.rb'
我收到以下错误。
[rerun] Webhook-receiver launched
/Users/myhome/.rbenv/versions/2.4.2/lib/ruby/2.4.0/
rubygems/core_ext/kernel_require.rb:55:
in `require': cannot load such file -- oj (LoadError)
from /Users/myhome/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/
core_ext/kernel_require.rb:55:
in `require' from app.rb:2:in `<main>'
[rerun] Webhook-receiver Launch Failed
[rerun] Watching . for **/*.{rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md,feature}
我该如何解决这个问题?
只是想为其他人提供一个详细和结构化的答案,因为你已经解决了这个问题。在开发Ruby应用程序时,如果需要驻留在外部gem中的代码,您可以使用Bundler to keep track and manage your dependencies. It uses a file called Gemfile注册您的项目所依赖的依赖项,以及来源这些依赖项将被拉到您的机器上。 Gemfile 的基本语法示例。
# Registering the sources of gem packages
source 'https://rubygems.org'
[...]
# Requiring a gem for this project
gem 'package_1' # registers a dependency
gem 'package_2', '>=2.0.0' # registers a dependency, with minimum version required
gem 'package_3', '>= 1.5.0', '< 1.9.0' # registers a dependency, with minimum and maximum version required
[...]
完成所有这些设置后,当您 运行 bundle install, the dependencies that are specified in your gemfile are pulled to your machine and you can run the program. If you want to check more information for a gem on your machine, you can run bundle info package(下面是 mysql gem 的示例)
* mysql (2.9.1)
Summary: This is the MySQL API module for Ruby
Homepage: http://github.com/luislavena/mysql-gem
Path: /var/lib/gems/2.3.0/gems/mysql-2.9.1
我只知道 Ruby 的基础知识并正在尝试修复此错误。已经有相同的问题,但无法从中解决。
当我 运行 在我的 Ruby 项目中执行命令时
rerun 'ruby app.rb'
我收到以下错误。
[rerun] Webhook-receiver launched
/Users/myhome/.rbenv/versions/2.4.2/lib/ruby/2.4.0/
rubygems/core_ext/kernel_require.rb:55:
in `require': cannot load such file -- oj (LoadError)
from /Users/myhome/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/
core_ext/kernel_require.rb:55:
in `require' from app.rb:2:in `<main>'
[rerun] Webhook-receiver Launch Failed
[rerun] Watching . for **/*.{rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md,feature}
我该如何解决这个问题?
只是想为其他人提供一个详细和结构化的答案,因为你已经解决了这个问题。在开发Ruby应用程序时,如果需要驻留在外部gem中的代码,您可以使用Bundler to keep track and manage your dependencies. It uses a file called Gemfile注册您的项目所依赖的依赖项,以及来源这些依赖项将被拉到您的机器上。 Gemfile 的基本语法示例。
# Registering the sources of gem packages
source 'https://rubygems.org'
[...]
# Requiring a gem for this project
gem 'package_1' # registers a dependency
gem 'package_2', '>=2.0.0' # registers a dependency, with minimum version required
gem 'package_3', '>= 1.5.0', '< 1.9.0' # registers a dependency, with minimum and maximum version required
[...]
完成所有这些设置后,当您 运行 bundle install, the dependencies that are specified in your gemfile are pulled to your machine and you can run the program. If you want to check more information for a gem on your machine, you can run bundle info package(下面是 mysql gem 的示例)
* mysql (2.9.1)
Summary: This is the MySQL API module for Ruby
Homepage: http://github.com/luislavena/mysql-gem
Path: /var/lib/gems/2.3.0/gems/mysql-2.9.1