Dart: Pub Get not working – Solution
I haven’t posted anything in ages. I have been working away on various projects some of which were dead ends some of which might lead to something, we’ll see.
Also, I have been playing around with Dart, Maven and Tomcat which I will post about later. One problem I came across which I couldn’t find a straight answer to anywhere on the web was an issue I had with ‘pub get‘ for Dart. This command downloads your dart application dependencies to a folder local to your Dart project. For some reason is just stopped working properly for me. It would create the folder structure but not fetch any (or not the majority of) files. I tried
- Deleting the pubspec.lock file and redo ‘pub get‘.
- Deleting my package folders and redo ‘pub get‘.
- Trying ‘pub upgrade‘ in case that had some effect.
None of these actions had any effect.
I knew it had to be something to do with a local cache but I couldn’t find the folder as stated in the documentation. It does mention you can define a system variable PUB_CACHE to redirect the cache to where you want. So I created a system variable (windows) and set it to a folder under my user setting and then retried pub get‘. This time it worked perfectly.
It is not clear to me what I did to break the ‘get’ mechanism. I wish I knew so I could raise an issue but in the meantime I hope this helps someone else with the same problem.