question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't cd into a specific directory

See original GitHub issue
  • Describe the current behavior:
%%bash
date_dir=`date +"%y-%m-%d"` # Use linux date command to get today's date and initialize to the `date_dir` variable
mkdir -p $date_dir          # Make a new directory (if it doesn't already exist) and assign the name as the value of the `date_dir` variable
cd "`ls -t | head -1`"      # This is supposed to list all elements in the current directory, sorted newest first, 
                            # only take the newest element and change directory into the newest element
  • Describe the expected behavior:

The cd command isn’t working on Google Colab, but this command works on my local linux machine.

  • The web browser you are using (Chrome, Firefox, Safari, etc.):

This behavior has been seen on Google Chrome and Firefox.

  • Link to self-contained notebook that reproduces this issue (click the Share button, then Get Shareable Link):

Copy/Paste the aforementioned Jupyter code in a notebook to reproduce this issue

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
craigcitrocommented, Jul 18, 2019

No, there’s no reasonable way for the child (bash) process to affect the state of the parent process.

0reactions
CSP197commented, Jul 18, 2019

So I’m currently using the following:

date_dir = datetime.date.today().strftime("%y-%m-%d")
os.makedirs(date_dir, exist_ok=True)
os.chdir(date_dir)

and wanted to implement the same concept using the % cell magic, but am unable to do so as of writing…

Any advice?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't I cd into a directory? - Server Fault
A good quick solution is to use $HOME instead of ~ . While ~ is not expanded even within double-quotes, $HOME is. So...
Read more >
Can't cd into my own directory? - Super User
Show activity on this post. Yes, you need execute permission on a directory to “traverse” it—that is, to do anything with its contents....
Read more >
having trouble with cd and getting back to a directory
This error message simply means that the directory/file you specified could not be found at your current location. If you look to the...
Read more >
files - Cannot cd into directory because of permission, but ...
So I changed them with runnign chmod -x {dirs and files} . Because I have done all the installation and the moving the...
Read more >
How to Fix CD Command Not Working in CMD Windows 10
E:. Check how to change directory in CMD (Command Prompt) by using CD command in Windows 10. Detailed Command Prompt change directory guide....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found