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

can't open C:\Users\��\AppData\Local\Temp\cc4K9XbU.s for reading: Illegal byte sequence make: *** [Makefile:247: c99func.o] #320

Closed
yunkyukim opened this issue Dec 11, 2022 · 11 comments

Comments

@yunkyukim
Copy link

What problems are you experiencing?

can't open C:\Users\��\AppData\Local\Temp\cc4K9XbU.s for reading: Illegal byte sequence
make: *** [Makefile:247: c99func.o]

Steps to reproduce

What's the output from ridk version?

ruby:
path: C:/Ruby31-x64
version: 3.1.3
platform: x64-mingw-ucrt
ruby_installer:
package_version: 3.1.3-1
git_commit: a09714d
msys2:
path: C:\Ruby31-x64\msys64
cc: gcc (Rev6, Built by MSYS2 project) 12.2.0
sh: GNU bash, 버전 5.2.9(1)-release (x86_64-pc-msys)
os: Microsoft Windows [Version 10.0.19044.2251]

@yunkyukim yunkyukim reopened this Dec 11, 2022
@larskanis
Copy link
Member

Can you explain, what you're trying to do?

@yunkyukim
Copy link
Author

I'm trying to make my github.io using jekyll-theme-chirpy.

@larskanis
Copy link
Member

The "Steps to reproduce" above are an important part of a bug report. No one can help you, if you don't tell the command(s) you executed and the output text of them.

I just did an successful jekyll install - it looks like so:

c:\Users\kanis>gem inst jekyll --no-doc
Successfully installed webrick-1.7.0
Successfully installed unicode-display_width-2.3.0
Successfully installed terminal-table-3.0.2
Successfully installed safe_yaml-1.0.5
Successfully installed rouge-4.0.0
Successfully installed forwardable-extended-2.6.0
Successfully installed pathutil-0.16.2
Successfully installed mercenary-0.4.0
Successfully installed liquid-4.0.3
Successfully installed kramdown-2.4.0
Successfully installed kramdown-parser-gfm-1.1.0
Successfully installed jekyll-watch-2.2.1
Successfully installed jekyll-sass-converter-2.2.0
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed http_parser.rb-0.8.0
Building native extensions. This could take a while...
Successfully installed eventmachine-1.2.7
Successfully installed em-websocket-0.5.3
Successfully installed colorator-1.1.0
Successfully installed jekyll-4.3.1
18 gems installed

c:\Users\kanis>

@yunkyukim
Copy link
Author

I put the same command: gem inst jekyll, but the results are same. Thanks for help anyway! I think I should read the manual carefully and try again...

@larskanis
Copy link
Member

Could it be that the username you're using consists of an invalid byte sequence? The error message looks like that. You might try an ASCII only name instead.

@mohits
Copy link
Collaborator

mohits commented Dec 14, 2022

@larskanis - I wonder if this is related to this earlier issue: #265

@kubo
Copy link

kubo commented Dec 15, 2022

@yunkyukim Could you post command output as @larskanis requested at #320 (comment)? Copy whole command output, not only the error lines, and paste it in a code block. The location of the error may be a hint to resolve this.

By the way, it may be fixed by changing TMP and TEMP environment variables as follows. The default value of them is C:\Users\%USERNAME%\AppData\Local\Temp and cc4K9XbU.s looks a temporary file created in the temporary directory specified by TMP or TEMP. I guess that it is fixed when either TMP or TEMP doesn't contain non-ASCII characters.

mkdir c:\temp
set TMP=c:\temp
set TEMP=c:\temp
gem inst jekyll --no-doc

@yunkyukim
Copy link
Author

yunkyukim commented Dec 16, 2022

@kubo My username is in Korean so I guess it is the reason.
Here's the whole command:

C:\Users\나>gem inst jekyll --no-doc
Building native extensions. This could take a while...
ERROR:  Error installing jekyll:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 extconf.rb
creating Makefile

current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20221216-11260-zbad8z sitelibdir\=./.gem.20221216-11260-zbad8z clean
bash.exe: warning: could not find /tmp, please create!

current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20221216-11260-zbad8z sitelibdir\=./.gem.20221216-11260-zbad8z
compiling ./libsass/src/ast.cpp
compiling ./libsass/src/ast2c.cpp
compiling ./libsass/src/ast_fwd_decl.cpp
compiling ./libsass/src/ast_sel_cmp.cpp
compiling ./libsass/src/ast_sel_super.cpp
compiling ./libsass/src/ast_sel_unify.cpp
compiling ./libsass/src/ast_sel_weave.cpp
compiling ./libsass/src/ast_selectors.cpp
compiling ./libsass/src/ast_supports.cpp
compiling ./libsass/src/ast_values.cpp
compiling ./libsass/src/backtrace.cpp
compiling ./libsass/src/base64vlq.cpp
compiling ./libsass/src/bind.cpp
compiling ./libsass/src/c2ast.cpp
compiling ./libsass/src/c99func.c
Assembler messages:
Error: can't open C:\Users\��\AppData\Local\Temp\ccGeDH5w.s for reading: Illegal byte sequence
make: *** [Makefile:247: c99func.o] 오류 1

make failed, exit code 2

Gem files will remain installed in C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/sassc-2.4.0 for inspection.
Results logged to C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/sassc-2.4.0/gem_make.out

@kubo
Copy link

kubo commented Dec 16, 2022

@yunkyukim
Could you create a directory c:\temp and set TMP=c:\temp as described in #320 (comment)?

I reproduced this issue by setting TMP=c:\いろは on Japanese version of Windows as follows. I guess that this can be reproduced by setting a non-ASCII path to TMP on other language versions.

C:\ruby\rubyinstaller-3.1.0-1-x64\bin>mkdir c:\いろは

