PlatformIO Community

Cannot build project... pioenvs error


#1

After installing Python 3.7.3 I am no longer able to build any project.

ERROR: Can not remove temporary directory.........\.pioenvs

There is not .pioenvs to remove. I have checked everywhere I can think, including the specified location.
I removed Python 3.7.3
I restarted VS, I restarted Windows 10.
I removed all Python exe files I could find.
I uninstalled Platformio deleted the folder and reinstalled.
I still get the same error, report below.

Executing task: C:\Users\johnk\.platformio\penv\Scripts\platformio.exe run <

Can not remove temporary directory `c:\Users\johnk\Documents\PlatformIO\Projects\oled_lab\.pioenvs`. Plea
se remove it manually to avoid build issues
Processing esp32dev (framework: arduino; platform: espressif32; board: esp32dev)
--------------------------------------------------------------------------------------------------------
Error: Traceback (most recent call last):
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\__main__.py", line 120, in main
    cli(None, None, None)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\click\core.py", line 700, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\click\core.py", line 680, in main
    rv = self.invoke(ctx)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\click\core.py", line 1027, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\johnk\.platformio\penv\lib\site-packages\click\core.py", line 873, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\click\core.py", line 508, in invoke
    return callback(*args, **kwargs)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\click\decorators.py", line 16, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\commands\run.py", line 97, in cli
    result = (envname, ep.process())
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\commands\run.py", line 163, in proce
ss
    result = self._run()
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\commands\run.py", line 225, in _run
    self.verbose)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\commands\run.py", line 248, in _auto
install_libdeps
    ctx.invoke(cmd_lib_install, libraries=[lib], silent=not verbose)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\click\core.py", line 508, in invoke
    return callback(*args, **kwargs)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\commands\lib.py", line 108, in lib_i
nstall
    library, silent=silent, interactive=interactive, force=force)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\managers\lib.py", line 351, in insta
ll
    force=force)
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\managers\package.py", line 692, in i
nstall
    with LockFile(self.package_dir):
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\lockfile.py", line 102, in __enter__

    self.acquire()
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\lockfile.py", line 86, in acquire
    return self._lock()
  File "c:\users\johnk\.platformio\penv\lib\site-packages\platformio\lockfile.py", line 61, in _lock
    self._fp = open(self._lock_path, "w")
IOError: [Errno 2] No such file or directory: 'c:\\Users\\johnk\\Documents\\PlatformIO\\Projects\\oled_la
b\\.piolibdeps.lock'

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================

#2

It’s a hidden folder, can you turn on “show hidden fodlers” in your windows explorer?


#3

@maxgerhardt
It’s a hidden folder, can you turn on “show hidden fodlers” in your windows explorer?

I thought I had hidden already turned on. I took 40 minutes to change the attribute in all the files and folders. But it doesn’t matter, I still do not see .pioenvs even though all the other hidden files are shown and I get the same error.


#4

Oh actually the problem seems that it cannot create a lock for accessing the .piolibdeps. Could you check if

  • the user you are executing the IDE with has sufficient rights to that folder, i.e. right-click on the project folder -> Properties -> Security -> click on your User -> Edit -> Give all rights
  • you might want to delete .piolibdeps and see what happens.
  • you maybe want to re-initilaize the project using pio init in the project’s directory.

#5

Please understand, this is a new problem. I have been using PIO with great success for months. The only thing, to my knowledge, it that I upgraded to Python 3.7.x.
None of my projects have worked since. I have rolled everything that I can think of back.

  • the user you are executing the IDE with has sufficient rights to that folder, i.e. right-click on the project folder -> Properties -> Security -> click on your User -> Edit -> Give all rights
  • you might want to delete .piolibdeps and see what happens.
  • you maybe want to re-initilaize the project using pio init in the project’s directory.

I re-checked and admin and myself all have full rights.(As far as I can tell)
I deleted ‘.piolibdeps’ without any change to the problem
But,
Something interesting…
When I tried to run pio inti in the project directory I got the following error. I don’t know if it means anything…

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

. : File C:\Users\johnk\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded 
because running scripts is disabled on this system. For more information, see about_Execution_Policies 
at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . 'C:\Users\johnk\Documents\WindowsPowerShell\Microsoft.PowerShell_pr ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\johnk\Documents\PlatformIO\Projects\oled_lab> pio init
Fatal error in launcher: Unable to create process using '"'

