atom-community / atom-script

:runner: Run ( scripts | selections | source ) in Atom
https://atom.io/packages/script
MIT License
734 stars 269 forks source link

Prolog windows support #941

Open robeady opened 8 years ago

robeady commented 8 years ago

Looks like the initial implementation for prolog (swipl) was cross-platform, but commit f87651e1c16a3e84a2134e4f3aa7a531e23af7dc by @Chosko broke it by calling bash.

Chosko commented 8 years ago

@rjeady I admit. I broke Windows compatibility for Prolog.

Initially I created the command for Prolog (https://github.com/rgbkrk/atom-script/pull/776) using directly the swipl command.

The problem is that the command is not run from the project's directory. This create issues when your prolog file consults other files, because swipl cannot find them. This is why i introduced (in https://github.com/rgbkrk/atom-script/pull/801) the 'bash' thing. And as you can see in the comments, we were aware of that.

Feel free to revert that commit if you want...

nixel2007 commented 8 years ago

The problem is that the command is not run from the project's directory.

is this a problem? we can pass current working dir as project's root.

Chosko commented 8 years ago

I just remember there were problems with launching swipl from the file's directory (sometimes you don't want to run it from the project's root, as your project may be arranged in modules that you want to run one by one). Another case is: if you are running some code in "file" mode, you might expect to run it as a single file, that may consult other files located relatively in its same directory, and not related to a whole project. I also remember I was looking into Sublime Text's packages to understand their behaviour in running script files, and I found they are based on file's directory, and not on project's root directory.

That said, I tried to run files from their path. The main problem with this is that swipl doesn't accept any parameter to run a file from a given directory. Then the quick-and-dirty solution was to call swipl from a command line (bash), that allowed me to cd in the file's directory before running it.

I think this issue is related to deciding what's more important between:

But their are mutually exclusive if we keep my workaround (I know my PR it's not a good solution). I'm open to revert it, if cross compatibility is more important that allowing modular projects (it makes a lot of sense). I understand cross-compatibility it's not an ignorable issue.

But if we want to keep this kind of modular behaviour together with cross compatibility, maybe there's a bit of work to do: I see in lib/grammars.coffee that Prolog is not the only language that uses this ugly workaround. Others are using bash to cd into the file path, while others more 'lucky' interpreters accept some options to decide that the context is the file's directory. This suggests me that maybe it's the case to find a more global (and overridable) configuration to select which languages should be run from the file's directory. For those languages, it may be useful to write a function that runs the command in the expected directory, preserving cross-compatibility. :-)

Unfortunately I don't have the time to look into this now. So, these are just wonderings, and I really understand if you decide to just drop my workaround.