Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with relative_path - different prefix #179

Closed
ArmorDarks opened this issue Jul 5, 2013 · 1 comment
Closed

Issue with relative_path - different prefix #179

ArmorDarks opened this issue Jul 5, 2013 · 1 comment

Comments

@ArmorDarks
Copy link

Hi

I'm getting following error when trying to run Sass compiling command with --sourcemap:

C:/Ruby200-x64/lib/ruby/2.0.0/pathname.rb:500:in `relative_path_from': different prefix: "C:/" and "C:\\Users/Username/Desktop/sass" (ArgumentError)
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/source/map.rb:125:in `block in to_json'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/source/map.rb:120:in `each'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/source/map.rb:120:in `to_json'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/plugin/compiler.rb:318:in `update_stylesheet'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/plugin/compiler.rb:182:in `block in update_stylesheets'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/plugin/compiler.rb:179:in `each'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/plugin/compiler.rb:179:in `update_stylesheets'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/plugin.rb:81:in `update_stylesheets'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/exec.rb:462:in `watch_or_update'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/exec.rb:324:in `process_result'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/exec.rb:41:in `parse'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/lib/sass/exec.rb:21:in `parse!'
    from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.3.0.alpha.198/bin/sass:9:in `<top (required)>'
    from C:/Ruby200-x64/bin/sass:23:in `load'
    from C:/Ruby200-x64/bin/sass:23:in `<main>'
[Finished in 0.2s with exit code 1]

Unfortunately, I can't understand - is it bug in my PC enviroment, or ruby\sass issue?

I've tried that solutions
http://stackoverflow.com/a/2916503

but, as expected, it didn't worked.

example of command which outputs error:

sass --watch --sourcemap C:\sass\app.scss:C:\sass\test.css --trace --stop-on-error --no-cache

I'd be thankful for any help

@luislavena
Copy link
Member

Hello,

I don't believe this falls into the responsability of RubyInstaller, as this is caused by your usage of paths and how Pathname class interprets them.

As Issue #39 mentions, this issue tracker is to report issues with RubyInstaller and the provided components, but not 3rd party scripts (sass) or language issues like Pathname behavior.

The issue here, as I mentioned, are the paths given to Pathname class to interpret. It is important to note that C:\sass\app.scss is not the same as C:/sass/app.scss and Pathname is having problems with these non-normalized paths.

To reproduce this issue, you can try creating a t.rb script and paste in it:

require "pathname"
require "pp"

a = Pathname.new 'C:\sass\app.scss'
b = Pathname.new 'C:/sass/app.scss'

pp a
pp b

pp a.relative_path_from(b)

What you obtain from running it will be this:

C:\Users\Luis\Desktop>ruby t.rb
#<Pathname:C:\sass\app.scss>
#<Pathname:C:/sass/app.scss>
C:/Ruby200/lib/ruby/2.0.0/pathname.rb:500:in `relative_path_from': different prefix: "C:\\" and "C:/sass/app.scss" (ArgumentError)
        from t.rb:10:in `<main>'

The same error you're reporting.

Now, if I changed the first path (C:\sass\app.scss) to use different slashes instead: C:/sass/app.scss, then the script will work.

Since you're giving to sass a Windows-style path, I suggest you give it instead a path that is compatible with Pathname:

sass --watch --sourcemap C:/sass/app.scss:C:/sass/test.css --trace --stop-on-error --no-cache

That should work.

I recommend you report this to Sass developers, so the paths given from the command line are normalized prior be given to Ruby's Pathname class.

Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants