gpt4 book ai didi

ruby-on-rails - "uninitialized constant Sass::Script (NameError)"

转载 作者:行者123 更新时间:2023-12-04 00:07:29 30 4
gpt4 key购买 nike

我必须首先更改我的 Gemfile(我删除了评论以缩短文本):

source 'https://rubygems.org'

gem 'rails', '4.2.0'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc


group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end

到:
source 'https://rubygems.org'


gem 'rails', '4.2.0'
gem 'sass-rails', '5.0.1'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc

group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end

现在,当我尝试使用 rails server -b $IP -p $PORT 运行 rails 服务器时我收到以下错误消息:
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/sass-rails-5.0.1/lib/sass/rails/helpers.rb:11:in `<top (required)>': uninitialized constant Sass::Script (NameError)
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/sass-rails-5.0.1/lib/sass/rails.rb:8:in `require'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/sass-rails-5.0.1/lib/sass/rails.rb:8:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/sass-rails-5.0.1/lib/sass-rails.rb:1:in `require'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/sass-rails-5.0.1/lib/sass-rails.rb:1:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in `require'
from /usr/local/rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /usr/local/rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in `each'
from /usr/local/rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib/bundler/runtime.rb:72:in `block in require'
from /usr/local/rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in `each'
from /usr/local/rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib/bundler/runtime.rb:61:in `require'
from /usr/local/rvm/gems/ruby-2.1.5@global/gems/bundler-1.7.6/lib/bundler.rb:133:in `require'
from /home/ubuntu/workspace/hello_app/config/application.rb:7:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from /home/ubuntu/workspace/hello_app/bin/rails:8:in `require'
from /home/ubuntu/workspace/hello_app/bin/rails:8:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/ubuntu/workspace/hello_app/bin/spring:13:in `require'
from /home/ubuntu/workspace/hello_app/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'

我在更改 Gemfile 之前尝试运行服务器,并且它有效,所以一定是因为新的更改。我也知道它说的错误 ruby-2.1.5 , 在我的 Gemfile 中我放了 4.2.0 但我不知道如何改变它,或者这是否是问题所在?我试图添加 ruby '2.1.5'在源代码行下,没有任何变化。我也改了 'rails', '4.2.0'到 2.1.5 但更新失败告诉我 Could not find gem 'rails (= 2.1.5) ruby' in the gems available on this machine.

最佳答案

正如这里所说:

https://github.com/josh/sprockets-es6/issues/15

使用 sass-rails v 5.0.2+ .这应该可以解决您的问题。所以在gem文件中更改:

gem 'sass-rails', '5.0.3'

或者
gem 'sass-rails', '5.0.2'

更新:

由于链接现已关闭,因此此问题实际上与 gem 版本有关 5.0.1所以只需运行:
bundle update sass-rails

最终更新您 saas-rails gem 到最新的。或者您可以在您的 gemfile 中输入上面指定的版本。

关于ruby-on-rails - "uninitialized constant Sass::Script (NameError)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29716284/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com