sustained / CoffeeScript-Sublime-Plugin

Syntax highlighting and checking, commands, shortcuts, snippets, compilation and more.
MIT License
290 stars 71 forks source link

Build Broken in Sublime Text Version 2.0.1 Build 2217 #9

Open topher515 opened 12 years ago

topher515 commented 12 years ago

Attempts to build any Coffeescript file using the Sublime Text build system results in the following error:

/usr/local/lib/node_modules/coffee-script/lib/cake.js:38
        throw new Error("Cakefile not found in " + (process.cwd()));
              ^
Error: Cakefile not found in <my_directory>/<my_coffeescript_file>
    at /usr/local/lib/node_modules/coffee-script/lib/cake.js:38:15
    at path.js:292:19
[Finished in 0.4s with exit code 1]
deweller commented 12 years ago

This is also happening to me.

Xavura commented 12 years ago

For me, at least, it looks like $project_path is not being set correctly in all cases. It seems this is an issue with Sublime.

Does this fix it? I don't know why that would fix it but apparently it works.

deweller commented 12 years ago

I did try removing and reinstalling the package. That fixed the "Error parsing plist xml" issue. But I am still unable to run the build system. I am seeing a "Cakefile not found" error similar to Topher515's.

Xavura commented 12 years ago

It is assumed that your .sublime-project file will be in your project's base directory. It is also assumed that the Cakefile will be there too. This is because of a limitation with build systems that means I am unable to determine your project's actual directory - the one added via Project » Add Folder(s) to Project - see the docs.

Currently the build system is using $project_path which means, the directory containing the .sublime-project file.

If I don't specify a working directory for the build system, then Sublime will default to the directory containing the file that is focused when you run the build system. The problem with that is it will also look for the Cakefile in the same place.

So you need to put your .sublime-project in your project directory along with your Cakefile. If you don't want it in source control then you can add it to your .gitignore.

Does this solve the issue?

deweller commented 12 years ago

I added an empty Cakefile and .sublime-project at my project's root. That helped a little. Now I get the following message when I run the build:

No such task: sbuild

To see a list of all tasks/options, run "cake"

I've never had a Cakefile or a .sublime-project in my project directory tree until now.

deweller commented 12 years ago

It occurs to me now that I've probably been using this plugin incorrectly. The build system is meant to be used with a Cakefile. I just naively used the build system without knowing anything about cake.

What the build did before recently is created a .js file in the same folder as the .coffee file I had highlighted. This was not useful as a build system, but it did provide feedback about any syntax errors.

I will read up on cake and add a meaningful Cakefile to my project.

For those of us who were using this plugin without a Cakefile, is it possible to restore this default behavior?

Xavura commented 12 years ago

That's all the build system does - it runs a Cake task which you would define in your Cakefile as such:

task 'sbuild', ->
    doStuff()
    andThings()

Typically this is where you would say concatenate your files, minify them, or whatever else building your project entails... which could be a myriad of things which is why it is done this way.

I was fairly certain there was also a Compile File command that would compile the current file to CoffeeScript but it appears I was wrong about that. I'm guessing the reason no one has complained about it yet is because everyone uses the coffee command line utility to compile their files, presumably with the --watch option.

For the moment, you can use alt+shift+d and then save the generated javascript file manually. I will add the missing Compile File command now, literally the package will be updated in 10-20 minutes.

If you're interested, in an upcoming update you will be able to just use watch integration.

Xavura commented 12 years ago

Windows decided to hard crash so that took a little longer than expected. You can now use alt+shift+c to compile the current file.

Pinging @topher515.

Xavura commented 12 years ago

@deweller By the way, alt+shift+s will run a syntax check and display the status in the status bar.

deweller commented 12 years ago

Well would you look at that! It turns out that alt-shift-s is exactly what I wanted and I didn't even know it.

I would probably be amazed at the treasure trove of helpful information I might find if I read the documentation.

Thanks for your help on this.

Xavura commented 12 years ago

Indeed, GitHub shows the documentation right there at the forefront for a reason. :smile:

topher515 commented 12 years ago

@Xavura, thanks for addressing this so quickly!

When I use alt-shift-s command it compiles the current CoffeeScript file into a new file which I then need to save as .js file.

The behavior which I originally used out-of-the-box was: cmd-b compiles the current CoffeeScript file into a Javascript file of the same name (but with a .js extension of course) and silently saves (w/ overwrite) in the background.

With the latest commit (fb04af1976), the cmd-b command continues to error with Error("Cakefile not found in " + (process.cwd())).

Is there a way to get this behavior back? I realize that having a proper cakefile is great in many cases but I also have several projects which simply dont warrant the complexity.

Xavura commented 12 years ago

You want alt±shift+c (c for compile).

Regarding ctrl+b, that's a shortcut for F7 and that does this.

Xavura commented 12 years ago

Regarding your error, I think I know what the problem may be. I'll look into it, you're on Windows right?

topher515 commented 12 years ago

Regarding the cmd+B error--no, actually I'm running OS X 10.7.

Regarding the alt-shift-c--Great, that's actually exactly what I was hoping for.

Xavura commented 12 years ago

Good to hear and I see the problem now, I'll fix it in the next update.

topher515 commented 12 years ago

Great! Thanks!

brihogan commented 12 years ago

My install didn't seem to be broken as mentioned in the original post, however the symbol list wasn't indenting properly and it was displaying unnecessary symbols (console, Object, etc). When I installed the files directly from https://github.com/jashkenas/coffee-script-tmbundle it worked (once I moved around some files from their subdirectories).

The problem can also be fixed if I install your plugin and then copy the "Symbol List*.tmPreferences" files from the "preferences" folder from jashkenas's repo straight into your plugin folder. Perhaps Sublime Text 2 added the need for these Symbol List files in the latest build? Looks like maybe you need to include them in your plugin?

Thanks for your work on this plugin.

peterschmidler commented 11 years ago

It would still be very nice to use cmd-B without a cakefile, as it works with Less. It would be cool to simply remember one shortcut. Is there any easy way to achieve this?

attenzione commented 11 years ago

i modified CoffeeScript.sublime-build

{
  // "path": "$HOME/bin:/usr/local/bin:$PATH",
  "cmd": ["coffeelint -f ~/.coffeelint --nocolor -q $file"],
  "file_regex": "([^\\s]+\\.coffee)$",
  "line_regex": "#(\\d+):(.*)$",
  "selector": "source.coffee, source.litcoffee, source.coffee.md",
  "shell": true,
  "osx": {
    "path": "~/:/usr/local/share/npm/bin:/usr/local/bin:/opt/local/bin"
  }
}

be careful with your path!

default ~/.coffeelint

{
  "no_tabs" : {
    "level" : "error"
  },

  "no_trailing_whitespace" : {
    "level" : "error"
  },

  "max_line_length" : {
    "value": 80,
    "level" : "error"
  },

  "camel_case_classes" : {
    "level" : "error"
  },

  "indentation" : {
    "value" : 2,
    "level" : "error"
  },

  "no_implicit_braces" : {
    "level" : "ignore"
  },

  "no_trailing_semicolons" : {
    "level" : "error"
  },

  "no_plusplus" : {
    "level" : "ignore"
  },

  "no_throwing_strings" : {
    "level" : "error"
  },

  "cyclomatic_complexity" : {
    "value" : 11,
    "level" : "ignore"
  },

  "line_endings" : {
    "value" : "unix",
    "level" : "ignore"
  },

  "no_implicit_parens" : {
    "level" : "ignore"
  },

  "no_stand_alone_at" : {
    "level": "ignore"
  }

}