未初始化的常量链轮::引擎(NameError) [英] uninitialized constant Sprockets::Engines (NameError)

查看:62
本文介绍了未初始化的常量链轮::引擎(NameError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Ubuntu 18.04、Ruby 2.6.3 和 Rails 6.我正在开发一个新的 rails 项目,当我启动服务器时,出现以下错误:

I'm using Ubuntu 18.04, Ruby 2.6.3, and Rails 6. I'm working on a new rails project, and when i start the server, i have the following error :

> rails s

=> Booting Puma
=> Rails 6.0.2.1 application starting in development 
=> Run `rails server --help` for more startup options
Exiting
Traceback (most recent call last):
    [...]
    72: from ./bin/rails:3:in `<main>'
    71: from ./bin/rails:3:in `load'
    70: from /home/franck/code/BTC1M/app-test/bin/spring:15:in `<top (required)>'
    69: from /home/franck/.rbenv/versions/2.6.3/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    68: from /home/franck/.rbenv/versions/2.6.3/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    67: from /home/franck/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
    66: from /home/franck/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
[...]
5: from /home/franck/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.2.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
4: from /home/franck/.rvm/gems/ruby-2.6.3/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:17:in `block in <class:Railtie>'
3: from /home/franck/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `load_missing_constant'
2: from /home/franck/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `rescue in load_missing_constant'
1: from /home/franck/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
/home/franck/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `block in load_missing_constant': uninitialized constant Sprockets::Engines (NameError)

我尝试卸载并重新安装 rails 和 ruby​​(通过这些步骤):

I tried to uninstall and re-install rails and ruby (through those steps) :

rvm implode
rm -rf ~/.rvm
rm -rf ~/.rbenv
sudo apt install -y build-essential tklib zlib1g-dev libssl-dev libffi-dev libxml2 libxml2-dev libxslt1-dev libreadline-dev
sudo apt clean
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.6.3
rbenv global 2.6.3
gem install rails

我也尝试了 spring stop,并更新链轮和链轮导轨:gem update(我的链轮导轨版本是 3.2.1),并更新链轮-Gemfile.lock 中的 rails 版本:sprockets-rails (3.2.1).我的链轮版本是 4.0.0.

I also tried spring stop, and updating sprockets and sprockets-rails : gem update (my sprockets-rails version is 3.2.1), and updating the sprockets-rails version in Gemfile.lock : sprockets-rails (3.2.1). My sprockets version is 4.0.0.

我还在我的 gemfile + bundle install 中添加了 gem 'sprockets', git: 'git://github.com/rails/sprockets'(原来如此在此线程上告知:https://github.com/rails/sass-rails/issues/48 ) 但它不能解决我的问题.

I also added gem 'sprockets', git: 'git://github.com/rails/sprockets' in my gemfile + bundle install (as it was told on this thread : https://github.com/rails/sass-rails/issues/48 ) but it doesn't fix my issue.

我仍然有同样的错误.我不明白发生了什么.有什么想法吗?

I still have the same error. I don't understand what is going on. Any idea ?

顺便说一句,为什么我有一个/home/franck/.rvm 文件夹(我之前删除的),因为我没有使用 RVM 而是 RBENV ?

By the way, why do i have a /home/franck/.rvm folder (that i deleted before) as i'm not using RVM but RBENV ?

github 存储库在这里:https://github.com/BTC1M/app-test

The github repo is here : https://github.com/BTC1M/app-test

推荐答案

尝试一一删除那些可能与 rails > 不兼容的旧依赖项5,然后再次打包:

Try removing one by one those old dependencies that might not be compatible with rails > 5, and bundle again:

  • gem 'less-rails-bootstrap' 开始,它最后一次提交是在 5 年前,并且在您的错误堆栈中被引用.
  • Start with gem 'less-rails-bootstrap' which last commit is 5 years ago, and which is referenced in your error stack.

还要看看那些其他的依赖:

Also look at those other dependencies:

  • gem 'jquery-easing-rails' 最后一次提交是 5 年
  • gem "font-awesome-rails" 最后一次提交 3 哟
  • gem 'jquery-easing-rails' last commit is 5 yo
  • gem "font-awesome-rails" last commit 3 yo

另请注意,bootstrap-sassfont-awesome-rails 不支持这些库的最新版本,并且可能需要一些黑客才能在 Rails 6 上工作,你最好将这些库与 webpack 一起使用,这是新标准(Sprocket 不再默认处理 JS,一切都发生在 app/javascript 中,由 编译>webpack).

Also note that bootstrap-sass and font-awesome-rails doesn't support latest versions of those libraries, and might need some hacking to work on Rails 6, you'd better use those librairies with webpack which is the new standard (Sprocket does not handle JS by default anymore, everything happens in app/javascript which is compiled by webpack).

而且,您可能不再需要 therubyracer(上次提交 3 年了,还有很多最近的问题).

And, you might not need therubyracer anymore (last commit 3 yo and a lot of recent issues).

这篇关于未初始化的常量链轮::引擎(NameError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