Am3*_*33d 4 ruby rubygems ruby-on-rails
任何 Rails 命令对我都不起作用。我通过rvm安装了几个版本的ruby。我尝试安装所有版本的rails,它们确实安装成功,但是每当我在项目目录中运行任何rails命令时,我都会遇到以下错误:
~ rails new blog
Traceback (most recent call last):
1: from bin/rails:3:in `<main>'
bin/rails:3:in `require_relative': cannot load such file -- /Users/Am33d/Documents/config/boot (LoadError)
Run Code Online (Sandbox Code Playgroud)
我尝试查找错误,但没有找到任何解决方案。
可以采取什么措施来解决这个问题?我使用的是 macOS Mojave (10.14.6)
boot.rb此错误表明由于某种原因您的配置目录中没有文件。运行rails命令时——无论您是否将它们运行为bin/rails [command]或bundle exec rails [command],都会运行该bin/rails文件。该文件通常有一行require_relative '../config/boot. bin/rails新的 Rails 6 应用程序中的样板文件是:
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
Run Code Online (Sandbox Code Playgroud)
要简单地解决此问题,您可以通过从应用程序的根目录运行来创建一个空白文件touch config/boot.rb,这本身就会抑制错误。话虽如此,您最好创建一个config/boot.rb包含有用信息的文件。样板config/boot.rb文件是这样的
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
Run Code Online (Sandbox Code Playgroud)
如果没有此文件,您不一定能够从 gemfile 中正确加载 gem,也不一定能够使用 bootsnap 缓存操作。
| 归档时间: |
|
| 查看次数: |
5964 次 |
| 最近记录: |