Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a clear error on -o pointing to an invalid directory. fixes #8549 #8551

Merged
merged 5 commits into from
May 8, 2019

Conversation

kripken
Copy link
Member

@kripken kripken commented May 5, 2019

Without this, Python will give an error "no such file" when we try to write to that file, which can be confusing. Worse, this will happen on the first file we try to write to, which may be one of the helper files (.wasm, .mem, etc.), which is even more confusing.

emcc.py Outdated
# target is just a basename, then dirname is '', which os.path.exists would
# report as not existing)
dirname = os.path.dirname(target)
if dirname and not os.path.exists(dirname):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be more specific here and use "os.path.isdir(dirname)".

# (note that we must check that dirname is not the empty string - if the
# target is just a basename, then dirname is '', which os.path.exists would
# report as not existing)
dirname = os.path.dirname(target)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the final sentence in brackets is necessary. It obvious enough (I think) what if dirname and not os.path.exists(dirname): is doing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the following comment

Check for the existence of the output directory now, to avoid having to do so repeatedly when each of the various output files (.mem, .wasm, etc) is written.   This gives a more useful error message than the IOError and python backtrace that users would otherwise see.

@sbc100
Copy link
Collaborator

sbc100 commented May 6, 2019

For reference the way native toolchains report this (both clang and gcc) is:

/usr/bin/ld: cannot open output file tmpxx/foo: No such file or directory

@kripken
Copy link
Member Author

kripken commented May 8, 2019

Thanks for the feedback @sbc100 , should be addressed now.

@kripken kripken merged commit 3fda0b7 into incoming May 8, 2019
@kripken kripken deleted the invalid_output_dir branch May 8, 2019 18:15
VirtualTim pushed a commit to VirtualTim/emscripten that referenced this pull request May 21, 2019
…ripten-core#8549 (emscripten-core#8551)

Without this, Python will give an error "no such file" when we try to write to that file, which can be confusing. Worse, this will happen on the first file we try to write to, which may be one of the helper files (.wasm, .mem, etc.), which is even more confusing.
VirtualTim added a commit to VirtualTim/emscripten that referenced this pull request May 23, 2019
VirtualTim added a commit to VirtualTim/emscripten that referenced this pull request May 23, 2019
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
…ripten-core#8549 (emscripten-core#8551)

Without this, Python will give an error "no such file" when we try to write to that file, which can be confusing. Worse, this will happen on the first file we try to write to, which may be one of the helper files (.wasm, .mem, etc.), which is even more confusing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants