PJQuakJag
PJQuakJag

Reputation: 1247

Receiving an error when trying to run pub

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!

Upvotes: 0

Views: 218

Answers (3)

Nikhil
Nikhil

Reputation: 315

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.

Upvotes: 0

Shakila
Shakila

Reputation: 1059

first clean dart using dart pub cache clean

then run dart pub get

After that run dart pub get upgrade

Upvotes: 1

Chiisom
Chiisom

Reputation: 71

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

Then add the following:

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

Upvotes: 0

Related Questions