GreenCodeSki
GreenCodeSki

Reputation: 909

Error when running pub get: Failed to rename directory because it was in use by another process

I get the below error when I try to get packages of beautifulsoup in my dart console project.

[scrape_3] pub get
Resolving dependencies...
+ beautifulsoup 0.0.1
Downloading beautifulsoup 0.0.1...
Failed to rename directory because it was in use by another process.
This may be caused by a virus scanner or having a file
in the directory open in another application.
exit code 1

My pubspec.yaml file is as follows:


    name: scrape_3
    description: A sample command-line application.
    # version: 1.0.0
    # homepage: https://www.example.com
    environment:
      sdk: ">=2.10.0 <3.0.0"
    
    #dependencies:
    #  path: ^1.7.0
    dev_dependencies:
      pedantic: ^1.9.0
      test: ^1.14.4
    dependencies:
      beautifulsoup: ^0.0.1
      html: ^0.13.3+3

How can I solve this? this is a recurring error for me and happens often.

Upvotes: 2

Views: 6877

Answers (4)

Cristian Dornelles
Cristian Dornelles

Reputation: 191

Just reset changes on your "pubspec.lock". Or simply delete it.

Upvotes: 2

mohmdezeldeen
mohmdezeldeen

Reputation: 449

If you using android studio
1.restart you laptop/pc.
2.close your antivirus if exist.
3.run android studio as administration and try again.

Upvotes: 0

Cornchips007
Cornchips007

Reputation: 165

I had to close VSCode, open it as Admin, then run flutter get again.

As an extra precaution I had also made sure I didn't have any of the flutter/dart tools running in command lines, powershell etc and no File Explorer windows open.

Upvotes: 0

GreenCodeSki
GreenCodeSki

Reputation: 909

Shutting down PC and starting it back on after some minutes eventually worked. Apparently, the file stays in use by VS CODE itself for a while and direct Restarts don't work

Upvotes: 1

Related Questions