Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colab suddenly unable to navigate through directories

I've been using Google Colab for the past months without issues connecting to drive and typing shell commands with !. However today, an error suddenly occurred and I can't find anything to solve it. Colab seems to magically not be able to navigate through directories. I get an error for any bash commands for directories like cd, pwd, mkdir, etc..

Even after closing, reopening the notebook and restarting Runtime, and only running the single line of code :

!pwd

I get this error :

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Transport endpoint is not connected
pwd: error retrieving current directory: getcwd: cannot access parent directories: Transport endpoint is not connected

whereas you normally would get /content printed by the console.

I've been able to bypass the problem by creating a copy of the Notebook, but I still wanted to ask this question, since after looking in Google, Stackoverflow, Super User, I didn't find a single thread closely related to my issue. I've also looked in Colab's documentation in vain. So I thought it would benefit the community as a whole in the future to open a thread talking about a new issue.

Has anybody encountered the issue and know how to fix this ?

Thanks to all of you :)

like image 844
Atralb Avatar asked Jan 26 '19 20:01

Atralb


1 Answers

I faced a similar problem. Here's a quick fix to this:

  1. Go to Colab
  2. Click on Runtime
  3. Finally, click on restart runtime.(Caution: Your local variables will be lost)

Now, you'll be able to use shell commands in the colab cell.

like image 124
Harshit Singh Avatar answered Oct 01 '22 00:10

Harshit Singh