guillermooo / dart-sublime-bundle

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

Error when running files. #498

Open ceronman opened 9 years ago

ceronman commented 9 years ago

I'm getting the following error when running Dart files:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 533, in run_
    return self.run(**args)
  File "/home/ceronman/.config/sublime-text-3/Packages/Dart/run.py", line 263, in run
    if dart_view.is_server_app:
  File "/home/ceronman/.config/sublime-text-3/Packages/Dart/lib/pub_package.py", line 253, in is_server_app
    is_cli_script = self._find_at_top('dart:io')
  File "/home/ceronman/.config/sublime-text-3/Packages/Dart/lib/pub_package.py", line 186, in _find_at_top
    for line in self._get_top_lines():
  File "/home/ceronman/.config/sublime-text-3/Packages/Dart/lib/pub_package.py", line 180, in _get_top_lines
    end = self.view.full_line(80 * 50).end()
AttributeError: 'NoneType' object has no attribute 'full_line'

After looking a little bit at the code it looks like DartRunFileCommand is not creating a DartFile without a sublime view object:

dart_view = DartFile.from_path(file_name)

Happens with version 1.3.7

ceronman commented 9 years ago

More debugging information:

This happens when it's trying to detect if it's a server app:

if (project.path_to_example and
            self.has_prefix(project.path_to_example)):
                # TODO(guillermooo): improve detection of cli apps under
                # 'example'.
                is_cli_script = self._find_at_top('dart:io')
                is_not_web_file = (self.is_dart_file and
                                   not self._find_at_top('import:html'))
                return (is_cli_script or is_not_web_file)
garajo commented 9 years ago

I get the same Traceback. It started to go wrong when I went into a different project folder. I was trying to use F7 with the intent to serve a different project. But it kept serving the last project. I did some searching and wondered if this is related, https://github.com/guillermooo/dart-sublime-bundle/pull/359. But before I could comment in that issue, F7 started to fetch my dependencies instead; and not do pub serve as I expected. That's when I noticed the error, matching this thread, which gets triggered on subsequent F7 calls. I hope this helps.