badsyntax / SassBeautify

[not maintained] A Sublime Text plugin that beautifies Sass files.
https://github.com/badsyntax/SassBeautify
MIT License
143 stars 13 forks source link

ERROR: invalid option: --indent #13

Closed edwardsdesign closed 11 years ago

edwardsdesign commented 11 years ago

Hello,

When ever I try to run SassBeautify in ST2 or ST3 I receive the following error:

There was an error beautifying your Sass: OptionParser::InvalidOption: invalid option: --indent

Ay help would be greatly appreciated.

badsyntax commented 11 years ago

Please let me know what version of sass and sass-convert you're using.

badsyntax commented 11 years ago

Can you also run this from the cli and let me know the output?

sass-convert --indent 4  --to scss --stdin <<< ".test{color:red}"
edwardsdesign commented 11 years ago

Sure, I am using sass version 3.2.10.

The output for test is:

.test {
    color: red;
}
badsyntax commented 11 years ago

That doesn't make sense to me. This plugin is simply a wrapper around sass-convert. If you can run sass-convert from the CLI you should be able to run it from this plugin.

Thanks.

edwardsdesign commented 11 years ago
  1. What OS version are you on?
    • OSX Mountain Lion 10.8.4
  2. Have you tried uninstalling and re-installing?
    • Yes
  3. Can you let me know what plugin version you're using? (Package Controll >> List packages)
    • 2013.08.12.20.57.29
  4. Do you have custom plugin settings? If so paste them here.
    • I do not have any custom plugin settings. My User/SassBeautify.sublime-settings file is empty
badsyntax commented 11 years ago

I'm almost out of ideas on this one. Do you get this error for every file you try to beautify?

Can you please try the following:

Before beautifying, can you open up the Sublime Text console: View >> Show Console Then try beautifying, then copy and paste the debug text here.

Thanks.

edwardsdesign commented 11 years ago

(1) Do you get this error for every file you try to beautify?

Yes, and I have tried both scss and sass files.

(2) Console Log:

error: There was an error beautifying your Sass: OptionParser::InvalidOption: invalid option: --indent Use --trace for backtrace.

badsyntax commented 11 years ago

Ok, we're going to have to break it down.

Can you paste this into the console in sublime text and let me know the output?

import os;import subprocess;process=subprocess.Popen(['sass-convert','--unix-newlines','--stdin','--indent', '4','--to', 'scss'],env=os.environ.copy(),stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE);output,err=process.communicate(input=".test{color:red}".encode('utf-8'));output=output.decode('utf-8');err=err.decode('utf-8');print(output);print(err);
edwardsdesign commented 11 years ago

The console output from your string was: OptionParser::InvalidOption: invalid option: --indent Use --trace for backtrace.

If I remove --indent 4 from your string I receive this out put:

.test {
  color: red; }

This got me thinking and so I tried to run sass-convert --indent file.scss --to scss from the terminal and I received the same error. I then ran sass-convert --indent 4 file.scss --to scss and I had success, the console gave me to correct output with formatting. Could there be an issue with sass-convert not recognizing the indentation parameter?

I hope this helps. Thank you for taking the time to look into this.

badsyntax commented 11 years ago

Man this is really weird, I just can't replicate what you're seeing. It's quite frustrating. Thanks for holding out with me.

At this stage, we only know this much:

  1. sass-convert works as expected from the terminal
  2. sass-convert does not work as expected when run from Sublime Text.
  3. The output that you get, when running sass-convert without --indent from sublime text, is not the default output for sass-convert. (The closing brace should be on a new line.)

The above points suggest a different version of sass-convert is being used when run from sublime text.

edwardsdesign commented 11 years ago
  1. In terminal, can you let me know the output of which sass-convert
    • Sass 3.2.10 (Media Mark)
  2. In sublime text console, can you let me know the output of import os;print(os.environ.copy())
    • os;print(os.environ.copy()) <module 'os' from '/Applications/Sublime Text.app/Contents/MacOS/python3.3.zip/os.pyo'> {'LOGNAME': 'me', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'SSH_AUTH_SOCK': '/tmp/launch-sTpFGW/Listeners', 'HOME': '/Users/me', 'SHELL': '/bin/bash', '__CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'TMPDIR': '/var/folders/m6/fzblr91575v9yv1_zvcb4v3r0000gn/T/', 'Apple_PubSub_Socket_Render': '/tmp/launch-scoBeX/Render', 'USER': 'me', 'Apple_Ubiquity_Message': '/tmp/launch-Icux4R/Apple_Ubiquity_Message', 'COMMAND_MODE': 'unix2003'}

  3. In sublime text console, can you let me know the output of the following: import os;import...
    • import os;import subprocess;process=subprocess.Popen(['which','sass-convert'],env=os.environ.copy(),stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE);output,err=process.communicate();output=output.decode('utf-8');err=err.decode('utf-8');print(output);print(err); /usr/bin/sass-convert

badsyntax commented 11 years ago

When typing which sass-convert in terminal, i would expect a path, like " /usr/bin/sass-convert". Can you try that again?

edwardsdesign commented 11 years ago

Sure, it looks as though terminal is referencing the gem location. /Users/me/.rvm/gems/ruby-1.9.3-p125/bin/sass-convert

edwardsdesign commented 11 years ago

I checked my /usr/bin/ and the version of sass was from last 2012. I reinstalled sass (which sass-convert now points to /usr/bin/) and now SassBeautify is working like a charm. Not sure why it was referencing the gem location. Great support, thank you for helping me out with this.

badsyntax commented 11 years ago

Ahhh, RVM!! Yea RVM will change your PATH which is why a different sass version was being used in SassBeautify. This has caused issues for others as well, which is why I added a custom path option to this plugin.

If you want to continue to use RVM, you can try add the RVM sass bin folder path to the SassBeautify settings. (There's probably a more elegant solution, but I haven't figured it out yet as I'm not entirely familiar with RVM.)

I'm just glad we got there in the end! :+1:

Estlopacu commented 11 years ago

Hello

I am having problems with this same error. I try to edit the file SassBeautify.sublime-settings with the new path /usr/bin/ and I didn't have lucky. I also reinstalled sass and also I am using RVM.

Any help please! I have big sass files....

badsyntax commented 11 years ago

@Estlopacu Type the following into terminal and let me know the output: which sass-convert

Estlopacu commented 11 years ago

This /Users/estebanlopez/.rvm/gems/ruby-1.9.3-p429/bin/sass-convert

badsyntax commented 11 years ago

If you add /Users/estebanlopez/.rvm/gems/ruby-1.9.3-p429/bin to the plugin path setting it should work. I'm going to try add a new feature to this plugin to add the RVM ruby path automatically. I'm tracking that with issue #18.

badsyntax commented 11 years ago

@Estlopacu Actually adding that path will probably not work. I've reopened issue #1 and am working on a proper fix for this.

badsyntax commented 11 years ago

I think we can finally put this one to bed: https://github.com/badsyntax/SassBeautify#compatibility-with-rvm

Upgrade to the latest version (which includes a PATH fix):

Estlopacu commented 11 years ago

It works perfect! Thanks for you help.

Pura vida!! as we say in my country Costa Rica.

badsyntax commented 11 years ago

Very happy to hear, thank you :) RVM has caused me many headaches and I'm glad to finally figure out how it modifies the environment settings.