dart-sublime-bundle
dart-sublime-bundle copied to clipboard
The plugin doesn't work for stagehand console app
I just have installed the plugin and tried it on a simple console project generated by stagehand, looks like nothing works, it gives me no warnings, no lines... In the console I see a couple of exceptions:
Traceback (most recent call last):
File "/opt/sublime_text_3/sublime_plugin.py", line 208, in on_load
callback.on_load(v)
File "/home/coffeeowl/.config/sublime-text-3/Packages/Dart/lib/path.py", line 78, in inner
return func(self, view)
File "/home/coffeeowl/.config/sublime-text-3/Packages/Dart/analyzer.py", line 137, in on_load
g_server.send_remove_content(view)
File "/home/coffeeowl/.config/sublime-text-3/Packages/Dart/analyzer.py", line 397, in send_remove_content
if self.should_ignore_file(view.file_name()):
File "/home/coffeeowl/.config/sublime-text-3/Packages/Dart/analyzer.py", line 439, in should_ignore_file
is_a_third_party_file = (project and is_path_under(project.path_to_packages, path))
File "/home/coffeeowl/.config/sublime-text-3/Packages/Dart/lib/path.py", line 66, in is_path_under
prefix = os.path.realpath(top_level)
File "./posixpath.py", line 394, in realpath
TypeError: 'NoneType' object is not subscriptable
The problem is that should_ignore_file
sends None
to is_path_under
and it fails. Such a simple project has no 3rd party deps. I have made a quick fix:
def should_ignore_file(self, path):
project = DartProject.from_path(path)
if project and project.path_to_packages is not None:
is_a_third_party_file = is_path_under(project.path_to_packages, path)
else:
is_a_third_party_file = False
if is_a_third_party_file:
return True
sdk = SDK()
return is_path_under(sdk.path, path)
Not sure if that is the most correct way, but it has started to work on my sample project
The packages directory will never be available in new dart projects
As of Dart 1.20, the .packages file has replaced packages directories.
If both are present, tools use the .packages file. For more information, see Resolving package: URIs.
For backward compatibility, the pub serve command still produces a virtual packages directory, and the pub build command produces an actual packages directory in its output directory. To make other pub commands create packages directories, specify --packages-dir.
Two years later, I applied this fix and was able to get myself up and running. So thanks.