C:\ruby\rubyinstaller-3.1.0-1-x64\bin>set TMP=c:\いろは

C:\ruby\rubyinstaller-3.1.0-1-x64\bin>gem install sassc
Fetching sassc-2.4.0.gem
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing sassc:
        ERROR: Failed to build gem native extension.

    current directory: C:/ruby/rubyinstaller-3.1.0-1-x64/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
C:/ruby/rubyinstaller-3.1.0-1-x64/bin/ruby.exe -I C:/ruby/rubyinstaller-3.1.0-1-x64/lib/ruby/3.1.0 -r ./siteconf20221216-14020-qhey2.rb extconf.rb
creating Makefile

current directory: C:/ruby/rubyinstaller-3.1.0-1-x64/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
make DESTDIR\= clean

current directory: C:/ruby/rubyinstaller-3.1.0-1-x64/lib/ruby/gems/3.1.0/gems/sassc-2.4.0/ext
make DESTDIR\=
compiling ./libsass/src/ast.cpp
compiling ./libsass/src/ast2c.cpp
compiling ./libsass/src/ast_fwd_decl.cpp
compiling ./libsass/src/ast_sel_cmp.cpp
compiling ./libsass/src/ast_sel_super.cpp
compiling ./libsass/src/ast_sel_unify.cpp
compiling ./libsass/src/ast_sel_weave.cpp
compiling ./libsass/src/ast_selectors.cpp
compiling ./libsass/src/ast_supports.cpp
compiling ./libsass/src/ast_values.cpp
compiling ./libsass/src/backtrace.cpp
compiling ./libsass/src/base64vlq.cpp
compiling ./libsass/src/bind.cpp
compiling ./libsass/src/c2ast.cpp
compiling ./libsass/src/c99func.c
Assembler messages:
Error: can't open c:\�����\ccaKD7kF.s for reading: Illegal byte sequence
make: *** [Makefile:246: c99func.o] エラー 1

make failed, exit code 2

Gem files will remain installed in C:/ruby/rubyinstaller-3.1.0-1-x64/lib/ruby/gems/3.1.0/gems/sassc-2.4.0 for inspection.
Results logged to C:/ruby/rubyinstaller-3.1.0-1-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/sassc-2.4.0/gem_make.out

@larskanis
Copy link
Member

Thank you @kubo ! I can reproduce the issue as well by setting TMP to a unicode path. The issue is in gcc which seems to not use Unicode WINAPI. One can work around by setting the gcc options like so:

diff --git a/lib/ruby/3.1.0/x64-mingw-ucrt/rbconfig.rb b/lib/ruby/3.1.0/x64-mingw-ucrt/rbconfig.rb
index d82a209..4828a08 100644
--- a/lib/ruby/3.1.0/x64-mingw-ucrt/rbconfig.rb
+++ b/lib/ruby/3.1.0/x64-mingw-ucrt/rbconfig.rb
@@ -174,8 +174,8 @@ module RbConfig
   CONFIG["CXXFLAGS"] = "-march=nocona -msahf -mtune=generic -O2 -pipe"
   CONFIG["OBJEXT"] = "o"
   CONFIG["CPPFLAGS"] = "-D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0600 -D__MINGW_USE_VC2005_COMPAT $(DEFS) $(cppflags)"
-  CONFIG["LDFLAGS"] = "-L. -pipe -s -fstack-protector-strong -Wl,--no-as-needed"
-  CONFIG["CFLAGS"] = "-O3 -fno-fast-math -fstack-protector-strong"
+  CONFIG["LDFLAGS"] = "-L. -pipe -save-temps -s -fstack-protector-strong -Wl,--no-as-needed"
+  CONFIG["CFLAGS"] = "-O3 -pipe -fno-fast-math -fstack-protector-strong"
   CONFIG["STRIP"] = "strip -S -x"
   CONFIG["RANLIB"] = "x86_64-w64-mingw32-gcc-ranlib"
   CONFIG["OBJDUMP"] = "objdump"

I wonder if we should enable these options by default in RubyInstaller. -pipe is save to be used on Windows and fixes the issue for *.c files when invoking the assembler. -pipe is already enabled for *.cpp. So this is a no-brainer. I'm uncertain if -save-temps could have a negative impact. Any idea?

larskanis added a commit to oneclick/rubyinstaller2-packages that referenced this issue Dec 16, 2022
larskanis added a commit to oneclick/rubyinstaller2-packages that referenced this issue Dec 16, 2022
@kubo
Copy link

kubo commented Dec 22, 2022

This is just information. I'm not against the fix.

In aa15f1a

cmd and powershell mechanism to set variables doesn't support Unicode either.

cmd in Japanese version of Windows supports Unicode characters as long as they are in CP932 (ANSI and OEM code page in Japanese version). I bet that c:\いろは in Japanese version and C:\Users\나\AppData\Local\Temp in Korean version cause no problems if gcc uses ANSI API in all places and treats byte sequence got by ANSI API as it is. The problem is that gcc supports unicode partly and decodes byte sequence of ANSI code page as UTF-8.

In order to check it, I set TMP=c:\ツア on Japanese version and got the error message: "No such file or directory" instead of "Illegal byte sequence".

Error: can't open c:\±\ccKrzIwR.s for reading: No such file or directory

The byte sequence of c:\ツア in CP932 is 63 3A 5C C2 B1, which is also legal byte sequence of c:\± in UTF-8. So the error message "Illegal byte sequence" disappears.

character byte sequence in cp932 byte sequence in utf-8
c 63 63
: 3A 3A
\ 5C 5C
C2 EF BE 82
B1 EF BD B1
± 81 7D C2 B1

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

No branches or pull requests

4 participants