【问题标题】:Cannot Load Such File - Active Support无法加载此类文件 - 主动支持
【发布时间】:2016-07-13 13:32:12
【问题描述】:

我正在尝试启动 Rails 服务器,但出现错误:

/Users/<username>/RubyWorkspace/<appname>/vendor/bundle/gems/railties-5.0.0/lib/rails/commands/rake_proxy.rb:2:in `require': cannot load such file -- active_support (LoadError)

当我转到 /vendor/bundle 并列出 gem 时,我没有看到积极的支持:

actioncable-5.0.0       minitest-5.9.0
actionmailer-5.0.0      multi_json-1.12.1
actionpack-5.0.0        nio4r-1.2.1
actionview-5.0.0        pkg-config-1.1.7
activejob-5.0.0         rack-2.0.1
activemodel-5.0.0       rack-test-0.6.3
activerecord-5.0.0      rails-5.0.0
arel-7.0.0              rails-dom-testing-2.0.1
builder-3.2.2           rails-html-sanitizer-1.0.3
byebug-9.0.0            railties-5.0.0
byebug-9.0.5            rake-11.2.2
coffee-rails-4.2.1      rb-fsevent-0.9.7
coffee-script-2.4.1     rb-inotify-0.9.7
coffee-script-source-1.10.0 sass-3.4.22
concurrent-ruby-1.0.2       sass-rails-5.0.5
debug_inspector-0.0.2       spring-1.7.1
erubis-2.7.0            spring-1.7.2
execjs-2.7.0            spring-watcher-listen-2.0.0
ffi-1.9.14              sprockets-3.6.3
globalid-0.3.6          sprockets-rails-3.1.1
i18n-0.7.0              thor-0.19.1
jbuilder-2.4.1          thread_safe-0.3.5
jbuilder-2.5.0          tilt-2.0.5
jquery-rails-4.1.1      turbolinks-5.0.0
listen-3.0.8            turbolinks-source-5.0.0
loofah-2.0.3            tzinfo-1.2.2
mail-2.6.4              uglifier-3.0.0
method_source-0.8.2     web-console-3.1.1
mime-types-3.1          web-console-3.3.1
mime-types-data-3.2016.0521 websocket-driver-0.6.4
mini_portile2-2.1.0     websocket-extensions-0.1.2

但是当我运行 bundle update 时,bundler 说它正在使用主动支持:

Using rake 11.2.2
....
Using activesupport 5.0.0
....
Bundle updated!
Gems in the group production were not installed.

我认为可能导致错误但我不确定的一件事是,当我在 gem 路径下运行 gem env 时,它显示:

- GEM PATHS:
 - /Users/<username>/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0
 - /Users/<username>/.gem/ruby/2.3.0

我是否需要修复 gem 路径,是否需要在不同的目录中重新安装活动支持,还是完全不同?

【问题讨论】:

  • 您是否使用捆绑程序运行服务器,即bundle exec rails s
  • 我不是,但我试过了,同样的错误出现了
  • 如果是 rails 项目,必须有 Gemfile 并且你应该运行 bundle install 来安装所有的 gem。你做到了吗?
  • 是的,我最近这样做了

标签: ruby-on-rails ruby terminal activesupport


【解决方案1】:

注意:相同的错误不同的堆栈。我正在使用Sinatra 并遇到了这个问题。地点:

  1. gem list 显示已安装 activesupport(例如 Using activesupport 5.0.2)。
  2. 我的bundle exec rackup 仍然失败,LoadError: cannot load such file -- active_support/all
  3. 使用通过rbenv 安装的Ruby 2.3.0

修复:故障排除让我意识到我会运行 sudo bundle install 而不是 bundle install。因此,activesupport 是为 root 用户而不是我的用户安装的。然后我跑了:

  1. 使用gem uninstall activesupport 卸载了gem(提示为yes)
  2. 重新安装到正确的用户bundle install
  3. bundle exec rackup成功启动我的应用

TLDR:文件权限问题。 Gem 安装在 root 上,并试图以 non-root 的身份访问。 gem uninstall all > yes ~50k 次 > bundle install > 应用程序启动没有问题。

【讨论】:

    猜你喜欢
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 2016-11-20
    • 2023-03-10
    • 2015-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多