emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.93k stars 665 forks source link

Emsdk install latest: unzipping file failed, invalid mode 'wb' #402

Open jon-heard opened 4 years ago

jon-heard commented 4 years ago

I've been attempting to install the latest emscripten on windows using the main install instructions. "Emsdk install latest" seems to download the zip properly (I can see the percent increase), but fails on unzipping with the following message:

Unpacking 'c:/Python27/emscripten/emsdk/zips/8bb7b0bbbca74cc58741416cc955011f22ff5ccb-wasm-binaries.zip' to 'c:/Python27/emscripten/emsdk/upstream' Unzipping file 'c:/Python27/emscripten/emsdk/zips/8bb7b0bbbca74cc58741416cc955011f22ff5ccb-wasm-binaries.zip' failed due to reason: [Errno 22] invalid mode ('wb') or filename: '\\?\c:\Python27\emscripten\emsdk\unzip_temp\install/emscripten_config_fastcomp'

I've determined that python 27 is being used and I've turned on "Admin mode" to avoid permissions issues. Does anyone have a thought as to what might be causing this? Thanks for any help you can provide.

mattiasgustavsson commented 4 years ago

I am getting the same error. Is there a pre-package zip archive somewhere instead of having to use an "install" script?

kripken commented 4 years ago

Perhaps the problem is in filename: '\\?\c:\Python27\emscripten\emsdk\unzip_temp\install/emscripten_config_fastcomp' - that looks odd, specifically the \\?\ prefix. Maybe adding some debug prints in the emsdk script can help figure that out.

cc @juj , maybe that looks like a known windows issue?

juj commented 4 years ago

The \\?\ specifies a Windows UNC path name to the local computer. The appeal of using UNC path names is that it lifts the path length limit from 260 chars to 32767 chars. However a drawback is that UNC path names do not support using forward slash / as a path delimiter, so the path should be \\?\c:\Python27\emscripten\emsdk\unzip_temp\install\emscripten_config_fastcomp.

juj commented 4 years ago

Perhaps changing https://github.com/emscripten-core/emsdk/blob/cf90c72aba3e09ffd96d90a6fdf87095ed5351b8/emsdk.py#L541 from '/' to os.path.sep might work. I.e.

   unzip_to_dir = os.path.join(os.path.sep.join(dest_dir.split('/')[:-1]), 'unzip_temp') 

(the other '/' probably needs to stay since it comes from zip contents)

Although https://github.com/emscripten-core/emsdk/blob/cf90c72aba3e09ffd96d90a6fdf87095ed5351b8/emsdk.py#L561 may need to change to if stripped_filename.endswith('/') or stripped_filename.endswith('\\'): as well.

I am unable to repro the bug, so perhaps @jon-heard or @mattiasgustavsson might be able to check if that change would fix the issue?

jon-heard commented 4 years ago

Thanks for your response. I'll let you know if they help resolve the issue.

jon-heard commented 4 years ago

Your ideas didn't pan out directly, but did lead to a good results. In the end, I could tell that python's zipfile package was not handling things properly (according to its documentation), which made me suspicious of the library version. After looking further, it looks like we were using an old version of python (2.7.2, which google led us to when searching "python 2"). That old version didn't work well with emscripten installation.

flower0wine commented 3 months ago
D:\桌面\clone\emsdk>emsdk install latest
Resolving SDK alias 'latest' to '3.1.57'
Resolving SDK version '3.1.57' to 'sdk-releases-523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d-64bit'
Installing SDK 'sdk-releases-523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d-64bit'..
Skipped installing node-16.20.0-64bit, already installed.
Skipped installing python-3.9.2-nuget-64bit, already installed.
Skipped installing java-8.152-64bit, already installed.
Installing tool 'releases-523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d-64bit'..
Downloading: D:/桌面/clone/emsdk/downloads/523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d-wasm-binaries.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d/wasm-binaries.zip, 487219899 Bytes
Unpacking 'D:/桌面/clone/emsdk/downloads/523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d-wasm-binaries.zip' to 'D:/桌面/clone/emsdk/upstream'
Unzipping file 'D:/桌面/clone/emsdk/downloads/523b29e1b99a61069a2fa9f9d3cc9be1c4c53d4d-wasm-binaries.zip' failed due to reason: File is not a zip file! Removing the corrupted zip file.
error: installation failed!

I encountered a similar error while executing emsdk install latest.