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 ไหน


Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more