Can't require image with spaces, etc. in filename
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, react-native
- Domain
- build-system, mobile-dev, tooling
Research direction
Start in metro/src/Assets.js at getAbsoluteAssetRecord and getAsset, using the reported stack trace as the entry point. Reproduce the asset request with a filename containing spaces under React Native 0.81 and compare behavior with 0.79. Done means the asset loads without the ENOENT path containing encoded filename characters.
Written by the indexing model from the issue text.
Description
Hi folks, I'm getting the same error seen in this very old RN issue:
https://github.com/facebook/react-native/issues/10364
Here is the stacktrace that shows this is ocurring in Assets.js
Error: ENOENT: no such file or directory, scandir '/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/.%2Fassets%2Fimages'
at Object.readdir (node:internal/fs/promises:956:18)
at getAbsoluteAssetRecord (/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/node_modules/@expo/metro/node_modules/metro/src/Assets.js:114:17)
at getAsset (/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/node_modules/@expo/metro/node_modules/metro/src/Assets.js:224:18)
at Server._processSingleAssetRequest (/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/node_modules/@expo/metro/node_modules/metro/src/Server.js:436:20)
at Server._processRequest (/Users/andrew/Work/Code/projects/Failure/Mobile/ReactNative/failure/node_modules/@expo/metro/node_modules/metro/src/Server.js:535:7)
I've confirmed that the file name had a space in it; when I renamed it to not have a space, it works just fine. Strangely, this did not happen in 0.79 of React Native; I recently upgraded to 0.81 of RN, and this happened. Though it says it's expo related, when forking this repo, the node_module file for Assets.js was the same as here, so I assume it's the correct repo.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 699
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 33
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from react/metro
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/metro#1927 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Async chunk URLs drop the file extension, so .cjs async imports fail with "Requiring unknown module"Open
Difficulty 3/5 1-2 days Newbie friendliness 74/100
react/metro#1959 · 2 comments · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
react/metro#1928 · 2 comments · 2 reactions ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
keyxmakerx/Chronicle#967 ·
Maintainers usually reply within 1 day
-
good first issue hacktoberfest
Difficulty 1/5 Under an hour Newbie friendliness 92/100
RogueAlg0/taken#386 · 3 comments ·
Maintainers usually reply within 1 day
-
external-issue to-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
LearningCircuit/local-deep-research#7067 ·
Maintainers usually reply within 1 day