Where does `pub get` download pubspec dependencies to? - flutter

In javascript, we have NPM and the node_modules folder in every project. I was not able to find a similar concept for Dart/ Flutter, except the build folder in my app, which contains a folder of a few dependencies I have in pubspec.yaml. It doesn't have any of the source code though, and I think it's actually built from something else. I've also looked in /usr/local/flutter/packages which is where my flutter is installed, but it only shows flutter_driver, flutter_goldens, and more seemingly unrelated folders.
I guess if wanted to read the source code, I really need to find the repo and read from that, or is there a location for dependencies I haven't looked?
I even found projectDir/.dart_tool/pub, which didn't have any of my packages.

From the documentation:
Dependencies downloaded over the internet, such as those from Git and
the pub.dev site, are stored in a system-wide cache. This means that
if multiple packages use the same version of the same dependency, it
only needs to be downloaded and stored locally once.
By default, the system package cache is located in the .pub-cache
subdirectory of your home directory (on Mac and Linux), or in
%APPDATA%\Pub\Cache (on Windows; the location might vary depending on
the Windows version). You can configure the location of the cache by
setting the PUB_CACHE environment variable before running pub.
So for Mac and Linux for example, this would be ~/.pub-cache/hosted/pub.dartlang.org by default.

In Android Studio
I could directly view the source code of the package under `
[External Libraries/Dart Packages/Your Packages]
`

You can get pubspec downloaded from your flutter sdk location .
/flutter/.pub-cache/hosted/pub.dartlang.org/
You can also clone package git .

If you are running Windows as your OS, you can find the packages under the folder that you installed your Flutter SDK to when setting up Android Studio.
In my case - using Windows 10 - the path is as follows, where C:\ is my primary harddrive and flutter\ the folder containing the Flutter SDK...
C:\flutter\.pub-cache\hosted\pub.dartlang.org\english_words-4.0.0
The above path for instance points to the "english words package", containing the most ~5000 used English words and some utility functions, which are mentioned and used in the Flutter tutorial on their official page for writing and running your first Flutter app.
https://pub.dev/packages/english_words

If you have installed flutter using snap then the location might be
/home/user/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org

I had forgotten that I've been command + clicking into these libraries all the time in VSCode.
However, it looks like packages are not stored in the app folder. Packages that we use in our projects are downloaded to $FLUTTER_PATH/.pub-cache, so if I'm looking for camera picker plugin, its in
/usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.5+2/lib/image_picker.dart

If you are using VScode you can find these dependencies under the dependencies window:

Related

Can't load Kernel binary: Invalid SDK hash in Flutter

Whenever I try to run a dart tool like Dart Migrate I get the following error and I am unable to run that tool. Is there a way to solve this problem or I have to reinstall Flutter?
Btw every thing is okay with Flutter Doctor
After a lot of effort and wasting a lot of time on this issue I have been able to solve this problem. I have installed dart-sdk separately in the past and place the path of that dart-sdk at the top (before flutter one) in environment variables PATH. So I deleted that old dart-sdk path and deleted the respective folder this solved my problem.
In VS Code, if you get "Can't Load Kernel binary: Invalid SDK Hash" in Flutter or Dart, update dart.sdkPath setting
If you get this in VS Code, in addition to re-downloading the dart-sdk, make sure the "dart.sdkPath" setting in user/workspace settings is pointing to the new SDK. In my case, even though I had it in my path as in Junaid's answer, VS Code was still looking to the old dart-sdk folder and giving me the kernel hash error. I updated the dart.sdkPath to the correct path and restarted VS Code:
For example, in Windows:
Download dart sdk
Unzip it to c:\tools\dart-sdk or any other folder (make sure you rename or delete the existing dart-sdk folder)
ctrl-shift-p, type 'user settings (JSON)', open the json settings, and add:
"dart.sdkPath": "C:\\tools\\dart-sdk",
Update your system PATH environmental variable to point to the new dart-sdk and delete the reference to the old location.
Restart VS Code.
Note that Instead of This "dart.sdkPath": "D:\Dart\dart-sdk\bin" work well for me.
path should be included '\bin' also. It work for me

How to delete then reinstall Flutter

Whenever I have a problem with Flutter I often find answers saying 'reinstall the Flutter SDK'.
However I cannot find any clear instructions on how to do this (please direct me to them if I am wrong).
General Questions
By 'clear' instructions, I mean ones that answer the following questions:
What folder(s) should be deleted to remove Flutter from my computer?
Do any files need to be copied and added to the new Flutter folder once I reinstall it?
Do I need to make any changes to my Flutter projects either before or after reinstalling Flutter?
Will I need to download the same channel (stable, beta, dev, master) as what I am currently on?
Will I need to make any changes to my PATH?
Are these the correct steps to reinstall?
Go to https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
Download the zip of the release you want (safest to use latest stable version)
Open Flutter zip in SAME location as the previous Flutter folder was
Done - I should now be able to run Flutter projects without any further steps
Apologies if these seem like very basic questions but for someone fairly new it isn't obvious what the answers are.
I'm new to Flutter and had similar issues. I will outline what worked for me but meanwhile, to answer your questions:
What folder(s) should be deleted to remove Flutter from my computer?
The Flutter folder which you unzipped and, presumably added to $PATH. Although not deleting it isn't going to pose an issue. I have separate folders of different versions of Flutter on my computer and it's fine.
Do any files need to be copied and added to the new Flutter folder
once I reinstall it?
Try a fresh download of Flutter and unzip it? There is no need to copy or add any files to the Flutter folder once you've (re)installed it.
Do I need to make any changes to my Flutter projects either before or
after reinstalling Flutter?
Not exactly sure what you mean by make changes to your Flutter projects. If you ran flutter doctor and didn't get any errors, then it's good to go. When you create a new Flutter project either in Android Studio, VS Code or Terminal, it will automatically handle whatever file copying business.
Will I need to download the same channel (stable, beta, dev, master)
as what I am currently on?
No, you only need one. I suggest you download one from Stable unless you need web support, which would be Beta.
Will I need to make any changes to my PATH?
After you've unzipped your fresh copy of Flutter (note the folder destination), open Terminal and change the path to said folder destination but make sure it's the /bin folder you're mapping to.
Are these the correct steps to reinstall?
Go to
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
Download the zip of the release you want (safest to use latest stable
version) Open Flutter zip in SAME location as the previous Flutter
folder was Done - I should now be able to run Flutter projects without
any further steps
Yes and no. You're missing a number of steps. Please follow the full Flutter installation guide depending on your OS.
It took me about 10 hours over two days and a VPN to finally get it working in China with an old install from two years ago when I was in Montréal.

How to develop Flutter app and related package at same time in VS Code

I have a Flutter app and a package folder loaded in VS code at the same time within a workspace. What entry do I need to make to my app's pubspec.yaml file to ensure that changes I've made to the package are compiled and included whenever I hot reload or restart the app? What would be an alternate strategy if this is not possible?
If your pubspec.yaml refers to your package with a path then I would expect this to happen automatically. If not, I would consider it a bug. Please file an issue at https://github.com/Dart-Code/Dart-Code and include a log file generated by running the Dart: Capture Logs command and as much info about your project layout as possible (a clonable repo to repro would be perfect).

How to install android build support for unity manually (unity hub)?

I used Unity Hub downloaded latest Unity Editor, it works fine for editor,document and language packs, but can not download android build support. Just told me download failed many many times in the past two days.
So I downloaded UnitySetup-Android-Support-for-Editor-2018.2.16f1.pkg from webpage. This package install reported failed at the end of every try.This package size(348.9M) is not same as the one showed(365.8M) in UnityHub download list.
There is a 2017 version Unity Editor installed by download **.pkg, but the support installer never ask me about Editor's location.
Is there some way to install android build support manually?
Thanks for any tips.
This worked for me. To anyone facing this problem. I apologize for my long explanation and my english.
You can verify if *.pkg file is complete by comparing the checksum (I use dolphin)
Execute this command to manually install your UnitySetup-Android-Support-for-Editor-*.pkg
:~> ./UnitySetup-2019.1.0f2 -u --use-component-list
unity-2019.1.0f2-linux.ini --install-location $HOME/2019.1.6f1/ -d
$HOME
Note that the unity version must be compatible, otherwise you will have the error unable to initialize the Unity engine in you android device. I use:
UnitySetup-Android-Support-for-Editor-2019.1.6f1
Unity-2019.1.6f1
As much as possible use unity hub to install the android add-on, I use unity hub 2.0.1
Step by step explanation of the installation manually of *.pkg
The problem :(
I will put them in context.
I use opensuse tumbleweed. My problem was that I did not have android build support.
No Android module loaded image, and when I press open download page, the browser shows me a message:
<Error> <Code>AccessDenied</Code> <Message>Access denied.</Message> <Details> Anonymous caller does not have storage.objects.get access to publishing-unity-binaries-prd/6e9a27477296/Unknown/UnitySetup-Android-Support-for-Editor-2018.3.0f2. </Details> </Error>
and I can not do anything else.
The SOLUTION :)
0.- Previous requirements
I already had my previous installation this file:
UnitySetup-2019.1.0f2
1.- Download UnitySetup-Android-Support-for-Editor-2019.1.x.pkg
To achieve this look for UnitySetup-Android-Support-for-Editor- in the file https://public-cdn.cloud.unity3d.com/hub/prod/releases-linux.json
This is a fragment of release-linux.json file
...
{
"id": "android",
"name": "Android Build Support",
"description": "Allows building your Unity projects for the Android platform",
"downloadUrl": "h ttps://download.unity3d.com/download_unity/f2970305fe1c/MacEditorTargetInstaller/UnitySetup-Android-Support-for-Editor-2019.1.6f1.pkg",
"category": "Platforms",
"installedSize": 1958542000,
"downloadSize": 664332318,
"visible": true,
"selected": false,
"destination": "{UNITY_PATH}/Editor/Data/PlaybackEngines/AndroidPlayer",
"checksum": "d00addecefb7babcb9cd6a8085672908"
}
...
What interests us about this file is the url to download https://download.unity3d.com/download_unity/f2970305fe1c/MacEditorTargetInstaller/UnitySetup-Android-Support-for-Editor-2019.1.6f1.pkg and the checksum.
2.- Component list file
Download the file from the list of components from here or create a file like unity-2019.1.0f2-linux.ini:
[Android]
title=Android Build Support
description=Allows building your Unity projects for the Android platform
url=MacEditorTargetInstaller/UnitySetup-Android-Support-for-Editor-2019.1.6f1.pkg
md5=d00addecefb7babcb9cd6a8085672908
install=true
mandatory=false
size=365578263
installedsize=1259081000
requires_unity=false
for [Android] install=true, the url and md5 which is the checksum from the previous step (or again I get md5 with dolphin to verify)
3.- Installation
Have the following files in the same directory that in my case are in $HOME
UnitySetup-2019.1.0f2
UnitySetup-Android-Support-for-Editor-2019.1.6f1.pkg
unity-2019.1.0f2-linux.ini
Finally, execute the following command line. (Note that my current unity installation is in $HOME/2019.1.6f1/).
:~> ./UnitySetup-2019.1.0f2 -u --use-component-list unity-2019.1.0f2-linux.ini --install-location $HOME/Unity-2019.1.6f1/ -d $HOME
Thanks
Source
https://forum.unity.com/threads/installing-android-build-support-and-other-build-support-post-installation.515436/
https://forum.unity.com/threads/how-to-install-editor-packages.554977/
Download the Android Sdk Manager under Command line tools only.
And download the SDK you need, then link it to Unity.
I usually download AndroidStudio and it comes with a GUI manager.
Here is some more info about how to update sdk tools.
You link it here: Edit/Preferences/External Tools
According to this:
Possible causes could be:
A corrupt package (download again manually from the list of individual
packages)
Filesystem corruption (repair disk from single-user mode, reboot and
try again)
The user account somehow not being in the sudoers group (deeper
technical problem - check Apple's forums)
Package file stored on a drive formatted weirdly, so execute
permissions aren't set correctly (pre-/post-installation script won't
run; move to boot drive)
Add Unity modules on Linux manually:
Download pkg:
Head to this page, select your specific unity version from the dropdown at the right.
For those modules that arent listed in linux section, download the pkg from the mac section.
Extract the pkg. you can use any of these:
Files
Archive Manager
7z x -o* UnitySetup-XXXXXX-Support-for-Editor-2022.1.16f1.pkg
bsdtar -xf UnitySetup-XXXXXX-Support-for-Editor-2022.1.16f1.pkg TargetSupport.pkg.tmp/Payload
Move the extracted "Payload" file to one of these directories:
For Android Build Support:
{UNITY_PATH}/Editor/Data/PlaybackEngines/AndroidPlayer
For Windows Build Support (Mono) & Widows Dedicated Server Build Support:
{UNITY_PATH}/Editor/Data/PlaybackEngines/WindowsStandaloneSupport
For Mac Build Support (Mono) & Mac Dedicated Server Build Support:
{UNITY_PATH}/Editor/Data/PlaybackEngines/MacStandaloneSupport
4. Now decompress and extract Payload:
zcat Payload | cpio -iu && rm Payload
or if it's named Payload~ just extract it:
cpio -iu < Payload~ && rm Payload~

how to compile kdesvn from githib repo

I've downloaded the sources for kdesvn from the github repo as I'm thinking to look into working on an addition to the project. Now turns out, I'm not even able to properly compile the downloaded sources: I've created a directory kdesvn-build changed into it and launched cmake ../ (as described on https://github.com/KDE/kdesvn/blob/master/INSTALL-cmake) which does some stuff but then stops saying:
CMake Error: The following variables are used in this project, but
they are set to NOTFOUND. Please set them or make sure they are set
and tested correctly in the CMake files: SUBVERSION_INCLUDE_DIR
Now, I don't know what SUBVERSION_INCLUDE_DIR should be set to nor could I find it searching around the web. Anyone?
It is a directory containing svn_*.h files. If you are on Linux, you'd need to install something like subversion-dev package. On FreeBSD headers are installed with main package, and the directory is /usr/local/include/subversion-1/.