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.

Unable to create a directory

See original GitHub issue

What happened: Trying to create a directory in a bucket and it silently fails.

What you expected to happen: Expect a key created in a bucket.

Minimal Complete Verifiable Example:

from s3fs import S3FileSystem
s3 = S3FileSystem(anon=False)
s3.makedirs('s3://my-bucket-name/testdir', exist_ok=False) #fails to create 
s3.makedirs('my-bucket-name/testdir', exist_ok=False) #fails to create

How do I create a directory in a bucket? Am I doing something wrong or is it a bug? I see conversation in #245 and I was wondering if you could please help explain what the intended behavior is.

Anything else we need to know?: s3fs version == 0.5.0 Relevant issue here: #245

Environment:

  • Dask version:
  • Python version: 3.7.7
  • Operating System: Ubuntu Linux
  • Install method (conda, pip, source): conda

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
martindurantcommented, Dec 2, 2020

This is a long-standing misunderstanding, and your help, @srib , would be greatly appreciated in clarifying the situation for other users.

s3 does not support directories, except the top-level buckets, which are fairly similar in their behaviour. If you expect s3.makedirs('my-bucket-name/testdir') to enable you to write files with paths that start with that string then: congratulations! There is in fact nothing for s3fs to do, the location was already writable.

Once you have a file like “my-bucket-name/testdir/testfile”, the directory will appear to exist, without that file it will not. This is similar to trying to commit an empty directory to git.

Unfortunately, the situation is complicated by the behaviour of the s3 console, which has a “make directory” button, whose action is actually to create an empty file with the name of the directory you wanted. This is not part of the s3 API, just a convention, and the AWS CLI does not do this. If we were to do this, we end up making extra requests, and have to distinguish between real common preixes (directories implied by having contents) and empty placeholder files.

1reaction
martindurantcommented, Jun 24, 2021

That would make sense if mkdir were only called by end users, but other libraries call it internally. Since the intent there is “make sure that files can be written as children of this path”, the co-op does exactly the right thing - and errors and warnings would just get in the way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't Create a New Folder in Windows 10? Here's How to Fix It
1. Update Your Windows · 2. Try the Keyboard Shortcut to Create a New Folder · 3. Create a New Folder via Command...
Read more >
'Unable to create the directory' error in laravel (on the server)
When I submit the form it gives me a "Unable to create the "http://xxx.xx.xx/profileLogo" directory". This is when I'm trying to save the ......
Read more >
Error 5: Access Denied: Setup unable to create the directory
The problem is with the security permissions on your profile temp folder. To fix it navigate to %temp% or C:\Users\[Username]\AppData\Local and ...
Read more >
How to Fix "Installation Failed: Could Not Create Directory"
If your site's permissions settings are causing the “Installation failed: could not create directory error,” you can resolve it by resetting ...
Read more >
Unable to create a file or directory under some specific ...
This directory is read-only: you can not create files or directories in it. The following error appears in an attempt to modify files...
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