Mac’s are a bit tricky because when MacOS runs a GUI program it gets a different path than what applications launched from the terminal get. Sublime runs programs using the path that it inherited when it got started, so the path that it sees is different from what you might expect.
How you go about it seems to vary based on what version of MacOS you have, so I would recommend a Google search for the specific version that you have to get instructions on how to modify it for your install.
With that said, there’s another way around this: override the build system that’s being used or duplicate it with a new name and use that one instead. These have the advantage of working no matter what version of MacOS you have.
The disadvantage (for the override method) is that if the package ever updates the build system, your modification will override the new version as well and you won’t see the changes. That’s not a show stopper though, just something to be aware of.
For either method, the first thing you need to do is take a look at what the current build system is doing. I don’t have a package for this installed, so this is based on the first hit in google for such a package being this page. The steps are still the same, although the actual file names and content may differ.
- Install PackageResourceViewer, if you haven’t already; it’s a great tool for peeking inside of installed packages and making modifications.
- Open up the command palette (
Tools > Command Palette
or Shift+⌘+P on MacOS)
- Filter down the list of commands to
Package Resource Viewer: Open Resource
(entering prv
is usually enough to get close) and run it
- The list of installed packages opens; filter it by entering
Cobol
and select the package that pops up
- The list of all of the files that exist in this package will be presented, so select
OpenCOBOL.sublime-build
(you can enter the text build
to filter to just build files) and hit enter to open the file, then close the command palette if it’s still open.
You should now be looking at the contents of the sublime build file that you’re using. The build file from the link I mentioned above looks like this; yours may be different if you’re not using the same package.
{
"selector": "source.cobol",
"cmd": [
"cobc -fsyntax-only $file"
],
"working_dir": "$file_path",
"shell": true,
"file_regex": "^([^:]+):([0-9]+):",
"osx": {
"env": {
"PATH": "/usr/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin:$PATH"
}
},
"linux": {
"env": {
"PATH": "/usr/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin:$PATH"
}
}
}
From here, you can modify the PATH
setting under osx
to include the path to your cobc
compiler (path settings are separated from each other by the colon character) if your build system is similar, add such a section if your build system doesn’t have one, or modify the cmd
portion to specify the absolute path to the command so that it doesn’t need to be looked up in the path at all.
If you modify the file and hit save, the modification will be saved not in the actual package, but in your own Packages
directory as an override. This keeps the installed package pristine and gives you your change as if it was a part of the package, but it does mean that if the package itself updates this file, sublime will still use yours.
Alternatively, you could save it in your Packages/User
folder with a name like CustomCobol.sublime-build
or something similar, and then select that build system from the menu so that yours gets used instead.