DEV Community

MrChoke
MrChoke

Posted on • Originally published at Medium on

1

Homebrew M1 (ARM64)

ใครสนใจทดลองเล่น package ที่ติดตั้งจาก Homebrew แบบ M1 หรือ ARM64 ตอนนี้ก็สามารถเล่นกันได้แล้ว package พื้นฐานหลายตัวได้รับการ patch ผมบันทึกไว้สั้นๆ ดังนี้

ภาพจากเว็บ brew.sh

x86_64

ณ ตอนนี้ทางทีมงาน Homebrew ยังแนะนำให้ใช้แบบ x86_64 เพื่อความมั่นใจว่าใช้งานได้แน่นอนซึ่งการติดตั้งแบบนี้ง่ายๆ ทำได้ดังนี้

arch -x86_64 /bin/bash -c "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install.sh](https://raw.githubusercontent.com/Homebrew/install/master/install.sh))"

arch -x86_64 brew install htop
Enter fullscreen mode Exit fullscreen mode

การใช้ arch -x86_64 ยังสามารถใช้ได้กับหลายๆ สถานการเช่น compile source code ถ้าไม่ระบุอะไรเลยมันจะพยายาม compile เป็นแบบ arm64 เราก็ใส่ arch -x86_64 ไว้ข้างหน้าแล้วทำการ configure หรือ make หรือตอนเรียกใช้งานก็ได้ เช่นในกรณีของ brew ตอนเรียกใช้สามารถใส่ arch -x86_64ไว้หน้าคำสั่ง brew ก็ได้ แต่มันก็น่ารำคาญหลายคนแนะนำให้เปิด terminal ใน mode x86_64 ไปเลยก็ได้

เปิด iTerm ใน mode x86_64

เปิด Terminal ใน mode x86_64

M1 (ARM64)

สำหรับคนที่ชอบตื่นเต้นก็ต้องเสี่ยงและลุ้นกันหน่อย Homebrew กำลัง patch และทดสอบกันอย่างเข้มข้นทำให้ตอนนี้ package หลายๆ ตัวสามารถทำงานได้แล้ว วิธีติดตั้งก็ไม่ยากอะไรครับทำตามนี้เลย

mkdir /opt/homebrew
sudo chown mrchoke /opt/homebrew ## เปลี่ยนเป็นชื่อ user ของคุณ
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C /opt/homebrew
Enter fullscreen mode Exit fullscreen mode

ถ้าไม่มีอะไรผิดพลาดก็สามารถเรียกใช้ brew ได้โดยตรงที่

/opt/homebrew/bin/brew update
Enter fullscreen mode Exit fullscreen mode

SET PATH

echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

ตอนนี้ก็น่าจะเรียก brew แบบสั้นๆ ได้แล้วลองติดตั้งกันได้เลย

brew install htop
Enter fullscreen mode Exit fullscreen mode

การติดตั้งใน mode arm64 จะช้าหน่อยนะครับเพราะส่วนใหญ่ อาจจะทั้งหมดต้อง compile ก้นสดๆ

สามารถทดสอบกันได้ว่า binary ที่ได้เป็นแบบไหนโดยใช้คำสั่ง

file /opt/homebrew/bin/htop
Enter fullscreen mode Exit fullscreen mode

ตรวจ arch ของ binary

ตรวจดูว่ามัน run ใน mode ไหน


Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay