Sublime Forum

Dependencies for unmanaged packages (not installed with PC)

#1

Hi,

how do I get sublime text to install dependencies for packages that are not managed by package control? I have my own (at least for now) not-public package, I added a “dependencies.json” file to the package folder and was hoping that CT installs the dependencies. But nothing happens. I restarted multiple times, I used the “PC: Satisfy Dependencies” etc.

Thanks!

0 Likes

#2

Works fine for me.

Can you paste the contents of your dependencies.json?

0 Likes

#3

Here is the file. It’s saved as “Packages/MyPackage/dependencies.json” but arrow never gets installed. There are also no error messages. Thanks!

{
	// This file is a filesystem-level solution for specifying dependencies
	// for packages. This is most useful for package developers since they are
	// not installing their own packages from a repository or channel, and
	// need to make sure Package Control installs the dependencies they need.

	// The file contains two levels of selectors, platform and Sublime Text
	// version, to pick what set of dependencies should be installed.
	// The most-specific selectors will be used, and all other ignored. This
	// means that some dependencies will be duplicated under a specific
	// platform and under *.

	// The first level of keys should be the value from sublime.platform(),
	// or "*" for all platforms.

	// Matching of platform and version selectors is exclusive. Thus, these
	// dependencies will only be installed if no other keys matched first.
	"*": {
		"*": 
			"arrow"
		]
	}
}
0 Likes

#4

Can confirm, with your file it does not work. The reason for that are the comments; you need to remove them since PC is using the json module internally. Sublime Text 3 provides a new method that can parse JSON with comments, but obviously that is not available on ST2. There are also methods to remove comments using regular expressions, but that is not feasable imo.

I will add some code that shows an error if parsing dependencies.json fails.

0 Likes

#5

Seriously? I mean I get the API isn’t available, but stripping comments from JSON is pretty easy.

I’ve been doing it reliably for years in a number of my packages and in other various projects; not straight regex, but still it doesn’t require that much code. I am yet to run into a situation where it failed. I’m surprised something hasn’t been included in Package Control to do that for ST2.

0 Likes

#6

I’ll think about adding comment support when I fix github.com/wbond/package_control/issues/946, and I’ll likely do it since I think it is useful. I suppose Will just didn’t consider people wanting to use comments in dependencies.json files.

I’ve been doing it like this in packagedev: github.com/SublimeText/AAAPacka … py#L16-L44

0 Likes

#7

Not so different from mine :smile:. github.com/facelessuser/ThemeSc … omments.py

It’s no big deal to me since I am on ST3. And normally, I think you’d be correct in assuming people wouldn’t use comments, but people get used to the idea of Sublime allowing comments in all their config files, and they don’t separate plugin configs from Sublime configs in their brain. When there is no targeted error telling you the comments is the issue, it is even more confusing. So I think it would be good to add a simple comment removal method.

0 Likes

#8

Thanks, I will try that later. I am also on ST3 though…

ps: It’s working now. The comments also seem to be a problem on ST3. I just thought it’s convenient to leave the documentation in the file. Thanks!

0 Likes

#9

I don’t think it is unreasonable for Package Control to follow the JSON spec for files ending in .json. Comment stripping happens in ST, but not for files ending in .json, just .sublime-* files.

If we are are going to consider allowing people to violate the JSON spec, we should probably document the changes and change the file extension.

0 Likes

#10

[quote=“wbond”]I don’t think it is unreasonable for Package Control to follow the JSON spec for files ending in .json. Comment stripping happens in ST, but not for files ending in .json, just .sublime-* files.

If we are are going to consider allowing people to violate the JSON spec, we should probably document the changes and change the file extension.[/quote]

Extremely good points, and I completely understand your position. I only suggest stripping comments because the average user will probably blunder things because they don’t make the obvious separation between the two; some peoples first exposure to JSON may be in Sublime’s config files. Now that doesn’t necessarily make it Package Control’s problem. I guess if the error just got logged so the user could determine they are breaking the JSON syntax, then I guess that would be okay as well. Sometimes it is just easier to be lax on input and strict on output, but may not be the way you want to go.

0 Likes