- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.8k
 
Fix to work with UTF-8 Gem $HOME #8188
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
Conversation
| 
           Hi! I'm not going to merge this because it seems like it would cause more problems than it solves, but I can try to help you figure out another solution. It seems like something is up with your environment — ASCII only defines 128 characters, and they don't include  I added a user with the same username on my system, and with a UTF-8  Can you provide the output of running   | 
    
| 
           It's not related with environment. I'm only using UTF-8 
       first_line = File.open(file, "rb") {|f| f.read(possibilities.map(&:size).max) }
      possibilities.any? {|shebang| first_line.start_with?(shebang) }
  | 
    
| 
           Hmm something's off, I don't understand why it was failing, I thought that you can't use  first_line = 'test'.force_encoding('ASCII-8BIT')
shebang = '/home/Dāvis/.rvm/rubies/ruby-3.3.4/bin/ruby'
first_line.start_with?(shebang)
# No exceptionbut then why did it show up like that...  | 
    
| 
           Now also it doesn't seem to be happening anymore, weird...  | 
    
| 
           I dug into this a bit more. Turns out, string interpolation putting an ASCII-8BIT string into a UTF-8 string results in a UTF-8 string. That means that  This means it is impossible for this to have fixed anything, on any system.  | 
    
| 
           I think this error may be real, and not a misconfiguration, and although I'm no encoding expect, I think @davispuh fix may do the trick. I used the same trick for a similar error at #8196. @duckinator If you run  I didn't fully simulate the situation myself but I can recreate the error like @davispuh suggested below, just slightly modified:  | 
    
What was the end-user or developer problem that led to this PR?
I'm using RVM and my $HOME is
/home/DāvissoGem.rubyreturns/home/Dāvis/.rvm/rubies/ruby-3.3.4/bin/rubywhich is withUTF-8encoding and that causes failureWhat is your fix for the problem, implemented in this PR?
This PR fixes this issue by setting
ASCII-8BITand using that for comparison instead.Make sure the following tasks are checked