deadfoxygrandpa / Elm.tmLanguage

Elm language syntax highlighting and tool integration for ST2/3
https://packagecontrol.io/packages/Elm%20Language%20Support
MIT License
122 stars 27 forks source link

Support elm-package.json outside source directory #49

Closed thSoft closed 8 years ago

thSoft commented 8 years ago

I have the attached directory layout: before When I try to build an Elm file in src, the result is the following: after The readme says: "Elm build system only requires a valid config in any ancestor directory of the active file", so it should support this layout, shouldn't it?

texastoland commented 8 years ago

Would you restart ST, build again, open the dev console with Ctrl+`, and paste its contents?

thSoft commented 8 years ago
startup, version: 3083 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/thsoft/Library/Application Support/Sublime Text 3/Packages
state path: /Users/thsoft/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/thsoft/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.42078
first paint time: 0.615529
startup time: 0.652828
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_context_url
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.quick_panel
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 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.02-bz2
reloading plugin AngularJS.AngularJS-sublime-package
reloading plugin AngularJS.jscompletions
reloading plugin AngularJS.message
reloading plugin AngularJS.sublime_commands
reloading plugin AngularJS.viewlocation
reloading plugin Better TypeScript.TypeScript
reloading plugin Elm Language Support.elm_generate
reloading plugin Elm Language Support.elm_make
reloading plugin Elm Language Support.elm_open_in_browser
reloading plugin Elm Language Support.elm_plugin
reloading plugin Elm Language Support.elm_project
reloading plugin Elm Language Support.elm_show_type
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 74, in reload_plugin
    m = importlib.import_module(modulename)
  File "./importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 678, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "elm_show_type in /Users/thsoft/Library/Application Support/Sublime Text 3/Installed Packages/Elm Language Support.sublime-package", line 334, in <module>
  File "elm_show_type in /Users/thsoft/Library/Application Support/Sublime Text 3/Installed Packages/Elm Language Support.sublime-package", line 78, in load_docs
NotADirectoryError: [Errno 20] Not a directory: '/Users/thsoft/Library/Application Support/Sublime Text 3/Installed Packages/Elm Language Support.sublime-package/docs.json'
reloading plugin Glue.__init__
reloading plugin Glue.Glue
reloading plugin Glue.GlueBrowser
reloading plugin Glue.GlueCmds
reloading plugin Glue.GlueIO
reloading plugin Glue.GlueSidebarOpener
reloading plugin Highlight Build Errors.HighlightBuildErrors
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin SideBarEnhancements.SideBar
reloading plugin SideBarEnhancements.SideBarAPI
reloading plugin SideBarEnhancements.SideBarDefaultDisable
reloading plugin SublimeOnSaveBuild.SublimeOnSaveBuild
plugins loaded
Running elm-make ../../../../Users/thsoft/Development/Terminology/src/Table.elm --output=/dev/null --report=json --yes
Package Control: Skipping automatic upgrade, last run at 2015-09-17 22:25:42, next run at 2015-09-17 23:25:42 or after
texastoland commented 8 years ago

Sorry I forgot to ask you to set "debug": true in our Settings! The package parser is designed to log deduced file paths. I'm hoping it will reveal why you're getting such a funky relative path. It looks like something I should be able to fix this weekend.

thSoft commented 8 years ago
startup, version: 3083 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/thsoft/Library/Application Support/Sublime Text 3/Packages
state path: /Users/thsoft/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/thsoft/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.498226
first paint time: 0.618886
startup time: 0.654554
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_context_url
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.quick_panel
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 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.02-bz2
reloading plugin AngularJS.AngularJS-sublime-package
reloading plugin AngularJS.jscompletions
reloading plugin AngularJS.message
reloading plugin AngularJS.sublime_commands
reloading plugin AngularJS.viewlocation
reloading plugin Better TypeScript.TypeScript
reloading plugin Elm Language Support.elm_generate
reloading plugin Elm Language Support.elm_make
reloading plugin Elm Language Support.elm_open_in_browser
reloading plugin Elm Language Support.elm_plugin
reloading plugin Elm Language Support.elm_project
reloading plugin Elm Language Support.elm_show_type
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 74, in reload_plugin
    m = importlib.import_module(modulename)
  File "./importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 678, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "elm_show_type in /Users/thsoft/Library/Application Support/Sublime Text 3/Installed Packages/Elm Language Support.sublime-package", line 334, in <module>
  File "elm_show_type in /Users/thsoft/Library/Application Support/Sublime Text 3/Installed Packages/Elm Language Support.sublime-package", line 78, in load_docs
NotADirectoryError: [Errno 20] Not a directory: '/Users/thsoft/Library/Application Support/Sublime Text 3/Installed Packages/Elm Language Support.sublime-package/docs.json'
reloading plugin Glue.__init__
reloading plugin Glue.Glue
reloading plugin Glue.GlueBrowser
reloading plugin Glue.GlueCmds
reloading plugin Glue.GlueIO
reloading plugin Glue.GlueSidebarOpener
reloading plugin Highlight Build Errors.HighlightBuildErrors
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin SideBarEnhancements.SideBar
reloading plugin SideBarEnhancements.SideBarAPI
reloading plugin SideBarEnhancements.SideBarDefaultDisable
reloading plugin SublimeOnSaveBuild.SublimeOnSaveBuild
reloading plugin View In Browser.ViewInBrowserCommand
plugins loaded
Package Control: Skipping automatic upgrade, last run at 2015-09-17 22:25:42, next run at 2015-09-17 23:25:42 or after
[Elm says]: Detected settings: ElmProject(
    data_dict=None,
    exists=False,
    file_path=/Users/thsoft/Development/Terminology/src/Table.elm,
    html_path=build/Table.html,
    json_path=None,
    main_path=../../../../Users/thsoft/Development/Terminology/src/Table.elm,
    output_dir=build,
    output_ext=html,
    output_name=Table,
    output_path=build/Table.html,
    working_dir=,
)
Running elm-make ../../../../Users/thsoft/Development/Terminology/src/Table.elm --output=/dev/null --report=json --yes
[Elm says]: Invalid JSON from elm-make: Downloading elm-lang/core
[Elm says]: Invalid JSON from elm-make: Packages configured successfully!
[Elm says]: Invalid JSON from elm-make: elm-make: ../../../../Users/thsoft/Development/Terminology/src/Table.elm: openFile: does not exist (No such file or directory)
[Elm says]: Invalid JSON from elm-make: 

The contents of my elm-package.json are:

{
    "version": "1.0.0",
    "summary": "Terminology",
    "repository": "https://github.com/thSoft/Terminology.git",
    "license": "BSD3",
    "source-directories": [
        "../src"
    ],
    "exposed-modules": [
        "Terminology"
    ],
    "dependencies": {
        "elm-lang/core": "2.0.0 <= v < 3.0.0",
        "evancz/elm-html": "4.0.1 <= v < 5.0.0",
        "jcollard/key-constants": "1.0.1 <= v < 2.0.0"
    },
    "elm-version": "0.15.0 <= v < 0.16.0"
}

However, a new elm-package.json is generated in the directory where the Elm source file is located, which is clearly undesirable.

texastoland commented 8 years ago

Wait is your elm-package.json in build? That's not a parent directory of Table.elm. The directory tree can't reasonably be traversed laterally (like up a directory then recurse back down again).

thSoft commented 8 years ago

Oh crap, then it's my fault, sorry. Then can the location of elm-package.json be configured per project?

texastoland commented 8 years ago

I made an architectural decision to search from the active file. I consulted @deadfoxygrandpa and @rtfeldman about using ST project configs but most users aren't even aware of them. There are also often multiple Elm configs per ST project. I believe this is a shortcoming in Elm but I believe the solution wouldn't be amenable to the maintainer. My current project uses one for distribution and another for tests. If you're interested in adding project level support I can offer guidance and review your PR? Closing for now.

thSoft commented 8 years ago

That's totally OK, thanks for the support so far! :)

texastoland commented 8 years ago

Much obliged!