QuestionIs there a way to tell pub to create 'relative symlinks' instead of 'absolute symlinks' to reference its cache?
It seems like pub is storing the cached packages in ~/ or in the directory specified by the PUB_CACHE environment variable.Pub is using absolute symlinks which cause a challenge with my vagrant setup.
This creates the cache and also symlinks to the cache. Now my initial problem was that the cache was outside of my source coderepository and therefore was not mounted into the virtual machine which means that the symlinks pointed to a place that did not existfrom the point of view of the virtual machine.I wanted to work around this by manually setting PUB_CACHE on my host machine as well as in my virtual machineto the root of my source code repository (/path/to/my/project/.pubcache).
If they were relative symlinks I could use the IDEs on my host and at the same time run build scriptswithin the virtual machine without having to regularly run pub get or rewire the symlinks manually when I switch context.
Workaround?I will try to re-wire the symlinks manually since I don't run pub get all the time (just need to remember it)and maybe do a wrapper script that runs pub get and re-wires the symlinks automatically for me.
On Mon, Aug 25, 2014 at 2:56 PM, Thomas Schranz <tho...@blossom.io> wrote:
QuestionIs there a way to tell pub to create 'relative symlinks' instead of 'absolute symlinks' to reference its cache?
Currently, no. But supporting that would be super easy.It seems like pub is storing the cached packages in ~/ or in the directory specified by the PUB_CACHE environment variable.Pub is using absolute symlinks which cause a challenge with my vagrant setup.Right and right. We use absolute symlinks here deliberately because they mean that if you move your package directory, the symlinks don't all break.
This creates the cache and also symlinks to the cache. Now my initial problem was that the cache was outside of my source coderepository and therefore was not mounted into the virtual machine which means that the symlinks pointed to a place that did not existfrom the point of view of the virtual machine.I wanted to work around this by manually setting PUB_CACHE on my host machine as well as in my virtual machineto the root of my source code repository (/path/to/my/project/.pubcache).Yup, that makes perfect sense. It's one of the reasons the cache directory is configurable.If they were relative symlinks I could use the IDEs on my host and at the same time run build scriptswithin the virtual machine without having to regularly run pub get or rewire the symlinks manually when I switch context.Yeah, having to constantly re-get is a total drag.Workaround?I will try to re-wire the symlinks manually since I don't run pub get all the time (just need to remember it)and maybe do a wrapper script that runs pub get and re-wires the symlinks automatically for me.
That's the workaround I'd consider too. The other thing you could do is replace all of your dependencies with path dependencies that point to the packages stored at a location your VM can reach to. In other words, basically vendor your dependencies into your app and then tell pub to use path dependencies to find them. Path dependencies do support relative symlinks so this will then work in your host OS and in the VM. You'll probably need to use dependency overrides to deal with transitive deps. But this will be a pain, and just fixing the symlinks is probably easier in the short term.Can you file a bug to support relative symlinks to the cache? We're trying to move away from symlinks in general, but that's a long slow process. In the meantime, supporting opt-in relative symlinks to the cache is an easy change. (The usual caveat: that this won't work at all on Windows.)
I'll note that pub build/serve/run don't require these symlinks at all. As long as the cache is in a directory that the VM can see (like you did), they should work both in the VM and on your host machine.
The Dart Editor is also moving (has moved? I'm not sure about the status) to going through pub to resolve "package:" URLs. That means it won't require those symlinks either and should Just Work™. I'm not sure about IntelliJ and the command-line analyzer.
- bob
Does that mean we'll eventually be to tell pub to not even create the packages directories?
Or might that even become a default? :)