0

In VSCode and trying to run the following:

dart pub upgrade

I get the following error:

Error: Error when reading 'pub': No such file or directory

However, my flutter file seems fine. Flutter Doctor output below:

[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.72.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

Any idea how I can resolve this? Thanks!

7
  • did you need to upgrade your dependency Commented Oct 19, 2022 at 4:34
  • @MrShakila I get this whenever trying to use any Pub commands but not sure what is causing this Commented Oct 19, 2022 at 4:36
  • if you're using some proxies that may cause the issue Commented Oct 19, 2022 at 4:40
  • I'm unfamiliar with proxies, but anyway I should resolve? Commented Oct 19, 2022 at 4:42
  • flutter pub upgrade --major-versions try this for flutter Commented Oct 19, 2022 at 4:44

3 Answers 3

1

first clean dart using dart pub cache clean

then run dart pub get

After that run dart pub get upgrade

Sign up to request clarification or add additional context in comments.

6 Comments

anytime I run a dart pub command I get: "Error: Error when reading 'pub': No such file or directory"
Any idea how I can re-install this or if address pointing to the right SDK
did you install dart SDK two times?I found this question if you did so
I dont think so but is there a way to check?
Is there a way to delete all potential versions of dart and redownload it?
|
0

try creating a .bashrc file in your user's folder.

Then add the following:

PATH=$PATH:/path/to/dart/installation/bin/folder
export PATH

1 Comment

Still getting the error
0

This can happen when you have installed Dart-sdk two times. One time as a windows installer, and the other through chocolatey for instance. Uninstall the one you have in "Add/Remove programs", or at least make sure you only have one, and it should work.

2 Comments

Do you know how I can do this on mac?
Refer here -> dart.dev/get-dart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.