Compass (ruby) encoding error

北城以北 提交于 2020-02-24 12:37:27

问题


I had Compass 0.12 (a ruby gem) installed on Ubuntu Oneiric with no problems I have updated to Precise formatting / and keeping /home, so I needed to reinstall ruby (1.9.3).

I get this error now when I compile a SCSS file:

compass watch --trace

            Change detected at 12:45:09 to: style.scss overwrite css/style.css

Dear developers making use of FSSM in your projects, FSSM is essentially dead at this point. Further development will be taking place in the new shared guard/listen project. Please let us know if you need help transitioning! ^_^b - Travis Tilley

>>> Compass is polling for changes. Press Ctrl-C to Stop.
ArgumentError on line ["46"] of /usr/lib/ruby/1.9.1/pathname.rb: invalid byte sequence in US-ASCII
  /usr/lib/ruby/1.9.1/pathname.rb:46:in `chop_basename'
  /usr/lib/ruby/1.9.1/pathname.rb:102:in `cleanpath_aggressive'
  /usr/lib/ruby/1.9.1/pathname.rb:90:in `cleanpath'
  /usr/lib/ruby/1.9.1/pathname.rb:452:in `relative_path_from'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/path.rb:82:in `split_path'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/path.rb:70:in `run_callback'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/path.rb:56:in `callback_action'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/path.rb:36:in `update'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/state/directory.rb:39:in `block in modified'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/state/directory.rb:37:in `each'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/state/directory.rb:37:in `modified'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/state/directory.rb:18:in `refresh'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/backends/polling.rb:17:in `block (2 levels) in run'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/backends/polling.rb:17:in `each'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/backends/polling.rb:17:in `block in run'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/backends/polling.rb:15:in `loop'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/backends/polling.rb:15:in `run'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm/monitor.rb:26:in `run'
  /var/lib/gems/1.9.1/gems/fssm-0.2.9/lib/fssm.rb:70:in `monitor'
  /var/lib/gems/1.9.1/gems/compass-0.12.1/lib/compass/commands/watch_project.rb:89:in `perform'
  /var/lib/gems/1.9.1/gems/compass-0.12.1/lib/compass/commands/base.rb:18:in `execute'
  /var/lib/gems/1.9.1/gems/compass-0.12.1/lib/compass/commands/project_base.rb:19:in `execute'
  /var/lib/gems/1.9.1/gems/compass-0.12.1/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
  /var/lib/gems/1.9.1/gems/compass-0.12.1/lib/compass/exec/sub_command_ui.rb:15:in `run!'
  /var/lib/gems/1.9.1/gems/compass-0.12.1/bin/compass:29:in `block in <top (required)>'
  /var/lib/gems/1.9.1/gems/compass-0.12.1/bin/compass:43:in `call'
  /var/lib/gems/1.9.1/gems/compass-0.12.1/bin/compass:43:in `<top (required)>'
  /usr/local/bin/compass:19:in `load'
  /usr/local/bin/compass:19:in `<main>'

(The "Dear developers" message is part of the output).

This error doesn't appear the first time I make a change to the scss file, but the second.

In addition, compass "eats" one "s" in some files and, instead of compiling them as "style.css" (what it should be from the file's name) it does as "tyle.css".

I've spend 3 hours looking at similar problems here but I couldn't solve it. I tried including # encoding: utf-8 on the top of some files with no luck.

Please explain step by step what should I do, since I am a total noob with Ruby (I just use it because of SASS).


回答1:


I think there is some problem with the pathname, maybe it contains an invalid non-ASCII sequence; probably the eaten "s" is the problem, maybe it is an invalid character, or maybe a character near to it; try to ensure path is ASCII.

Or maybe a bug in precise readline package? Try to install ruby 1.9.3 via RVM, RVM should use readline bundled with it (see the comments below for details)




回答2:


From what I can see, the file in question pathname.rb contains this function that seems to be where the trouble is:

def chop_basename(path)
  base = File.basename(path)
  if /\A#{SEPARATOR_PAT}?\z/o =~ base
    return nil
  else
    return path[0, path.rindex(base)], base
  end
end
private :chop_basename

Here's a link to a similar question with the same issue:

Ruby on Rails application won’t start using Passenger when there are non-ASCII characters in the app path

So the fix is clearly to stick with us-ascii pathnames.

Here's a snippet from the doc on that class:

Pathname represents a pathname which locates a file in a filesystem. The pathname depends on OS: Unix, Windows, etc. Pathname library works with pathnames of local OS. However non-Unix pathnames are supported experimentally.

As to why it worked before and doesn't now, that's hard to say. It's possible that some other library on your system changed, or that the upgrade to ruby 1.9.3 caused a minor change that introduced the error.



来源:https://stackoverflow.com/questions/10495908/compass-ruby-encoding-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!