#6

Python3 should be no problem (https://github.com/platformio/platformio-core/issues/895#issuecomment-462057766).

Did you install PIO via the shell or using it within PlatformIO?

Did you login and logout so that changes in the environment variables take effect?


#7

@ maxgerhardt
Did you install PIO via the shell or using it within PlatformIO?

I guess I don’t understand the difference of PIO from PlatformIO.
I uninstalled the PlatformIO extension within VS then reinstalled the extension within VS.
Where should I run “pio init” ? I tried running it in the Microsoft.powershell and in Bash shell in the project directory. I keep getting:
Fatal error in launcher: Unable to create process using ‘"’
I have restarted VS and PIO and Windows mutiple times.


#8

You should have the pio command available within a PlatformIO terminal https://docs.platformio.org/en/latest/ide/vscode.html#platformio-toolbar

The VSCode extension internally installs the actual PlatformIO core in a python environment.


#9

Sorry, yes, I have been using the toolbar in VS for months.

I still don’t understand why I get a error message that some process cannot remove .pioenvs, then the next line says that it cannot find it

Can not remove temporary directory `c:\Users\johnk\Documents\PlatformIO\workspace2\pioSloberVerifier\.pio
envs`. Please remove it manually to avoid build issues
Processing esp32-gateway (framework: arduino; platform: espressif32; board: esp32-gateway)
--------------------------------------------------------------------------------------------------------
Exception: [Error 2] The system cannot find the file specified: 'c:\\Users\\johnk\\Documents\\PlatformIO\\workspace2\\pioSloberVerifier\\.pioenvs':
File "C:\Users\johnk\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 113:
PROJECTBUILD_DIR=get_projectbuild_dir(),

#10

Because you’ve been playing with file permissions… is there any chance

c:\Users\johnk\Documents\PlatformIO\workspace2\pioSloberVerifier

was created with admin privileges, and now you’re running VSCode (and PlatformIO) as a normal user?


#11

@pfeerick
Thanks for your input

I am starting to think it might be a permission thing but why would everything change after over 6 months of use and working on 4 different project, each in their own folders? Even upgrading Python happened weeks ago. But per your suggestion, I ran VS in admin mode, but no joy.
The project does not complain about not being able to run it complains that it cannot run properly.and about .pioenvs
Example:

Executing task: C:\Users\johnk.platformio\penv\Scripts\platformio.exe run --target clean <

Can not remove temporary directory c:\Users\johnk\Documents\PlatformIO\Projects\oled_lab\.pioenvs. Plea
se remove it manually to avoid build issues
Processing esp32dev (framework: arduino; platform: espressif32; board: esp32dev)
Also
I can no longer create a project:

Server error: {“message”:"[Error 2] The system cannot find the file specified: u’C:\\Users\\johnk\\Documents\\PlatformIO\\Projects\\oled2’",“args”:[2,“The system cannot find the file specified”],“type”:“WindowsError”}


#12

Solved, I finally figured it out !!!
And as I suspect, it was all my fault.

The last thing I did last Friday was to enable Windows 10 Ransomware protection without bothering to understand how it was protecting me. I had forgotten that I had done this.
Following pfeerick thought I was trying to figure out why I could not create a file in Documents with Powershell while I could with file Explorer. When doing a search abut that it was suggested to look at security settings, that’s when I saw that everything under users/johnk/Documents is protected, I realized that protected means that the security setting stopped powershell scripts from making write and create changes to files in protected folders, which make sense as to how malware would lock up files.
The tragedy and difficulty in solving this problem is that I had not worked with PS that much, especially when trying to solve a problem and the error reports gave no clue’ as far as my limited knowledge could tell’ that it was a permission problem different from the permissions found in file Explorer.
Anyway, thanks to all that took the time to try and help me. I hope this two day debacle with solution helps someone else.


#13

Oh raspberry… When your security settings make it so you can’t actually do what you should be able to do! :open_mouth: :laughing: Nice catch @catotonic… and yes, I’m sure this will help someone in the future… most likely me if I actually press that button! :laughing: