demotomohiro / remocolab

remocolab is a Python module to allow remote access to Google Colaboratory using SSH or TurboVNC.
MIT License
317 stars 230 forks source link

OSError: [Errno 26] Text file busy: 'cloudflared' #102

Closed radhasaraf closed 2 years ago

radhasaraf commented 2 years ago

Describe the bug Occasionally, I keep getting the error: OSError: [Errno 26] Text file busy: 'cloudflared' when trying to set up VNC using command remocolab.setupVNC() I suspect it's because of failure in downloading 'cloudflared-linux-amd64'

To Reproduce Steps to reproduce the behaviour:

!pip install git+https://github.com/demotomohiro/remocolab.git
import remocolab
remocolab.setupVNC()

Expected behavior VNC should be setup successfully

Desktop:

Additional context The first time I tried it, I got this error. The second time it worked fine and now it is consistently giving this error every time I run the code block. Attaching the log below:

As ngrok doesn't work on colab for long time, default tunnel method has been changed to Argo tunnel.
Please read this for more details:
https://github.com/demotomohiro/remocolab/blob/master/README.md
openssh-server is already installed
Failed to download  https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
[<ipython-input-15-0266415ad402>](https://localhost:8080/#) in <module>()
----> 1 remocolab.setupVNC()

[/usr/local/lib/python3.7/dist-packages/remocolab.py](https://localhost:8080/#) in setupVNC(ngrok_region, check_gpu_available, tunnel, mount_gdrive_to, mount_gdrive_from, public_key)
    419 
    420 def setupVNC(ngrok_region = None, check_gpu_available = True, tunnel = None, mount_gdrive_to = None, mount_gdrive_from = None, public_key = None):
--> 421   stat, msg = _setupSSHDMain(public_key, tunnel, ngrok_region, check_gpu_available, mount_gdrive_to, mount_gdrive_from, True)
    422   if stat:
    423     msg += _setupVNC()

[/usr/local/lib/python3.7/dist-packages/remocolab.py](https://localhost:8080/#) in _setupSSHDMain(public_key, tunnel, ngrok_region, check_gpu_available, mount_gdrive_to, mount_gdrive_from, is_VNC)
    287       ngrok_region = region = input()
    288 
--> 289   return (True, _setupSSHDImpl(public_key, tunnel, ngrok_token, ngrok_region, mount_gdrive_to, mount_gdrive_from, is_VNC))
    290 
    291 def setupSSHD(ngrok_region = None, check_gpu_available = False, tunnel = None, mount_gdrive_to = None, mount_gdrive_from = None, public_key = None):

[/usr/local/lib/python3.7/dist-packages/remocolab.py](https://localhost:8080/#) in _setupSSHDImpl(public_key, tunnel, ngrok_token, ngrok_region, mount_gdrive_to, mount_gdrive_from, is_VNC)
    191     ssh_common_options += f" -p {port}"
    192   elif tunnel == "argotunnel":
--> 193     _download("https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64", "cloudflared")
    194     #shutil.unpack_archive("cloudflared.tgz")
    195     pathlib.Path("cloudflared").chmod(stat.S_IXUSR)

[/usr/local/lib/python3.7/dist-packages/remocolab.py](https://localhost:8080/#) in _download(url, path)
     81   try:
     82     with urllib.request.urlopen(url) as response:
---> 83       with open(path, 'wb') as outfile:
     84         shutil.copyfileobj(response, outfile)
     85   except:

OSError: [Errno 26] Text file busy: 'cloudflared'
demotomohiro commented 2 years ago

Did you factory reset runtime before rerun remocolab.setupVNC()? https://github.com/demotomohiro/remocolab/wiki/Frequently-Asked-Questions#i-got-error-while-running-remocolabsetupvnc-or-remocolabsetupsshd

It looks like you ran remocolab.setupVNC() without factory reset and got "Text file busy: 'cloudflared'" error because cloudflared is running.

radhasaraf commented 2 years ago

Did you factory reset runtime before rerun remocolab.setupVNC()? https://github.com/demotomohiro/remocolab/wiki/Frequently-Asked-Questions#i-got-error-while-running-remocolabsetupvnc-or-remocolabsetupsshd

It looks like you ran remocolab.setupVNC() without factory reset and got "Text file busy: 'cloudflared'" error because cloudflared is running.

That is indeed true. Factory resetting runtime did the job. Thank you!