Incorrect path file reference to packages when sharing solution between mac and windows

Issue

I have solution/flutter app running on windows fine. Within the .packages file vscode is referencing the package via

analyzer:file:///c:/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.31.2-alpha.2/lib/
args:file:///c:/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.4.3/lib/
async:file:///c:/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.7/lib/
...

I have the flutter sdk installed c:\flutter directory on windows.

I copied this solution via dropbox to the mac and when running

“Warning! This package referenced a Flutter repository via the .packages file that is no longer available”.

In an effort to isolate/locate the problem, I created a new Flutter project on the mac and found that the .packages file referenced packages via

analyzer:file:///flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.31.2-alpha.2/lib/
args:file:///flutter/.pub-cache/hosted/pub.dartlang.org/args-1.4.3/lib/
async:file:///flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.7/lib/
...

Notice the different paths used on both systems.

I suspect I can search/replace the references file:///c:/flutter to file:///flutter and it should work but I would like to avoid always manually swapping out locations. Is there an easier approach when sharing solutions across mac and windows?

thx

Solution

Don’t copy .packages over from one machine to another. (It should be in .gitignore if using git.)

Instead, run flutter packages get on the mac, and it will recreate .packages.

(Don’t copy .flutter-plugins either.)

Answered By – Richard Heap

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *