---
title: "เปลี่ยนเวอร์ชัน Ruby สำหรับรันคำสั่งเดียวด้วย rbenv"
description: "สลับเวอร์ชัน Ruby ชั่วคราวได้ด้วย rbenv local"
canonical: https://oozou.com/til/change-ruby-version-for-single-command-with-rbenv-68
locale: th
date: 2020-10-13
topic: ruby
---

# เปลี่ยนเวอร์ชัน Ruby สำหรับรันคำสั่งเดียวด้วย rbenv

> สลับเวอร์ชัน Ruby ชั่วคราวได้ด้วย rbenv local

Published: 2020-10-13 · Topic: [ruby](https://oozou.com/th/til-topics/ruby) ([markdown](https://oozou.com/th/til-topics/ruby.md))

สลับเวอร์ชัน Ruby ชั่วคราวได้ด้วย *rbenv local*

แต่พอใช้เสร็จก็ต้องสลับกลับ ยิ่งถ้าจะรันแค่คำสั่งเดียวก็ยิ่งน่ารำคาญ ในกรณีแบบนี้ ให้ใช้ env variable *RBENV\_VERSION* แทน

```
RBENV_VERSION=2.6.3 ruby -v
```

วิธีนี้น่าจะมีประโยชน์เวลาใช้ใน shell script หรืองานทำนองนั้น

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/th/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
