guillermooo / dart-sublime-bundle

Sublime Text 3 Dart Package
BSD 3-Clause "New" or "Revised" License
264 stars 42 forks source link

Build Fails in Sublime Text 3 with Homebrew Dart #361

Closed partydrone closed 9 years ago

partydrone commented 9 years ago

I installed Dart via homebrew on OS X Mavericks. When I try to build anything, nothing happens. Here's what I have:

// Dart - Plugin Settings.sublime-settings
{
  "dart_dartium_path": "/Applications/Chromium.app",
  "dart_linter_active": false,
  "dart_linter_gutter_icon_error": "Packages/Dart/gutter/dartlint-simple-error.png",
  "dart_linter_gutter_icon_info": "Packages/Dart/gutter/dartlint-simple-info.png",
  "dart_linter_gutter_icon_warning": "Packages/Dart/gutter/dartlint-simple-warning.png",
  "dart_linter_on_load": true,
  "dart_linter_on_save": true,
  "dart_linter_show_popup_level": "WARNING",
  "dart_linter_underline_color_error": "C7321C",
  "dart_linter_underline_color_info": "0000FC",
  "dart_linter_underline_color_warning": "F18512",
  "dart_log_level": "error",
  "dart_sdk_path": "/usr/local/opt/dart/libexec",
  "dart_user_browsers":
  {
  }
}

With the following dart file:

// sample.dart
main() {
  print("Hello, Dart world!");
}

When I try to build it, nothing happens, and the following error shows up in the Sublime Text console:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 524, in run_
    return self.run(**args)
  File "exec in /Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package", line 168, in run
TypeError

I also set "dart_sdk_path": "/usr/local/opt/dart" with the same results. I also downloaded the Dart SDK from dartlang.org and pointed to that with the same results.

I'm not sure if this is an issue with the Dart Sublime bundle or with Sublime Text itself. I'm using Sublime Text 3, build 3065.

I created a corresponding issue at SublimeText/Issues#497.

partydrone commented 9 years ago

I updated to the 1.1.0 release, but the problem still persists. Here is a complete dump of what is in the console:

startup, version: 3065 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/aporter/Library/Application Support/Sublime Text 3/Packages
state path: /Users/aporter/Library/Application Support/Sublime Text 3/Local
hardware concurrency: 8
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/aporter/Library/Application Support/Sublime Text 3/Installed Packages
found 4 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 3 files for base name Main.sublime-menu
loading bindings
loading pointer bindings
found 2 files for base name Soda Dark 3.sublime-theme
theme loaded
app ready
wrote startup cache, added files: 3 orphaned files: 43 total files: 307 cache hits: 304
pre session restore time: 0.203674
using gpu buffer for window
using gamma: 2 (err: 6.9282)
first paint time: 0.261661
startup time: 0.27137
launching: /Applications/Sublime Text.app/Contents/MacOS/plugin_host
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin Package Control.Package Control
reloading plugin Dart.__init__
reloading plugin Dart.AAA
reloading plugin Dart.analyzer
reloading plugin Dart.browser
reloading plugin Dart.cmds_search
reloading plugin Dart.config_check
reloading plugin Dart.dartlint
Dartlint plugin loaded.
reloading plugin Dart.dev_cmds
reloading plugin Dart.docgen
reloading plugin Dart.execute
reloading plugin Dart.format
reloading plugin Dart.misc
reloading plugin Dart.polymer
reloading plugin Dart.pub_support
reloading plugin Dart.run
reloading plugin Dart.test_runner
plugins loaded
loaded 842 snippets
Package Control: Skipping automatic upgrade, last run at 2014-10-19 00:28:38, next run at 2014-10-19 01:28:38 or after
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 524, in run_
    return self.run(**args)
  File "exec in /Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package", line 168, in run
TypeError
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 445, in is_enabled_
    raise ValueError("is_enabled must return a bool", self)
ValueError: ('is_enabled must return a bool', <Default.exec.ExecCommand object at 0x1079d6b50>)
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 445, in is_enabled_
    raise ValueError("is_enabled must return a bool", self)
ValueError: ('is_enabled must return a bool', <Default.exec.ExecCommand object at 0x1079d6b50>)

I opened the Dart file and press +B to build it, which produces the output above. I also noticed that other keyboard commands (e.g., +C) produce the same is_enabled must return a bool error. I will post something about this in the corresponding issue.

guillermooo commented 9 years ago

I take it you are trying to run that file in a random folder, not in a package structured after the pub conventions?

partydrone commented 9 years ago

Yes. Currently there are only two files in this folder: sample.dart and sample.rb.

sample.dart:

main() {
  print("Hello, Dart world!");
}

sample.rb:

print 'Hello, Ruby world!'

Building the Ruby file opens up the results pane and shows the expected message. Also, if I run dart sample.dart from the command line, it works:

sample% dart sample.dart
Hello, Dart world!
sample%
guillermooo commented 9 years ago

The docs for this plugin should state clearly that the plugin works best if the code follows the pub conventions regarding project folder structure. I'll add that.

Also, if you add dart to the $PATH in way that GUI apps will see it just as a terminal sees it, the action above should work.

But anyway, I think I'll try to make some changes so random .dart files will be run through dart in any case. Otherwise, users starting out with Dart will get frustrated that they don't get any output related to dart.

guillermooo commented 9 years ago

BTW, you can use stagehand from the cmdline to easily generate a project skeleton. It's a pub package.

partydrone commented 9 years ago

Thanks, I'll give it a try.

By the way, here is more info on my current configuration:

% which dart
/usr/local/bin/dart
% echo $PATH
/Users/aporter/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
%

So it looks like dart is already in my $PATH. I'm not sure what else to do to make it so GUI apps will see it.

guillermooo commented 9 years ago

You can also try starting ST from the cmdline and see if that works.

partydrone commented 9 years ago

That's how I always start it, actually:

project_dir% subl .
partydrone commented 9 years ago

I just finished reorganizing my project into a pub project and tried it again. Same result. I also downloaded a bunch of sample projects from the Dart site and tried building those in ST. No dice.

sample/
  bin/
    sample.dart
  pubspec.yaml
  pubspec.lock
guillermooo commented 9 years ago

It seems you are using CMD+B. In ST, that shortcut is bound to the active build system, but the Dart plugin has no notion of a default build system (as in 'ST build system'). It does, however, implement a custom sort of build system that is bound to the F7 key.

So, AFAICT, when you press CMD+B, ST attempts to run the default build system for the file type, but it fails because there isn't one. This is intended behaviour from the POV of the Dart plugin.

F7 should work, however.

partydrone commented 9 years ago

Yep, F7 works!

I think it's worth mentioning that if the Dart bundle uses a custom build system bound to a different key, it probably shouldn't be listed in the Tools > Build System menu, as that's where most users are likely to go to run their scripts.

After watching Timothy Armstrong's video, it looks like +B used to run dart2js and generate all the javascript files, but that's not happening, either.

guillermooo commented 9 years ago

In ST, F7 and Ctrl+B are synonyms (at least on Windows). I guess it would make sense to have them both behave the same in the Dart plugin. I think there used to be a reason why they don't now, but I forget.